显示目录内容列表,输出信息可以进行彩色加高亮显示,以分区不同类型的文件。
语法:
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 12drwxr-xr-x 2 root root 4096 Mar 19 14:23 dir1drwxr-xr-x 2 root root 4096 Mar 19 14:23 dir2[root@zsf test]# ll –h #以K,M,G来显示文件大小total 12Kdrwxr-xr-x 2 root root 4.0K Mar 19 14:23 dir1drwxr-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 fileDevice: fd00h/64768d Inode: 521236 Links: 1Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)Access: 2018-03-13 00:00:00.000000000 -0400Modify: 2018-03-12 00:00:00.000000000 -0400Change: 2018-03-19 14:47:13.681005838 -0400[root@zsf test]# stat file1 File: `file1' Size: 0 Blocks: 0 IO Block: 4096 regular empty fileDevice: fd00h/64768d Inode: 521234 Links: 1Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)Access: 2018-03-14 00:00:00.000000000 -0400Modify: 2018-03-11 00:00:00.000000000 -0500Change: 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执行,分别代表4211:代表被链接了几次root:属主root:属组0 :代表大小,单位bitsMar 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/ |
|---|