一、ls命令简介
命令所在路径:/bin/ls (所有人可以使用)命令英文原意:list (清单)功能描述:显示目录、文件语法:ls+选项+文件或目录二、ls命令的选项
1. -a:显示所有文件,包括隐藏文件(“.”“..”) 2. -A:显示所有文件,但是不包括“.”“..” 3. -l:已成格式显示(显示详细信息),ls -l+操作对象是单独看对象的详细信息。 4. -d:显示当前目录名,不显示目录下的内容。(通常和-l连用,格式为ls -ld)。 5. -h:文件大小显示常见大小单位,B、KB(和-l连用)。 6. -i:显示文件的inode号,(+操作对象显示指定文件的inode号) 7. -R:递归处理,显示制定目录和子目录。 8. -s:显示文件和目录的大小,以区块为单位。 9. --full-time:列出完整的日期与时间。 10. --color [=when]:高亮显示三、ls命令的实例
[root@localhost ~]# ls anaconda-ks.cfg install.log install.log.syslog [root@localhost ~]# ls -a . .. anaconda-ks.cfg .bash_logout .bash_profile .bashrc .cshrc install.log install.log.syslog .tcshrc .viminfo [root@localhost ~]# ls -A anaconda-ks.cfg .bash_logout .bash_profile .bashrc .cshrc install.log install.log.syslog .tcshrc .viminfo [root@localhost ~]# ls -l 总用量 44 -rw-------. 1 root root 1233 3月 6 17:18 anaconda-ks.cfg -rw-r--r--. 1 root root 27338 3月 6 17:18 install.log -rw-r--r--. 1 root root 7572 3月 6 17:15 install.log.syslog [root@localhost ~]# ls -ld dr-xr-x---. 2 root root 4096 3月 6 19:24 . [root@localhost ~]# ls -lh 总用量 44K -rw-------. 1 root root 1.3K 3月 6 17:18 anaconda-ks.cfg -rw-r--r--. 1 root root 27K 3月 6 17:18 install.log -rw-r--r--. 1 root root 7.4K 3月 6 17:15 install.log.syslog [root@localhost ~]# ls -i 397161 anaconda-ks.cfg 393219 install.log 393220 install.log.syslog [root@localhost ~]# ls -R .: anaconda-ks.cfg install.log install.log.syslog [root@localhost ~]# ls -s 总用量 44 4 anaconda-ks.cfg 32 install.log 8 install.log.syslog [root@localhost ~]# ls --full-time 总用量 44 -rw-------. 1 root root 1233 2017-03-06 17:18:46.819999221 +0800 anaconda-ks.cfg -rw-r--r--. 1 root root 27338 2017-03-06 17:18:33.488999244 +0800 install.log -rw-r--r--. 1 root root 7572 2017-03-06 17:15:47.167999340 +0800 install.log.syslog