糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > Linux 基本命令(一)--ls 常用命令

Linux 基本命令(一)--ls 常用命令

时间:2019-02-19 01:10:18

相关推荐

Linux 基本命令(一)--ls 常用命令

-07-30

以下例举的是常用参数

ls

只显示文件、文件目录等名称,不显示其他信息。

[root@localhost opt]# lstest1 test11 test13 test15 test2 test4 test6 test8test10 test12 test14 test16 test3 test5 test7 test9

ls 目录 #显示某个目录内的文件、文件目录等名称

ls -a

查看当前目录所有文件(包含隐藏文件)

ls -a 目录 #某目录下的所有文件

[root@localhost var]# ls -a. adm crash empty gopher lib lock mail opt run tmp yp.. cache dbgames kerberos local log nis preserve spool .updated[root@localhost var]# ls -a /opt/test10/. .. 1 12 jkl

ls -l

(参数是字母L的小写) 用来查看详细的文件信息

ls -l 目录 #目录内所有文件的详细信息,不加目录默认是当前目录

[root@localhost opt]# ls -ltotal 0drwxr-xr-x. 3 root root 36 Jul 29 21:22 test10drwxr-xr-x. 2 root root 6 Jul 29 21:06 test12-rw-r--r--. 1 root root 0 Jul 29 21:05 test2-rw-r--r--. 1 root root 0 Jul 29 21:05 test4-rw-r--r--. 1 root root 0 Jul 29 21:05 test8-rw-r--r--. 1 root root 0 Jul 29 21:05 test9[root@localhost opt]# ls -l test10total 0-rw-r--r--. 1 root root 0 Jul 29 21:21 1-rw-r--r--. 1 root root 0 Jul 29 21:21 12drwxr-xr-x. 2 root root 6 Jul 29 21:22 jkl

第一个字符文件类型中:

d:目录文件

l:链接文件

b:块设备文件

c:字符设备文件

p:管道文件

-:表示普通文件

ls -S

按文件大-->小排序

ls -rS

按文件小-->大排序

(-S一般搭配 -l参数,即 -lS)

[root@localhost var]# ls -lStotal 8drwxr-xr-x. 24 root root 4096 May 12 23:15 libdrwxr-xr-x. 7 root root 4096 Jul 29 20:56 logdrwxr-xr-x. 8 root root 87 May 12 23:14 spooldrwxrwxrwt. 3 root root 85 Jul 29 21:03 tmpdrwxr-xr-x. 5 root root 44 May 12 23:14 cachedrwxr-xr-x. 3 root root 34 Jul 29 21:00 dbdrwxr-xr-x. 3 root root 18 May 12 23:14 emptydrwxr-xr-x. 3 root root 18 Jan 29 12:32 kerberoslrwxrwxrwx. 1 root root 11 May 12 23:11 lock -> ../run/locklrwxrwxrwx. 1 root root 10 May 12 23:11 mail -> spool/maildrwxr-xr-x. 2 root root 6 Apr 11 admdrwxr-xr-x. 2 root root 6 Apr 11 preservelrwxrwxrwx. 1 root root 6 May 12 23:11 run -> ../rundrwxr-xr-x. 2 root root 6 Apr 11 yp[root@localhost var]# ls -lrStotal 8drwxr-xr-x. 2 root root 6 Apr 11 yplrwxrwxrwx. 1 root root 6 May 12 23:11 run -> ../rundrwxr-xr-x. 2 root root 6 Apr 11 preservedrwxr-xr-x. 2 root root 6 Apr 11 admlrwxrwxrwx. 1 root root 10 May 12 23:11 mail -> spool/maillrwxrwxrwx. 1 root root 11 May 12 23:11 lock -> ../run/lockdrwxr-xr-x. 3 root root 18 Jan 29 12:32 kerberosdrwxr-xr-x. 3 root root 18 May 12 23:14 emptydrwxr-xr-x. 3 root root 34 Jul 29 21:00 dbdrwxr-xr-x. 5 root root 44 May 12 23:14 cachedrwxrwxrwt. 3 root root 85 Jul 29 21:03 tmpdrwxr-xr-x. 8 root root 87 May 12 23:14 spooldrwxr-xr-x. 7 root root 4096 Jul 29 20:56 logdrwxr-xr-x. 24 root root 4096 May 12 23:15 lib

ls -t

按时间近-->远排序

ls -tr

按时间远-->近排序

(一般与参数-l同时使用)

