一、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
1.txt 2.txt
[root@localhost ~]# ls -a
. 1.txt .ansible .bash_logout .bashrc .pki .tcshrc
.. 2.txt .bash_history .bash_profile .cshrc .ssh
[root@localhost ~]# ls -A
1.txt .ansible .bash_logout .bashrc .pki .tcshrc
2.txt .bash_history .bash_profile .cshrc .ssh
[root@localhost ~]# ls -l
total 0
-rw-r--r-- 1 root root 0 Mar 8 08:25 1.txt
-rw-r--r-- 1 root root 0 Mar 8 08:25 2.txt
[root@localhost ~]# ls -ld
dr-xr-x---. 5 root root 178 Mar 8 08:25 .
[root@localhost ~]# ls -lh
total 0
-rw-r--r-- 1 root root 0 Mar 8 08:25 1.txt
-rw-r--r-- 1 root root 0 Mar 8 08:25 2.txt
[root@localhost ~]# ls -R
.:
1.txt 2.txt
[root@localhost ~]# ls -s
total 0
0 1.txt 0 2.txt
[root@localhost ~]# ls --full-time
total 0
-rw-r--r-- 1 root root 0 2018-03-08 08:25:58.915663163 +0800 1.txt
-rw-r--r-- 1 root root 0 2018-03-08 08:25:58.915663163 +0800 2.txt