Linux 基础命令 -- ls

命令介绍

命令:ls 列出有关文件的信息(默认情况下为当前目录)

用法: ls [OPTION]… [FILE]… ls 选项 目录

在这里插入图片描述

命令选项

[root@fp-21 script]# ls --help

  -a, --all                  # 显示所有文件,包括( .  .. 
  -A					     # 显示所有文件,不包括( .  .. 
  -c                         # 显示 ctime(最后一次文件状态信息的修改)
  --color                    # 显示颜色
  -d, --directory            # 查看目录的本身属性
  -F 					     # 对不同类型的文件加上不同类型的标识符
  -g                         # 同-l,但是不显示所有者
  -G, --no-group             # 同-l,但是不显示所属组
  -h, --human-readable       # 以单位形式显示文件大小,常见的有(K、M、G)
  -i, --inode                # inode索引节点编号,唯一性
  -k, --kibibytes            # 磁盘使用默认为1024字节块
  -l                         # 长格式显示,即显示属性等信息
  -m                         # 以逗号分隔各文件
  -n, --numeric-uid-gid      # 类似于-l,但列出数字用户和组ID
  -o                         # 同-G
  -r, --reverse              # 排序是倒序
  -R, --recursive            # 递归列出子目录
  -s, --size                 # 为单位打印每个文件的分配大小
  -S                         # 按文件大小排序,默认降序排序
  -t                         # 将文件依建立时间之先后次序列出
  -u                         # utime 按照访问时间排序
  -U                         # 不排序,安装目录顺序列出
  -v                         # 根据版本进行排序
  -X                         # 扩展名排序 
  --help     			     # 帮助文档
  --version  			     # 版本信息

命令实例

# 显示所有文件,包括( . 和 .. )
[root@fp-21 script]# ll -a
drwxr-xr-x. 2 root root 18 Feb 20 21:58 .
drwxr-xr-x. 4 root root 29 Feb 20 22:17 ..
-rwxr-xr-x. 1 root root 14 Feb 20 21:58 a.sh

# 显示所有文件,不包括( . 和 .. )
[root@fp-21 script]# ll -A
-rwxr-xr-x. 1 root root 14 Feb 20 21:58 a.sh

# 查看目录的本身属性
[root@fp-21 script]# ll -d
drwxr-xr-x. 2 root root 18 Feb 20 21:58 .

# 对不同类型的文件加上不同类型的标识符
[root@fp-21 opt]# ll -F
drwxr-xr-x. 3 root root 15 Feb 20 22:17 a/
drwxr-xr-x. 2 root root 18 Feb 20 21:58 script/

# 同-l,但是不显示所有者
[root@fp-21 opt]# chown tom:jack script
[root@fp-21 opt]# ll -g
drwxr-xr-x. 2 jack 18 Feb 20 21:58 script

# 同-l,但是不显示所属组
[root@fp-21 opt]# chown tom:jack script
[root@fp-21 opt]# ll -G
drwxr-xr-x. 2 tom 18 Feb 20 21:58 script

# inode索引节点编号,唯一性
[root@fp-21 opt]# ll -i
     879 drwxr-xr-x. 3 bin root 15 Feb 20 22:17 a
51211757 drwxr-xr-x. 2 tom jack 30 Feb 21 12:19 script

# 长格式显示,即显示属性等信息
[root@fp-21 opt]# ll
drwxr-xr-x. 2 tom jack 30 Feb 21 12:19 script

# 以逗号分隔各文件
[root@fp-21 opt]# ls -m
a, script

# 类似于-l,但列出数字用户和组ID
[root@fp-21 opt]# ll -n
drwxr-xr-x. 2 1000 1001 30 Feb 21 12:19 script

# 递归列出子目录
[root@fp-21 opt]# ls -R
.:
a  script

./a:
a

./a/a:

./script:
a.sh  test

# 为单位打印每个文件的分配大小
[root@fp-21 script]# ll -s
4 -rwxr-xr-x. 1 root root  80 Feb 21 12:18 a.sh
4 -rw-r--r--. 1 root root 141 Feb 21 12:19 test

# 按文件大小排序,默认降序排序
[root@fp-21 script]# ll -S
-rw-r--r--. 1 root root 48894 Feb 21 12:36 test4
-rw-r--r--. 1 root root 28893 Feb 21 12:36 test6
-rw-r--r--. 1 root root 26893 Feb 21 12:36 test10
-rw-r--r--. 1 root root 23893 Feb 21 12:36 test8
-rwxr-xr-x. 1 root root  4042 Feb 21 12:34 a.sh
-rw-r--r--. 1 root root  3893 Feb 21 12:35 test2
-rw-r--r--. 1 root root   141 Feb 21 12:19 test
-rw-r--r--. 1 root root     0 Feb 21 12:35 test1
-rw-r--r--. 1 root root     0 Feb 21 12:35 test3
-rw-r--r--. 1 root root     0 Feb 21 12:35 test5
-rw-r--r--. 1 root root     0 Feb 21 12:35 test7
-rw-r--r--. 1 root root     0 Feb 21 12:35 test9

# 将文件依建立时间之先后次序列出
[root@fp-21 script]# ll -t
-rw-r--r--. 1 root root 26893 Feb 21 12:36 test10
-rw-r--r--. 1 root root 23893 Feb 21 12:36 test8
-rw-r--r--. 1 root root 28893 Feb 21 12:36 test6
-rw-r--r--. 1 root root 48894 Feb 21 12:36 test4
-rw-r--r--. 1 root root  3893 Feb 21 12:35 test2
-rw-r--r--. 1 root root     0 Feb 21 12:35 test5
-rw-r--r--. 1 root root     0 Feb 21 12:35 test7
-rw-r--r--. 1 root root     0 Feb 21 12:35 test9
-rw-r--r--. 1 root root     0 Feb 21 12:35 test1
-rw-r--r--. 1 root root     0 Feb 21 12:35 test3
-rwxr-xr-x. 1 root root  4042 Feb 21 12:34 a.sh
-rw-r--r--. 1 root root   141 Feb 21 12:19 test

link 查看 Linux 基础命令

只有注入思想的博客才是好的博客

发布了33 篇原创文章 · 获赞 145 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/xtlhxl/article/details/104425213