ls命令

命令名称
  ls - 列出目录内容

ls命令语法
  ls [OPTION]... [FILE]...

ls命令描述
  列出文件信息(默认是当前目录),以字母顺序排序(如果使用没有任何 -cftuvSUX 或 --sort选项)

ls命令常用选项

  作为linux下最常用的命令,ls的常用选项也很多。

选项描述
-a, --all列出所有的项,包括以.开头的文件或目录。
-A, --almost-all列出除了.和..以外的所有项
--author和-l选项一起使用,列出文件的作者
-c和-lt选项一起使用,按ctime(最后更改文件状态信息时间)排序
 -d, --directory只列出目录
-l按详情格式显示,各字段意思请看实例。
-r, --reverse排序的时候使用倒序
 -R, --recursive列出子目录
 -S按文件大小排序
-t按修改时间(mtime)排序
 -u与-lt选项一起使用,按访问时间(atime)排序
 -U不做任何排序
 -1字母1,一行只列出一个文件

ls命令实例

  下面实例演示ls的各种常见用法。

[root@shellcn.net test#] ls
1.txt  5.txt  a.log  mysql.sh
######列出详情,七个列依次是
######权限,硬链接数或目录的子目录数,所有者,所属用户组,文件大小byte,mtime(修改时间,最后一次写文件内容时间),文件名
[root@shellcn.net test#] ls -l
total 8
-rw-r--r--. 1 root root   0 Oct  7 05:54 1.txt
-rw-r--r--. 1 root root 843 Apr 18 19:55 5.txt
-rw-r--r--. 1 root root   0 Oct  7 05:55 a.log
-rwxr--r--. 1 root root  10 Apr 16 19:26 mysql.sh
######显示所有文件,包括..和.
[root@shellcn.net test#] ls -al
total 16
drwxr-xr-x. 2 root root 4096 Oct  7 05:56 .
dr-xr-x---. 3 root root 4096 Oct  7 05:56 ..
-rw-r--r--. 1 root root    0 Oct  7 05:54 1.txt
-rw-r--r--. 1 root root  843 Apr 18 19:55 5.txt
-rw-r--r--. 1 root root    0 Oct  7 05:55 a.log
-rwxr--r--. 1 root root   10 Apr 16 19:26 mysql.sh
######按大小排序
[root@shellcn.net test#] ls -Sl
total 8
-rw-r--r--. 1 root root 843 Apr 18 19:55 5.txt
-rwxr--r--. 1 root root  10 Apr 16 19:26 mysql.sh
-rw-r--r--. 1 root root   0 Oct  7 05:54 1.txt
-rw-r--r--. 1 root root   0 Oct  7 05:55 a.log
######按mtime排序
[root@shellcn.net test#] ls -tl
total 8
-rw-r--r--. 1 root root   0 Oct  7 05:55 a.log
-rw-r--r--. 1 root root   0 Oct  7 05:54 1.txt
-rw-r--r--. 1 root root 843 Apr 18 19:55 5.txt
-rwxr--r--. 1 root root  10 Apr 16 19:26 mysql.sh
######按ctime排序
[root@shellcn.net test#] ls -lct
total 8
-rwxr--r--. 1 root root  10 Oct  7 05:56 mysql.sh
-rw-r--r--. 1 root root 843 Oct  7 05:55 5.txt
-rw-r--r--. 1 root root   0 Oct  7 05:55 a.log
-rw-r--r--. 1 root root   0 Oct  7 05:54 1.txt
######按atime排序
[root@shellcn.net test#] ls -ltu
total 8
-rw-r--r--. 1 root root   0 Oct  7 05:55 a.log
-rw-r--r--. 1 root root   0 Oct  7 05:54 1.txt
-rwxr--r--. 1 root root  10 Apr 18 22:55 mysql.sh
-rw-r--r--. 1 root root 843 Apr 18 19:56 5.txt

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值