ls命令

ls 命令 相关参数(需掌握):

-l    以长格式显示目录下的内容列表。输出的信息从左到右依次包括文件名,文件类型、权限模式、
      硬连接数、所有者、组、文件大小和文件的最后修改时间等;(与 ll 效果相似)
例如:
[root@centos7-02 ~]# ls -l
总用量 4
-rw-------. 1 root root 1418 5月  25 06:43 anaconda-ks.cfg
[root@centos7-02 ~]# ll
总用量 4
-rw-------. 1 root root 1418 5月  25 06:43 anaconda-ks.cfg
[root@centos7-02 ~]# 

-i    显示文件索引节点号(inode)。一个索引节点代表一个文件
例如:
[root@centos7-02 ~]# ls -i
33580642 anaconda-ks.cfg
[root@centos7-02 ~]# cd /
[root@centos7-02 /]# ls -i
  71 authorelabel  16777281 etc    50332068 media  33580641 root         1 sys
 120 bin           33581024 home         83 mnt        8142 run   16777288 tmp
  64 boot               124 lib    16777658 opt         125 sbin  33580988 usr
   3 dev                 82 lib64         1 proc   33581025 srv   50331713 var
[root@centos7-02 /]# ls -li
总用量 20
  71 -rw-r--r--.   1 root root    0 5月  25 03:42 authorelabel
 120 lrwxrwxrwx.   1 root root    7 5月  25 06:39 bin -> usr/bin
  64 dr-xr-xr-x.   5 root root 4096 5月  25 06:46 boot
   3 drwxr-xr-x.  19 root root 3180 5月  31 20:20 dev
16777281 drwxr-xr-x.  74 root root 8192 5月  31 20:25 etc
33581024 drwxr-xr-x.   2 root root    6 11月  5 2016 home
 124 lrwxrwxrwx.   1 root root    7 5月  25 06:39 lib -> usr/lib
  82 lrwxrwxrwx.   1 root root    9 5月  25 06:39 lib64 -> usr/lib64
50332068 drwxr-xr-x.   2 root root    6 11月  5 2016 media
  83 drwxr-xr-x.   2 root root    6 11月  5 2016 mnt
16777658 drwxr-xr-x.   2 root root    6 11月  5 2016 opt
   1 dr-xr-xr-x. 100 root root    0 5月  31 20:20 proc
33580641 dr-xr-x---.   3 root root  147 5月  25 02:48 root
8142 drwxr-xr-x.  23 root root  640 6月   1 23:58 run
 125 lrwxrwxrwx.   1 root root    8 5月  25 06:39 sbin -> usr/sbin
33581025 drwxr-xr-x.   2 root root    6 11月  5 2016 srv
   1 dr-xr-xr-x.  13 root root    0 5月  31 20:20 sys
16777288 drwxrwxrwt.  13 root root 4096 6月   1 23:58 tmp
33580988 drwxr-xr-x.  13 root root  155 5月  25 06:39 usr
50331713 drwxr-xr-x.  19 root root  267 5月  25 06:45 var
[root@centos7-02 /]#

-a    显示所有档案及目录(ls内定将档案名或目录名称为“.”的视为影藏,不会列出)
例如:
[root@centos7-02 ~]# ls -la
总用量 28
dr-xr-x---.  3 root root  147 5月  25 02:48 .
dr-xr-xr-x. 17 root root  244 5月  25 04:25 ..
-rw-------.  1 root root 1418 5月  25 06:43 anaconda-ks.cfg
-rw-------.  1 root root  687 5月  31 21:18 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
drwx------.  2 root root   29 5月  31 20:47 .ssh
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
[root@centos7-02 ~]# 

-t    用文件和目录的更改时间排序
例如:
[root@centos7-02 ~]# ls -lat
总用量 28
-rw-------.  1 root root  687 5月  31 21:18 .bash_history
drwx------.  2 root root   29 5月  31 20:47 .ssh
-rw-------.  1 root root 1418 5月  25 06:43 anaconda-ks.cfg
dr-xr-xr-x. 17 root root  244 5月  25 04:25 ..
dr-xr-x---.  3 root root  147 5月  25 02:48 .
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
[root@centos7-02 ~]#

-h    人性化显示容量信息。表示”–human-readable”,单位是k或者M ,比较容易看清楚结果
例如:
[root@centos7-02 ~]# ls -lath
总用量 28K
-rw-------.  1 root root  687 5月  31 21:18 .bash_history
drwx------.  2 root root   29 5月  31 20:47 .ssh
-rw-------.  1 root root 1.4K 5月  25 06:43 anaconda-ks.cfg
dr-xr-xr-x. 17 root root  244 5月  25 04:25 ..
dr-xr-x---.  3 root root  147 5月  25 02:48 .
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
[root@centos7-02 ~]#

-d    显示目录信息,而不显示目录下的文件信息
例如:
[root@centos7-02 /]# ls -d

. [root@centos7-02 /]# ls -ld dr-xr-xr-x. 17 root root 244 5月 25 04:25 .

ls命令参数(了解):

-A    不显示隐藏文件。(显示除"."和".."外的所有文件)
-b    print octal escapes for nongraphic characters(非显示字符进行转义打印);
       把文件名中不可输出的字符用反斜杠加字符编号的形式输出
-B    do not list implied entries ending with ~ 不显示以~结尾的文件.
-c    配合 -lt:根据 ctime排序及显示。 ctime (文件状态最后更改的时间)
-C    按列输出,纵向排序
-D    输出适合 Emacs 的 dired 模式使用的结果
-f     对输出的文件不进行排序, -lst等选项会失效
-F    附加文件类别,符号在文件名最后。/表明是一个目录;
        @表明是到其它文件的符号链接;* 表明是一个可执行文件
-g    类似参数-l,但是不列出所有者
-G    不列出任何有关组的信息
--si   类似参数h,但是文件大小去1000,而不是1024
-H    列出符号链接指示的真正的目的地
-k    以k 字节的形式表示文件的大小
-L    当显示符号链接的文件信息时,显示符号链接所指示的对象而并非符号链接本身的信息
-m    所有项目以逗号分隔,并填满整行行宽
-n    以数字显示文件和目录的UID和GID
-N    此选项将不限制文件长度
-o    显示文件出组信息以外的详细信息
-p    该ls命令选项可以在每个文件名后附上一个字符以说明该文件的类型,“*”表示可执行的普通文件;
        “/”表示目录;“@”表示符号链接;“|”表示FIFOs;“=”表示套接字(sockets)
-q    该选项可以用?代替不可输出的字符
-Q   该选项可以把输出的文件名用双引号括起来
-r     倒序方式显示文件和目录
-R    递归显示子目录
-s    以块大小为单位列出所有文件的大小
-S    以文件大小排序
-u    显示文件或目录最后被访问的时间
-U    不进行排序;依文件系统原有的次序列出项目
-v    根据版本进行排序
-w    自行指定屏幕宽度而不使用目前的数值
-x    逐行列出项目而不是逐栏列出
-X    根据扩展名排序
-1    每行只列一个文件

转载于:https://my.oschina.net/u/3866154/blog/1822907

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值