Linux中ls使用方法

170 阅读3分钟

ls -l:显示文件详细信息

# ls -l
总用量 8
-rw-------. 1 root root 1418 918 06:27 anaconda-ks.cfg
-rw-r--r--. 1 root root   58 918 22:46 dnfaifonvvreigh
//第一列:文件权限
//第二列:有多少文件使用相同的iNode号
//第三列:所有者
//第四列:所属组
//第五列:文件大小,默认为byte
//第六列:文件创建时间
//第七列:文件名称

ls -i:显示文件iNode号

# ls -i anaconda-ks.cfg
33582978 anaconda-ks.cfg
//前面显示为文件的iNode号

ls-lh:以人性化显示文件大小

# ls -lh anaconda-ks.cfg
-rw-------. 1 root root 1.4K 918 06:27 anaconda-ks.cfg
//文件大小以k显示

ls -la:显示隐藏文件

# ls -la
总用量 60
dr-xr-x---.  3 root root   218 9月  20 21:06 .
dr-xr-xr-x. 17 root root   224 921 22:00 ..
-rw-------.  1 root root  1418 9月  18 06:27 anaconda-ks.cfg
-rw-------.  1 root root  1956 9月  23 22:36 .bash_history
-rw-r--r--.  1 root root    18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root   176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root   176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root   100 12月 29 2013 .cshrc
-rw-r--r--.  1 root root    58 9月  18 22:46 dnfaifonvvreigh
-rw-------.  1 root root    35 9月  18 22:46 .lesshst
drwx------.  2 root root    80 9月  22 20:55 .ssh
-rw-------.  1 root root 12288 9月  20 20:43 .ssh.swo
-rw-------.  1 root root 12288 9月  20 20:42 .ssh.swp
-rw-r--r--.  1 root root   129 12月 29 2013 .tcshrc
//文件名前面有 . 的表示隐藏文件

ls -lt:以时间的顺序排序

# ls -lt /
总用量 20
drwxr-xr-x.  24 root root  660 9  23 21:04 run
drwxrwxrwt.  28 root root 4096 9  23 21:04 tmp
drwxr-xr-x.  74 root root 8192 9  23 21:02 etc
drwxr-xr-x.  19 root root 3200 9  23 21:02 dev
dr-xr-xr-x.  13 root root    0 9  23 21:02 sys
dr-xr-xr-x. 108 root root    0 9  23 21:02 proc
dr-xr-x---.   3 root root  218 9  20 21:06 root
drwxr-xr-x.  19 root root  267 9  19 05:08 var
dr-xr-xr-x.   5 root root 4096 9  18 06:27 boot
drwxr-xr-x.  13 root root  155 9  18 06:20 usr
lrwxrwxrwx.   1 root root    8 9  18 06:20 sbin -> usr/sbin
lrwxrwxrwx.   1 root root    7 9  18 06:20 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 9  18 06:20 lib64 -> usr/lib64
lrwxrwxrwx.   1 root root    7 9  18 06:20 bin -> usr/bin
drwxr-xr-x.   2 root root    6 4  11 2018 home
drwxr-xr-x.   2 root root    6 4  11 2018 media
drwxr-xr-x.   2 root root    6 4  11 2018 mnt
drwxr-xr-x.   2 root root    6 4  11 2018 opt
drwxr-xr-x.   2 root root    6 4  11 2018 srv
//最新修改的文件在最上面显示

ls -ld:显示文件目录本身详细信息

# ls -ld /
dr-xr-xr-x. 17 root root 224 921 22:00 /
//显示目录本身的详细信息