ls:list directory contents列出文件目录列表

选项:

-a 全部的文件,包含隐藏文件

-A 列出全部文件,不包含. ..

-d 仅列出目录本身,不包含目录下的文件数据(常用)

-F 根据文件/目录等信息给与附加的数据结构,可执行文件* 目录/ socket文件= FIFO文件|

-h 可读的方式显示容量信息(常用)

-i 列出inode号码

-l 列出长数据格式,包含文件属性及权限等数据(常用)

-r 将排序结果反向输出,ls默认是按文件名正向排序,而加r后反向排序

-R 连同子目录内容一起列出来(常用)

-S 以文件大小排序

-t 以modification time 时间排序(常用)

--color=never    不要依据文件特性给予颜色显示

--color=always    显示颜色

--color=auto       让系统自行依据设置来判断是否给予颜色

--full-time            以完整时间格式来显示时间

--time=atime        访问时间,access访问之意,当文件被读取,如cat more less ,此时间将被更改。

--time=ctime        改变权限属性时间,status状态之意,当文件的权限与属性更改后,此时间将被更改。

--time=mtime      内容更改时间,modification 作更改之意,当文件内容被更改时,此时间将被更改。

实例:

[root@www ~]# ls -dl yang
drwxr--r--. 2 yang test 4096 8月  25 04:22 yang
[root@www ~]# ll -lh install.log
-rw-r--r--. 1 root root 13K 8月  16 19:53 install.log
[root@www ~]# ls -F
anaconda-ks.cfg  install.log  install.log.syslog  test1.txt  test.txt  yang/
[root@www ~]#
[root@www ~]# ls -li
总用量 36
5982 -rw-------. 1 root      root   981 8月  16 19:53 anaconda-ks.cfg
  54 -rw-r--r--. 1 root      root 12877 8月  16 19:53 install.log
  69 -rw-r--r--. 1 root      root  3482 8月  16 19:52 install.log.syslog
6049 -rw-r--r--. 1 root      root   399 8月  23 05:26 test1.txt
6050 -rw-r--r--. 1 root      root   610 8月  23 05:04 test.txt
2467 drwxr--r--. 2 yanghaifu test  4096 8月  25 04:22 yang
[root@www ~]# ls -lr     #与上面的实例排序有差异
总用量 36
drwxr--r--. 2 yanghaifu test  4096 8月  25 04:22 yang
-rw-r--r--. 1 root      root   610 8月  23 05:04 test.txt
-rw-r--r--. 1 root      root   399 8月  23 05:26 test1.txt
-rw-r--r--. 1 root      root  3482 8月  16 19:52 install.log.syslog
-rw-r--r--. 1 root      root 12877 8月  16 19:53 install.log
-rw-------. 1 root      root   981 8月  16 19:53 anaconda-ks.cfg
[root@www ~]# ls -R
.:
anaconda-ks.cfg  install.log  install.log.syslog  test1.txt  test.txt  yang
./yang:
test.txt
[root@www ~]#

实例:查看/var/log下有多少文件      -R   递归recursion

[root@www ~]# ls  /var/log/ -lR | grep "^-" |wc -l        -R   递归recursion
75
[root@www ~]#