列出指定目錄內容,默認當前目錄,默認按升序排列結果
命令格式:
ls [OPTION]... [FILE]...
選項:
-a, --all 列出所有內容
-A, --almost-all 列出除 . 和 .. 意外的所有內容
-l 用長列表格式輸出結果
-author 同時顯示文件的所有者
-d 列出指定目錄自身信息,不含其目錄內的內容
-h 與 -l 選項一起用,將文件大小以更適合人閱讀的格式輸出,如1K 234M 2G
-i 列出每個文件的 inode 索引號
-r 降序排列輸出結果
使用示例:
# ls -a
. .bash_logout .cache Desktop .gnome2 initial-setup-ks.cfg Music .tcshrc .Xauthority
.. .bash_profile .config Documents .gnome2_private .lesshst Pictures Templates
anaconda-ks.cfg .bashrc .cshrc Downloads home .local Public Videos
.bash_history bin .dbus .esd_auth .ICEauthority .mozilla .ssh .viminfo
# ls -A
anaconda-ks.cfg .bashrc .cshrc Downloads home .local Public Videos
.bash_history bin .dbus .esd_auth .ICEauthority .mozilla .ssh .viminfo
.bash_logout .cache Desktop .gnome2 initial-setup-ks.cfg Music .tcshrc .Xauthority
.bash_profile .config Documents .gnome2_private .lesshst Pictures Templates
# ls -l //以長列表格式顯示結果
total 8
-rw-------. 1 root root 2065 Sep 18 14:03 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Feb 21 11:53 bin
drwxr-xr-x. 2 root root 6 Nov 24 09:54 Desktop
# ls -author //列出文件的所有者信息
total 92K
-rw-r--r--. 1 root 129 Dec 29 2013 .tcshrc
-rw-r--r--. 1 root 100 Dec 29 2013 .cshrc
# ls -ld / //顯示目錄自身的信息
dr-xr-xr-x. 17 root root 4096 Sep 18 14:03 /
# ls -lh //以更適合人閱讀的格式顯示文件大小
total 8.0K
-rw-------. 1 root root 2.1K Sep 18 14:03 anaconda-ks.cfg
# ls -li //顯示每個文件的inode索引號
total 8
54305280 -rw-------. 1 root root 2065 Sep 18 14:03 anaconda-ks.cfg
18622177 drwxr-xr-x. 2 root root 6 Feb 21 11:53 bin
# ls -lr //降序排列輸出結果
total 8
drwxr-xr-x. 2 root root 6 Nov 24 09:54 Videos
drwxr-xr-x. 2 root root 6 Nov 24 09:54 Templates
drwxr-xr-x. 2 root root 6 Nov 24 09:54 Public