ls 常用参数:
-h:计算文件的大小
-a:显示目录下包括隐藏文件在内的所有文件
-l:查看文件的详细信息
-A:显示目录下包括隐藏文件在内的所有文件,除了‘ **.** ’和‘ **..** ’
-d:显示目录的属性
-S:以文件的大小排序
-i:显示文件的inode编号
-r:逆序显示文件
-R:递归显示
一、显示当前目录下的文件
[root@localhost /]# cd
[root@localhost ~]# ls
anaconda-ks.cfg
二、显示当前目录下的所有文件
[root@localhost ~]# ls -a
. anaconda-ks.cfg .bash_logout .bashrc .tcshrc
.. .bash_history .bash_profile .cshrc
将隐藏的文件也显示出来
三、指定目录查看
[root@localhost ~]# ls /etc/
adjtime hosts python
aliases hosts.allow rc0.d
aliases.db hosts.deny rc1.d
alternatives init.d rc2.d
anacrontab inittab rc3.d
asound.conf inputrc rc4.d
audisp iproute2 rc5.d
四、指定文件查看
[root@localhost ~]# ls /etc/yum.conf
/etc/yum.conf
[root@localhost ~]#
五、查看文件或者文件夹的详细信息
1.ls -l 查看目录下文件的详细信息
[root@localhost ~]# ls -l /etc/yum.conf
-rw-r--r--. 1 root root 970 Aug 5 2017 /etc/yum.conf
[root@localhost ~]#
2.ls -la查看目录下所有文件 查看目录下包括隐藏文件
[root@localhost ~]# ls -la
total 28
dr-xr-x---. 2 root root 135 Mar 10 23:33 .
dr-xr-xr-x. 17 root root 224 Mar 11 2020 ..
-rw-------. 1 root root 1418 Mar 11 2020 anaconda-ks.cfg
-rw-------. 1 root root 381 Mar 11 01:40 .bash_history
-rw-r--r--. 1 root root 18 Dec 28 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 28 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 28 2013 .bashrc
-rw-r--r--. 1 root root 100 Dec 28 2013 .cshrc
-rw-r--r--. 1 root root 129 Dec 28 2013 .tcsh
3.ls -lh 查看目录下文件的大小 能够查看文件的大小
[root@localhost ~]# ls -lh
total 4.0K
-rw-------. 1 root root 1.4K Mar 11 2020 anaconda-ks.cfg
4.ls -ld 查看单个目录的属性 查看单个目录属性
[root@localhost ~]# ls -ld /etc/
drwxr-xr-x. 75 root root 8192 Mar 11 01:41 /etc/
[root@localhost ~]#
5.ls -li 查看文件的inode属性 查看文件的inode属性,类似于主键,唯一标识文件的id
[root@localhost ~]# ls -li
total 4
33574978 -rw-------. 1 root root 1418 Mar 11 2020 anaconda-ks.cfg
33574978 就是inode属性
6.ls -lS 以文件大小顺序排序
-S以文件大小顺序排序
[root@localhost ~]# ls -lS
总用量 28
-rw-r--r-- 1 root root 2113 3月 19 17:16 mima.txt
-rw-r--r--. 1 root root 1539 3月 13 17:35 initial-setup-ks.cfg
-rw-------. 1 root root 1491 3月 13 17:33 anaconda-ks.cfg
-rw-r--r-- 1 root root 158 3月 19 17:59 aa.txt
-rw-r--r-- 1 root root 146 3月 19 17:52 abc.txt
-rw-r--r-- 1 root root 139 3月 19 10:55 pho
-rw-r--r-- 1 root root 135 3月 20 10:23 cc.sh
drwxr-xr-x. 2 root root 6 3月 13 18:23 公共
drwxr-xr-x. 2 root root 6 3月 13 18:23 模板
drwxr-xr-x. 2 root root 6 3月 13 18:23 视频
drwxr-xr-x. 2 root root 6 3月 13 18:23 图片
drwxr-xr-x. 2 root root 6 3月 13 18:23 文档
drwxr-xr-x. 2 root root 6 3月 13 18:23 下载
drwxr-xr-x. 2 root root 6 3月 13 18:23 音乐
drwxr-xr-x. 2 root root 6 3月 13 18:23 桌面