实例一、查看当前文件夹内详细信息
[root@localhost ~]# ls -l
总计 88
-rw------- 1 root root 1019 2015-05-23 anaconda-ks.cfg
-rw-r--r-- 1 root root 13894 2015-05-23 install.log
-rw-r--r-- 1 root root 3048 2015-05-23 install.log.syslog
实例二、查看当前文件夹内详细信息,包含隐藏文件
[root@localhost ~]# ls -la
总计 200
drwxr-x--- 3 root root 4096 11-05 16:51 .
drwxr-xr-x 24 root root 4096 12-10 11:47 ..
-rw------- 1 root root 1019 2015-05-23 anaconda-ks.cfg
-rw------- 1 root root 25335 12-17 17:57 .bash_history
-rw-r--r-- 1 root root 24 2007-01-06 .bash_logout
-rw-r--r-- 1 root root 191 2007-01-06 .bash_profile
-rw-r--r-- 1 root root 176 2007-01-06 .bashrc
-rw-r--r-- 1 root root 100 2007-01-06 .cshrc
-rw-r--r-- 1 root root 13894 2015-05-23 install.log
-rw-r--r-- 1 root root 3048 2015-05-23 install.log.syslog
-rw------- 1 root root 40 10-20 08:54 .lesshst
-rw------- 1 root root 456 2015-05-23 .mysql_history
-rw------- 1 root root 1024 2015-05-23 .rnd
-rw-r--r-- 1 root root 129 2007-01-06 .tcshrc
-rw------- 1 root root 4535 10-24 15:40 .viminfo
实例三、查看当前文件夹内详细信息,不包含当前目录(.)和上层目录(..)
[root@localhost ~]# ls -lA
总计 184
-rw------- 1 root root 1019 2015-05-23 anaconda-ks.cfg
-rw------- 1 root root 25335 12-17 17:57 .bash_history
-rw-r--r-- 1 root root 24 2007-01-06 .bash_logout
-rw-r--r-- 1 root root 191 2007-01-06 .bash_profile
-rw-r--r-- 1 root root 176 2007-01-06 .bashrc
-rw-r--r-- 1 root root 100 2007-01-06 .cshrc
-rw-r--r-- 1 root root 13894 2015-05-23 install.log
-rw-r--r-- 1 root root 3048 2015-05-23 install.log.syslog
-rw------- 1 root root 40 10-20 08:54 .lesshst
-rw------- 1 root root 47389 2015-06-02 mail
-rw------- 1 root root 456 2015-05-23 .mysql_history
-rw------- 1 root root 1024 2015-05-23 .rnd
-rw-r--r-- 1 root root 129 2007-01-06 .tcshrc
drwxr-xr-x 2 root root 4096 12-17 17:29 test
-rw------- 1 root root 4535 10-24 15:40 .viminfo
实例四、查看当前文件夹内详细信息,按时间排序
[root@localhost ~]# ls -lt
总计 88
drwxr-xr-x 2 root root 4096 12-17 17:29 test
-rw------- 1 root root 47389 2015-06-02 mail
-rw------- 1 root root 1019 2015-05-23 anaconda-ks.cfg
-rw-r--r-- 1 root root 13894 2015-05-23 install.log
-rw-r--r-- 1 root root 3048 2015-05-23 install.log.syslog
实例五、查看当前文件夹内详细信息,包含inode号
[root@localhost ~]# ls -li
总计 88
4055305 -rw------- 1 root root 1019 2015-05-23 anaconda-ks.cfg
4055298 -rw-r--r-- 1 root root 13894 2015-05-23 install.log
4055299 -rw-r--r-- 1 root root 3048 2015-05-23 install.log.syslog
4055306 -rw------- 1 root root 47389 2015-06-02 mail
4055310 drwxr-xr-x 2 root root 4096 12-17 17:29 test
实例六、查看当前文件夹内详细信息,以k为单位
[root@localhost ~]# ls -lk
总计 88
-rw------- 1 root root 1 2015-05-23 anaconda-ks.cfg
-rw-r--r-- 1 root root 14 2015-05-23 install.log
-rw-r--r-- 1 root root 3 2015-05-23 install.log.syslog
-rw------- 1 root root 47 2015-06-02 mail
drwxr-xr-x 2 root root 4 12-17 17:29 test
实例七、查看当前文件夹内文件名,以逗号隔开
[root@localhost ~]# ls -m
anaconda-ks.cfg, install.log, install.log.syslog, mail, test
实例八、查看当前文件夹内详细信息,用户名和组名替换为UID,GID
[root@localhost ~]# ls -ln
总计 88
-rw------- 1 0 0 1019 2015-05-23 anaconda-ks.cfg
-rw-r--r-- 1 0 0 13894 2015-05-23 install.log
-rw-r--r-- 1 0 0 3048 2015-05-23 install.log.syslog
-rw------- 1 0 0 47389 2015-06-02 mail
drwxr-xr-x 2 0 0 4096 12-17 17:29 test
实例九、查看当前文件夹内详细信息,不包含组信息
[root@localhost ~]# ls -lo
总计 88
-rw------- 1 root 1019 2015-05-23 anaconda-ks.cfg
-rw-r--r-- 1 root 13894 2015-05-23 install.log
-rw-r--r-- 1 root 3048 2015-05-23 install.log.syslog
-rw------- 1 root 47389 2015-06-02 mail
drwxr-xr-x 2 root 4096 12-17 17:29 test
实例十、查看当前文件夹内详细信息,不包含用户信息
[root@localhost ~]# ls -lG
总计 88
-rw------- 1 root 1019 2015-05-23 anaconda-ks.cfg
-rw-r--r-- 1 root 13894 2015-05-23 install.log
-rw-r--r-- 1 root 3048 2015-05-23 install.log.syslog
-rw------- 1 root 47389 2015-06-02 mail
drwxr-xr-x 2 root 4096 12-17 17:29 test
实例十一、查看当前文件夹内详细信息,以文件名作反向排序
[root@localhost ~]# ls -lr
总计 88
drwxr-xr-x 2 root root 4096 12-17 17:29 test
-rw------- 1 root root 47389 2015-06-02 mail
-rw-r--r-- 1 root root 3048 2015-05-23 install.log.syslog
-rw-r--r-- 1 root root 13894 2015-05-23 install.log
-rw------- 1 root root 1019 2015-05-23 anaconda-ks.cfg
实例十二、列出链接文件名,不显示链接目标文件
[root@localhost rc.d]# ls -lL /etc/rc.local
-rwxr-xr-x 1 root root 688 2015-05-28 /etc/rc.local
实例十三、把输出的文件名用""括起来
[root@localhost rc.d]# ls -lQ /etc/rc.local
lrwxrwxrwx 1 root root 13 2015-05-23 "/etc/rc.local" -> "rc.d/rc.local"
实例十四、列出当前目录及子目录详细信息
[root@localhost ~]# ls -lR
.:
总计 88
-rw------- 1 root root 1019 2015-05-23 anaconda-ks.cfg
-rw-r--r-- 1 root root 13894 2015-05-23 install.log
-rw-r--r-- 1 root root 3048 2015-05-23 install.log.syslog
-rw------- 1 root root 47389 2015-06-02 mail
drwxr-xr-x 2 root root 4096 12-17 17:29 test
./test:
总计 4
-rw-r--r-- 1 root root 33 12-17 17:29 11.txt
实例十五、以大小进行排序
[root@localhost ~]# ls -lS
总计 88
-rw------- 1 root root 47389 2015-06-02 mail
-rw-r--r-- 1 root root 13894 2015-05-23 install.log
drwxr-xr-x 2 root root 4096 12-17 17:29 test
-rw-r--r-- 1 root root 3048 2015-05-23 install.log.syslog
-rw------- 1 root root 1019 2015-05-23 anaconda-ks.cfg
实例十六、以文件扩展名排序
[root@localhost ~]# ls -lX
总计 88
-rw------- 1 root root 47389 2015-06-02 mail
drwxr-xr-x 2 root root 4096 12-17 17:29 test
-rw------- 1 root root 1019 2015-05-23 anaconda-ks.cfg
-rw-r--r-- 1 root root 13894 2015-05-23 install.log
-rw-r--r-- 1 root root 3048 2015-05-23 install.log.syslog
实例十七、列出当前目录文件名,一行只显示一个
[root@localhost ~]# ls -1
anaconda-ks.cfg
install.log
install.log.syslog
test
实例十八、查看当前文件夹详细信息
[root@localhost ~]# ls -ld
drwxr-x--- 3 root root 4096 11-05 16:51 .