您的位置:首页 > 运维架构 > Linux

linux命令深度使用 – ls

2017-12-17 16:47 411 查看

1       linux命令深度使用 – ls

ls命令是linux系统中最被频繁使用的命令之一, 可查看目录或文件相关信息。

1.1不带任何参数

1.   # ls
2.   doc1 doc2 file1.txt file2.txt link1

 

1.2带参数 –l

1.   # ls -l
2.   drwxr-xr-x2 root root 80 Dec 17 13:49 doc1
3.   drwxr-xr-x2 root root 80 Dec 17 13:25 doc2
4.   -rw-r--r--1 root root 1315 Dec 17 13:48 file1.txt
5.   -rw-r--r--1 root root 1499 Dec 17 13:48 file2.txt
6.   lrwxrwxrwx1 root root 9 Dec 17 13:49 link1 -> file1.txt

 

1.3带参数 –lh

1.   # ls -lh
2.   drwxr-xr-x2 root root 80 Dec 17 13:49 doc1
3.   drwxr-xr-x2 root root 80 Dec 17 13:25 doc2
4.   -rw-r--r--1 root root 1.3K Dec 17 13:48 file1.txt
5.   -rw-r--r--1 root root 1.5K Dec 17 13:48 file2.txt
6.   lrwxrwxrwx1 root root 9 Dec 17 13:49 link1 -> file1.txt

按照便于人识别的格式显示,比如1K, 1M, 1G

1.4显示隐藏文件

1.   # ls -la
2.   drwxr-xr-x4 root root 160 Dec 17 13:51 .
3.   drwxrwxrwt12 root root 5540 Dec 17 14:10 ..
4.   -rw-r--r--1 root root 0 Dec 17 13:51 .tmp.log
5.   drwxr-xr-x2 root root 80 Dec 17 13:49 doc1
6.   drwxr-xr-x2 root root 80 Dec 17 13:25 doc2
7.   -rw-r--r--1 root root 1315 Dec 17 13:48 file1.txt
8.   -rw-r--r--1 root root 1499 Dec 17 13:48 file2.txt
9.   lrwxrwxrwx1 root root 9 Dec 17 13:49 link1 -> file1.txt

可以看出多显示了.tmp.log

 

1.5文件倒序排序

1.   # ls -r
2.   link1file2.txt file1.txt doc2 doc1

可以跟ls命令显示对比。

 

1.6目录后加/显示

1.   # ls -p
2.   doc1/ doc2/ file1.txt file2.txt link1

 

1.7非文件显示后缀

1.   # ls -F
2.   doc1/ doc2/ file1.txt file2.txt link1@

目录多出/ ,链接多出@

 

1.8递归显示子目录

1.   # ls -R
2.   .:
3.   doc1 doc2 file1.txt file2.txt link1
4.    
5.   ./doc1:
6.   file1.txt file2.txt
7.    
8.   ./doc2:
9.   file1 file2

1.9按大小排序

1.   # ls -S
2.   file2.txt file1.txt doc1 doc2 link1

 

1.10               修改时间倒序列出

1.   # ls -ltr
2.   drwxr-xr-x2 root root 80 Dec 17 13:25 doc2
3.   -rw-r--r--1 root root 1315 Dec 17 13:48 file1.txt
4.   -rw-r--r--1 root root 1499 Dec 17 13:48 file2.txt
5.   lrwxrwxrwx1 root root 9 Dec 17 13:49 link1 -> file1.txt
6.   drwxr-xr-x2 root root 80 Dec 17 13:49 doc1

 

1.11               显示UID和GID

1.   # ls -n
2.   drwxr-xr-x2 0 0 80 Dec 17 13:49 doc1
3.   drwxr-xr-x2 0 0 80 Dec 17 13:25 doc2
4.   -rw-r--r--1 0 0 1315 Dec 17 13:48 file1.txt
5.   -rw-r--r--1 0 0 1499 Dec 17 13:48 file2.txt
6.   lrwxrwxrwx1 0 0 9 Dec 17 13:49 link1 -> file1.txt

 

1.12               通用命令

ls --version

ls –help

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: