命令名称:ls
命令英文原意:list
命令所在路径:/bin/ls
执行权限:所有用户
功能描述:显示目录文件
语法:ls 选项[-ald] [文件或目录]
-a 显示所有文件,包括隐藏文件
-l 详细信息显示
-d 查看目录属性
不加任何参数(即查询当前目录):
macbook-pro:~ dok$ ls
Applications Documents Movies Public
Applications (Parallels) Downloads Music opt
Desktop Library Pictures
查询所有当前目录的隐藏文件:
macbook-pro:~ dok$ ls -a
. .anyconnect Applications (Parallels) Music
.. .bash_history Desktop Pictures
.CFUserTextEncoding .emacs.d Documents Public
.DS_Store .m2 Downloads opt
.IdeaIC14 .xlive Library 快盘
.Trash Applications Movies
查询根目录下所有文件:
macbook-pro:~ dok$ ls /
Applications Volumes home sbin
Library bin installer.failurerequests tmp
Network cores net usr
System dev opt var
Users etc private
l 代表long,长格式:
macbook-pro:~ dok$ ls -l
total 0
drwxr-xr-x 5 dok staff 170 8 22 22:14 Applications
drwxr-xr-x@ 4 dok staff 136 9 14 22:31 Applications (Parallels)
drwx------+ 6 dok staff 204 9 19 08:52 Desktop
drwx------+ 10 dok staff 340 8 24 22:13 Documents
drwx------+ 7 dok staff 238 9 21 22:36 Downloads
drwx------@ 50 dok staff 1700 8 17 23:45 Library
drwx------+ 3 dok staff 102 7 28 14:43 Movies
drwx------+ 6 dok staff 204 8 15 18:56 Music
drwx------+ 5 dok staff 170 8 15 18:56 Pictures
drwxr-xr-x+ 5 dok staff 170 7 28 14:43 Public
drwxr-xr-x 3 dok staff 102 8 22 09:50 opt
drwxr-xr-x@ 12 dok staff 408 9 21 10:33 快盘
查询文件大小并显示文件大小类型:
macbook-pro:~ dok$ ls -lh
total 0
drwxr-xr-x 5 dok staff 170B 8 22 22:14 Applications
drwxr-xr-x@ 4 dok staff 136B 9 14 22:31 Applications (Parallels)
drwx------+ 6 dok staff 204B 9 19 08:52 Desktop
drwx------+ 10 dok staff 340B 8 24 22:13 Documents
drwx------+ 7 dok staff 238B 9 21 22:36 Downloads
drwx------@ 50 dok staff 1.7K 8 17 23:45 Library
drwx------+ 3 dok staff 102B 7 28 14:43 Movies
drwx------+ 6 dok staff 204B 8 15 18:56 Music
drwx------+ 5 dok staff 170B 8 15 18:56 Pictures
drwxr-xr-x+ 5 dok staff 170B 7 28 14:43 Public
drwxr-xr-x 3 dok staff 102B 8 22 09:50 opt
看出目录详细信息:
macbook-pro:~ dok$ ls -ld /etc
lrwxr-xr-x@ 1 root wheel 11 6 28 04:39 /etc -> private/etc
文件id号(即为inode)
macbook-pro:~ dok$ ls -i
471009 Applications 451173 Downloads 451231 Pictures
470983 Applications (Parallels) 451175 Library 451233 Public
451187 Desktop 451227 Movies 1075292 opt
451171 Documents 451229 Music 1386413 快盘
-rw-r--r--
-文件类型(- 代表二进制文件,d 代表目录,l 代表软连接)
rw- r-- r--
u g o
u:所有者,g:所属组,o:其他人
r:读,w:写,x:执行
尊重原创,拒绝转载
http://blog.csdn.net/stark_summer/article/details/48638199
版权声明:本文为博主原创文章,未经博主允许不得转载。