[root@localhost var]# ls -lttotal 8drwxrwxrwt. 3 root root 85 Jul 29 21:03 tmpdrwxr-xr-x. 3 root root 34 Jul 29 21:00 dbdrwxr-xr-x. 7 root root 4096 Jul 29 20:56 logdrwxr-xr-x. 24 root root 4096 May 12 23:15 libdrwxr-xr-x. 8 root root 87 May 12 23:14 spooldrwxr-xr-x. 3 root root 18 May 12 23:14 emptydrwxr-xr-x. 5 root root 44 May 12 23:14 cachelrwxrwxrwx. 1 root root 10 May 12 23:11 mail -> spool/maillrwxrwxrwx. 1 root root 11 May 12 23:11 lock -> ../run/locklrwxrwxrwx. 1 root root 6 May 12 23:11 run -> ../rundrwxr-xr-x. 2 root root 6 Apr 24 10:03 crashdrwxr-xr-x. 3 root root 18 Jan 29 12:32 kerberosdrwxr-xr-x. 2 root root 6 Apr 11 admdrwxr-xr-x. 2 root root 6 Apr 11 gamesdrwxr-xr-x. 2 root root 6 Apr 11 gopherdrwxr-xr-x. 2 root root 6 Apr 11 localdrwxr-xr-x. 2 root root 6 Apr 11 nisdrwxr-xr-x. 2 root root 6 Apr 11 optdrwxr-xr-x. 2 root root 6 Apr 11 preservedrwxr-xr-x. 2 root root 6 Apr 11 yp[root@localhost var]# ls -ltrtotal 8drwxr-xr-x. 2 root root 6 Apr 11 ypdrwxr-xr-x. 2 root root 6 Apr 11 preservedrwxr-xr-x. 2 root root 6 Apr 11 optdrwxr-xr-x. 2 root root 6 Apr 11 nisdrwxr-xr-x. 2 root root 6 Apr 11 localdrwxr-xr-x. 2 root root 6 Apr 11 gopherdrwxr-xr-x. 2 root root 6 Apr 11 gamesdrwxr-xr-x. 2 root root 6 Apr 11 admdrwxr-xr-x. 3 root root 18 Jan 29 12:32 kerberosdrwxr-xr-x. 2 root root 6 Apr 24 10:03 crashlrwxrwxrwx. 1 root root 6 May 12 23:11 run -> ../runlrwxrwxrwx. 1 root root 11 May 12 23:11 lock -> ../run/locklrwxrwxrwx. 1 root root 10 May 12 23:11 mail -> spool/maildrwxr-xr-x. 5 root root 44 May 12 23:14 cachedrwxr-xr-x. 3 root root 18 May 12 23:14 emptydrwxr-xr-x. 8 root root 87 May 12 23:14 spooldrwxr-xr-x. 24 root root 4096 May 12 23:15 libdrwxr-xr-x. 7 root root 4096 Jul 29 20:56 logdrwxr-xr-x. 3 root root 34 Jul 29 21:00 dbdrwxrwxrwt. 3 root root 85 Jul 29 21:03 tmp

ls -h

超过1000字节的文件以K为单位显示,一般-l同时使用

[root@localhost var]# ls -lhtotal 8.0Kdrwxr-xr-x. 2 root root 6 Apr 11 admdrwxr-xr-x. 5 root root 44 May 12 23:14 cachedrwxr-xr-x. 2 root root 6 Apr 24 10:03 crashdrwxr-xr-x. 3 root root 34 Jul 29 21:00 dbdrwxr-xr-x. 3 root root 18 May 12 23:14 emptydrwxr-xr-x. 2 root root 6 Apr 11 gamesdrwxr-xr-x. 2 root root 6 Apr 11 gopherdrwxr-xr-x. 3 root root 18 Jan 29 12:32 kerberosdrwxr-xr-x. 24 root root 4.0K May 12 23:15 libdrwxr-xr-x. 2 root root 6 Apr 11 locallrwxrwxrwx. 1 root root 11 May 12 23:11 lock -> ../run/lockdrwxr-xr-x. 7 root root 4.0K Jul 29 20:56 loglrwxrwxrwx. 1 root root 10 May 12 23:11 mail -> spool/maildrwxr-xr-x. 2 root root 6 Apr 11 nisdrwxr-xr-x. 2 root root 6 Apr 11 optdrwxr-xr-x. 2 root root 6 Apr 11 preservelrwxrwxrwx. 1 root root 6 May 12 23:11 run -> ../rundrwxr-xr-x. 8 root root 87 May 12 23:14 spooldrwxrwxrwt. 3 root root 85 Jul 29 21:03 tmpdrwxr-xr-x. 2 root root 6 Apr 11 yp

如果觉得《Linux 基本命令(一)--ls 常用命令》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。