ls基本命令

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 桌面

六、文件详细信息解释

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

睡前来杯海飞丝

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值