菜鸟学习之Linux‘ls’命令实例(2)

例子6:显示当前路径的所有文件的文件大小,以可读形式显示(如:1K234M,2G

[root@localhost /]# ls -lh

total 94K

dr-xr-xr-x. 2 root root 4.0K Nov 23 03:13 bin

dr-xr-xr-x. 5 root root 1.0K Nov 23 05:29 boot

drwxr-xr-x 10 root root 4.0K Nov 23 03:42 cgroup

drwxr-xr-x 18 root root 3.6K Dec 12 21:32 dev

drwxr-xr-x. 64 root root 4.0K Dec 12 21:32 etc

drwxr-xr-x 8 root root 4.0K Jul 19 02:43 home

dr-xr-xr-x. 8 root root 4.0K May 3 2014 lib

dr-xr-xr-x. 8 root root 12K Nov 23 03:13 lib64

-rw-r--r-- 1 root root 72 Dec 12 21:40 linux-stuff

drwx------. 2 root root 16K May 3 2014 lost+found

drwxr-xr-x. 2 root root 4.0K Sep 23 2011 media

drwxr-xr-x. 3 root root 4.0K Jun 22 01:14 mnt

drwxr-xr-x. 2 root root 4.0K Jun 22 01:25 opt

......................................

例子7:显示所有文件,包括隐藏的文件,当前路径的文件显示详细信息

[root@localhost /]# ls -la

total 102

dr-xr-xr-x. 23 root root 4096 Dec 12 21:49 .

dr-xr-xr-x. 23 root root 4096 Dec 12 21:49 ..

-rw-r--r-- 1 root root 0 Dec 12 21:32 .autofsck

-rw-r--r-- 1 root root 0 Jul 19 02:17 .autorelabel

dr-xr-xr-x. 2 root root 4096 Nov 23 03:13 bin

dr-xr-xr-x. 5 root root 1024 Nov 23 05:29 boot

drwxr-xr-x 10 root root 4096 Nov 23 03:42 cgroup

drwxr-xr-x 18 root root 3680 Dec 12 21:32 dev

drwxr-xr-x. 64 root root 4096 Dec 12 21:32 etc

drwxr-xr-x 8 root root 4096 Jul 19 02:43 home

dr-xr-xr-x. 8 root root 4096 May 3 2014 lib

dr-xr-xr-x. 8 root root 12288 Nov 23 03:13 lib64

-rw-r--r-- 1 root root 0 Dec 12 21:48 .linux-rocks

-rw-r--r-- 1 root root 72 Dec 12 21:40 linux-stuff

-rw-r--r-- 1 root root 0 Dec 12 21:49 .linux-tips

drwx------. 2 root root 16384 May 3 2014 lost+found

drwxr-xr-x. 2 root root 4096 Sep 23 2011 media

..................................................................

例子8:用递归的方式列举/etc路径的内容

[root@localhost /]# ls -R /etc/

/etc/:

adjtime

aliases

aliases.db

alternatives

anacrontab

audisp

audit

bash_completion.d

bashrc

blkid

CentOS-release

..........................

例子9:以文件大小的方式排列文件

[root@localhost /]# ls -lhS

total 13M

-rw-r--r-- 1 root root 12M Dec 12 22:05 linux-stuff

drwx------. 2 root root 16K May 3 2014 lost+found

dr-xr-xr-x. 8 root root 12K Nov 23 03:13 lib64

dr-xr-xr-x. 2 root root 4.0K Nov 23 03:13 bin

drwxr-xr-x 10 root root 4.0K Nov 23 03:42 cgroup

drwxr-xr-x. 64 root root 4.0K Dec 12 21:32 etc

drwxr-xr-x 8 root root 4.0K Jul 19 02:43 home

dr-xr-xr-x. 8 root root 4.0K May 3 2014 lib

drwxr-xr-x. 2 root root 4.0K Sep 23 2011 media

drwxr-xr-x. 3 root root 4.0K Jun 22 01:14 mnt

..............................................

上面所有命令显示文件以及路径,都是以文件所占大小 从大到小的方式排列的

例子10:用‘-i’选项列举文件节点以及路径

[root@localhost /]# ls -li

total 12378

786436 dr-xr-xr-x. 2 root root 4096 Nov 23 03:13 bin

2 dr-xr-xr-x. 5 root root 1024 Nov 23 05:29 boot

655361 drwxr-xr-x 10 root root 4096 Nov 23 03:42 cgroup

3 drwxr-xr-x 18 root root 3680 Dec 12 21:32 dev

393217 drwxr-xr-x. 64 root root 4096 Dec 12 21:32 etc

2 drwxr-xr-x 8 root root 4096 Jul 19 02:43 home

917506 dr-xr-xr-x. 8 root root 4096 May 3 2014 lib

262146 dr-xr-xr-x. 8 root root 12288 Nov 23 03:13 lib64

2668 -rw-r--r-- 1 root root 12582912 Dec 12 22:05 linux-stuff

...................................................................

例子11:用‘-version’命令显示当前版本信息

[root@localhost /]# ls --version

ls (GNU coreutils) 8.4

Copyright (C) 2010 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <>.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

Written by Richard M. Stallman and David MacKenzie.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/17071.html