码迷,mamicode.com
首页 > 系统相关 > 详细

Linux ls命令

时间:2018-03-20 21:41:52      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:linux   ls   按照时间排序   ll   

Ls

显示目录内容列表,输出信息可以进行彩色加高亮显示,以分区不同类型的文件。

语法:

         touch [选项] [参数]

选项

解释

例子

-a--all

显示所有文件,包括以“.”开头的隐藏文件

ls –a / 显示根下面的所有文件

-l

长格式显示

Ls –l 显示文件属性

-h

1024位进制的显示文件大小


-d

显示当前目录

Ls –d /tmp

-t

按照修改时间排序,默认从近到远

Ls –t /

-r

倒序,经常配合-t使用

Ls –tr /

-c

配合-lt 根据ctime(文件的访问时间ACCESS


-G

不列出任何有关组的信息


-F

给目录加标识

(不同的文件加不同的标识)

-p

给目录加标识

只给目录加/




实例:

[root@zsf test]# ls –a   #显示所有,包括隐藏文件

.    ..  dir1  dir2    dir3  file1  file2    file3

[root@zsf test]# ls -l /ll   #长格式显示

total 12

drwxr-xr-x 2 root root 4096 Mar 19 14:23   dir1

drwxr-xr-x 2 root root 4096 Mar 19 14:23   dir2

[root@zsf test]# ll –h   #KMG来显示文件大小

total 12K

drwxr-xr-x 2 root root 4.0K Mar 19 14:23   dir1

drwxr-xr-x 2 root root 4.0K Mar 19 14:23   dir2

 [root@zsf test]# touch -m file1   -d "20180311"     #修改更改时间

[root@zsf test]# touch -m file2 -d "20180312"     #修改更改时间

[root@zsf test]# ll –t   #按照修改时间来排序,由近到远,默认是按照修改时间

total 0

-rw-r--r-- 1 root root 0 Mar 12 00:00   file2

-rw-r--r-- 1 root root 0 Mar 11 00:00   file1

[root@zsf test]# ll –tr  #-r倒序,一般配个-t使用

total 0

-rw-r--r-- 1 root root 0 Mar 11 00:00   file1

-rw-r--r-- 1 root root 0 Mar 12 00:00   file2

 

[root@zsf test]# ll -d /test/    #只显示当前文件或目录的属性

drwxr-xr-x 6 root root 4096 Mar 19 14:42   /test/

[root@zsf test]# touch -a file2 -d "20180313"    #修改访问时间

[root@zsf test]# touch -a file1 -d "20180314"    #修改访问时间

[root@zsf test]# ll -tc    #按照文件的访问时间来排序

total 0

-rw-r--r-- 1 root root 0 Mar 19 14:47   file1

-rw-r--r-- 1 root root 0 Mar 19 14:47   file2

[root@zsf test]# stat file2  查看状态

    File: `file2'

    Size: 0               Blocks:   0          IO Block: 4096   regular empty file

Device: fd00h/64768d    Inode: 521236      Links: 1

Access: (0644/-rw-r--r--)  Uid: (      0/    root)   Gid: (      0/    root)

Access: 2018-03-13 00:00:00.000000000 -0400

Modify: 2018-03-12 00:00:00.000000000   -0400

Change: 2018-03-19 14:47:13.681005838   -0400

[root@zsf test]# stat file1

    File: `file1'

    Size: 0               Blocks:   0          IO Block: 4096   regular empty file

Device: fd00h/64768d    Inode: 521234      Links: 1

Access: (0644/-rw-r--r--)  Uid: (      0/    root)   Gid: (      0/    root)

Access: 2018-03-14 00:00:00.000000000 -0400

Modify: 2018-03-11 00:00:00.000000000   -0500

Change: 2018-03-19 14:47:19.547994463   -0400

[root@zsf test]# ll -d /test/    #只显示当前这个目录的属性

drwxr-xr-x 6 root root 4096 Mar 19 14:42   /test/

[root@zsf test]# ll -Gd /test/   #不显示属组的信息

drwxr-xr-x 6 root 4096 Mar 19 14:42   /test/

长格式显示说明:

-rw-r—r--. 1 root root 0 Mar 12 16:18   1.sh

第一位:代表这个文件的类型,-代表文件、d代表目录,l代表链接文件,

后面9位:每3位分别代表,属主,属组,其他人的权限,r读,w写,x执行,分别代表421

1:代表被链接了几次

root:属主

root:属组

0 :代表大小,单位bits

Mar 12 16:18 代表最后修改的时间

[root@zsf test]#ls --color=auto  #带颜色显示

[root@zsf test]# ls -F          #给目录后面加上标识(不同的文件可能加的不一样)

dir1/    dir2/  dir3/  file    file1  file2  file3    test/

[root@zsf test]# ls –p     #只给目录加上“/

dir1/    dir2/  dir3/  file    file1  file2  file3    test/


Linux ls命令

标签:linux   ls   按照时间排序   ll   

原文地址:http://blog.51cto.com/13447608/2089162

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!