A day of school a Linux command: ls first day

Article Updated: 2020-03-02
Note: This article referring to man ls manual, use and give examples.

First, the commandls

1, the name and description

ls -列出目录内容

lsThe main program is listed in the file or directory information.
If you do not specify parameters, which is executed only ls, lists the current default directory information without recursion, does not appear in .the beginning of the hidden files.

2, syntax

ls [选项]... [文件或目录]...

3, example output

The execution ls -lwill see something like the following output, their meanings in FIG.
Figure zero

4, parameters

Lists information about a file (default is the current directory), if you do not specify -cftuvSUVor --sortwhen the parameters are arranged in alphabetical order.
When calling parameters, using the long form and short form is legal.

Short format Long format description
-a - -all Lists all files, including the start with a point
-A - -almost-all Lists all files, not including to the point of beginning
- -author And -lwith the use of lists each file
-b - -escape Octal overflow sequence represents a non-printable characters
- -block-size=SIZE Displays the specified file size
-B - -ignore-backups Not listed at ~the end of the backup file
-c With the -ltdisplay and to ctimearrange;
with the -lshow ctimeand also the file names are listed;
otherwise, to ctimeorder, newest first row
-C Press column shows the file (alone and lsone effect)
- -color[=WHEN] Shading result; WHENalternatively never, auto, always(default)
-d - -directory If it is a directory, the directory lists the information itself, rather than their content q
-D - dired Generated as a Emacsdesign diredmodel output
-f Do not sort, equivalent to calling -aU, disabled-ls --color
-F - -classify Add categories indicator for each file, */=>@!in a
- -file-type Above, but do not add*
- -format=WORD Output display formats, WORDalternatively verbose, long, commas, horizontal, across, vertical, single-column,context
- -full-time Equivalent to -l --time-style=full-iso
-g Equivalent to -l, but does not list the file's owner
- - group-directories-first Before all the files in the output directory
-G - - no-group Equivalent to -l, but does not list the name of the group file
-h - -human-readable With -luse, the output like 1k,23M,2Gthis friendly file size unit
- -and Above, but using 1000hexadecimal instead of 1024decimal
-H - -dereference-command-line Locations listed real symbol file
- -dereference-command-line-symlink-to-dir Directory lists the symbols of the real position (doubtful)
- -hide=PATTERN Do not list PATTERNthe matched files
- -indicator-style=WORD Add an indicator, optional none(default), slash(-p), file-type(- -file-type),classify(-F)
-i - - inode Digital output index for each file
-I - -ignore=PATTERN Do not list patternthe matched item
-k - -kibibytes The default order K 字节represented in the form of file size
-l Using the long form output information
-L - -dereference Showing symbolic link references a file, instead of linking their own information
-m Comma-separated items
-n - -numeric-uid-gid Equivalent -l, but the display 用户idand组id
-N - -literal Shows the original entry name, not special treatment (such as control characters)
-p - -indcator-style=slash Add in the directory name/
-q - -hide-control-chars The non-graphic characters appear as?
- -show-control-chars Non-graphical display character, is what to show
-Q - -quote-name Use double quotes project name
- -quoting-style=WORD word可选 literal, locale, shell, shell-always, c, escape
-r - -reverse 如果排序则反向排
-R - -recursive 递归显示子目录内容
-s - -size 输出文件已分配的块大小
-S 以文件大小排列
- -sort=WORD 根据none(-U)size(-S)time(-t)version(-v)extension(-X)排列项
- -time=WORD 配合-l使用,展示访问时间 atime-u,状态时间 ctime-c,而不是默认的修改时间 mtime,
当然也可以指定以时间排序 --sort=time
- -time-style=STYLE 配合-l使用,展示full-isolong-isoisolocale,或者+FORMAT,…
-t 以修改时间 mtime 排列,最新的放第一
-T - -tabsize=COLS 指定tab值来代指默认值 8
-u 配合 -lt使用,展示并以 atime 排列;配合 -l使用,展示 atime,以文件名排列;否则,以 atime 排列
-U 不排列,按目录顺序列出条目
-v 文本中自然的(版本)数字排序
-w - -widdth=COLS 手动指定屏幕宽度
-x 以行为单位列出而非以列
-X 以文件扩展名的字母顺序排列
-1 按每个一行排列

SELinux 参数:

短格式 长格式 描述
- -lcontext 显示安全内容
-Z - -context
- -scontext 仅显示安全信息和文件名
- -help 显示帮助信息
- -version 显示版本信息

二、命令实践

1、ls -als --all

注:列出所有文件,包括 ...
Figure I

2、ls -Als --almost-all

注:列出所有文件,但不包括 ...

Figure II

3、ls --author

注1:配合 -l 使用列出文件的作者。
注2:有时候文件的作者和所有者是不一样的。

Figure III

4、ls -bls --escape

Figure IV

5、ls --block-size=M

Figure V

6、ls -Bls --ignore-backups

Figure VI

7、ls -c

补充:

ls -l
内容更改时间:modification time(mtime) 指文件内容发生改变的时间;
ls -l --time=ctime
状态更改时间:status time(ctime) 指文件的权限或属性发生改变的时间;
ls -l --time=atime
最近访问时间:access time(atime) 指文件最近被读取的时间;

Figure VII

8、ls -C

Figure VIII

9、ls --color[=WHEN]

Figure IX

10、ls -d

Figure X

11、ls -Dls --dired

11

12、ls -f

12

13、ls -Fls --classify

补充:
普通文件:没有
普通可执行文件:*
目录:/
符号链接:@
FIFOs管道文件:|
套接字文件:=
doors:>

13

14、ls --full-time

14

15、ls -hls --human-readable

15

16、ls --hide=PATTERN

16

17、ls -l

17

18、ls -t

补充综合:
下表中的等价于列中的ctime可用status替换,atime可用accessuse替换。

命令 显示内容 排列顺序 等价于
ls -l 显示mtime 以文件名排列
ls -lt 显示mtime mtime排列
ls -c 不显示ctime ctime排列 ls --time=ctime
ls -cl 显示ctime 以文件名排列 ls -l --time=ctime
ls -clt 显示ctime ctime排列 ls -lt --time=ctime
ls -u 不显示atime atime排列 ls --time=atime
ls -ul 显示atime 以文件名排列 ls -l --time=atime
ls -ult 显示atime atime排列 ls -lt --time=atime

使用样例
18

19、ls --sort=WORD

WORD 可选nonetimesizeextensionversion

19

三、Enjoy!

Published 75 original articles · won praise 8 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_21516633/article/details/104587879