linux基础之常用命令(2)

date


显示当前系统时间

clock或者hwclock


显示当前硬件时钟
hwclock -w :将系统时间同步到硬件时间
hwclock -s :将硬件时间读取到系统时间

获得命令的使用帮助


内部命令:

help < command >

外部命令:

< command > - -help:获取命令的简单帮助

命令手册

man < command >
几乎所有的命令都可以用man查看详细帮助

[root@iZ28g26851kZ ~]# man ls

LS(1)                            User Commands                           LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about  the FILEs (the current directory by default).  Sort
       entries alphabetically if none of -cftuvSUX nor --sort.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

       -b, --escape
              print octal escapes for nongraphic characters

注意看第一行

LS(1)                            User Commands                           LS(1)

ls(1)中的(1)代表“章节”,
1:用户命令 (/bin, /user/bin, /user/local/bin)
2:系统命令
3:库用户
4:特殊文件(设备文件)
5:文件格式(配置文件的语法)
6:游戏
7:杂项(Miscellaneous)
8:管理命令(/sbin, /user/sbin, /user/local/sbin)通常只有管理员才能使用

whatis < command >

显示命令的摘要信息以及出现在哪些章节中

[root@iZ28g26851kZ ~]# whatis read
read                 (1p)  - read a line from standard input
read                 (2)  - read from a file descriptor
read                 (3p)  - read from a file
read [builtins]      (1)  - bash built-in commands, see bash(1)

<>:必选
[]:可选
…可以出现多次
|:多选一
{}:分组

man:

    NAME:命令名称及功能简要说明
    SYNOPSIS:用法说明,包括可用的选项
    DESCRIPTION:命令功能的详尽说明,可能包括每一个选项的意义
    OPTIONS:说明每一个选项的意义
    FILES:此命令相关的配置文件
    BUGS:
    EXAMPLES:使用示例
    SEE ALSO:另外参照

翻屏:

    向后翻一屏:space
    向前翻一屏:b
    向后翻一行:enter
    向前翻一行:k

查找:

    /keyword:向后
    ?keyword:向前
    搜索完之后
    n:定位向后一个结果
    N:定位向前一个结果

mkdir


创建目录空间

-p

当上级目录不存在时自动创建。
例:mkdir /opt/x/y
如果不加参数p,创建会失败,因为x文件不存在,这时加上-p就会自动创建x文件

[root@iZ28g26851kZ ~]# mkdir /opt/x/y
mkdir: cannot create directory `/opt/x/y': No such file or directory
[root@iZ28g26851kZ ~]# mkdir -p /opt/x/y
[root@iZ28g26851kZ ~]# 

-v(verbose)

显示创建过程

[root@iZ28g26851kZ opt]# mkdir -vp x/y/z
mkdir: created directory `x'
mkdir: created directory `x/y'
mkdir: created directory `x/y/z'
[root@iZ28g26851kZ opt]# 

使用{}

mkdir -p x/y x/z 等同于 mkdir -p x/{y,z}

tree

查看目录树结构

[root@iZ28g26851kZ opt]# tree x
x
├── y
│   └── k
└── z

3 directories, 0 files
[root@iZ28g26851kZ opt]# 

rmdir(remove directory)

删除空目录,空目录,空目录,否则会提示目录不是空的

[root@iZ28g26851kZ opt]# rmdir x
rmdir: failed to remove `x': Directory not empty
[root@iZ28g26851kZ opt]# 

-p

使用-p参数:当子目录被删除之后如果父目录为空,则也会被删除

touch


修改文件的时间戳,默认情况下,当文件不存在的时候,会创建该文件

stat


查看文件的状态(文件名,访问时间,修改时间,改变时间)
修改时间:指的是内容被修改,

[root@iZ28g26851kZ x]# stat test 
  File: `test'
  Size: 9           Blocks: 8          IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 1066408     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-05-04 10:55:47.016036253 +0800
Modify: 2016-05-04 10:55:47.016036253 +0800
Change: 2016-05-04 10:55:47.016036253 +0800

rm


删除文件
默认删除文件会提示用户是否删除,也就是加了 -i的效果

-f

强制删除,不进行提示,直接删除文件

-r

删除目录并递归删除目录下的所有文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值