Article Updated: 2020-03-02
Note: This article referring to man ls manual, use and give examples.
Article Directory
- First, the command of `ls`
- Second, the practice of command
- 1, `ls -a` or` ls --all`
- 2、`ls -A` 或 `ls --almost-all`
- 3、`ls --author`
- 4, `ls -b` or` ls --escape`
- 5、`ls --block-size=M`
- 6, `ls -B` or` ls --ignore-backups`
- 7、`ls -c`
- 8、`ls -C`
- 9、`ls --color[=WHEN]`
- 10 `ls -d`
- 11, `ls -D` or` ls --dired`
- 12、`ls -f`
- 13、`ls -F` 或 `ls --classify`
- 14、`ls --full-time`
- 15、`ls -h` 或 `ls --human-readable`
- 16、`ls --hide=PATTERN`
- 17 `ls -l`
- 18 `ls -t`
- 19、`ls --sort=WORD`
- 三、Enjoy!
First, the commandls
1, the name and description
ls -列出目录内容
ls
The 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 -l
will see something like the following output, their meanings in FIG.
4, parameters
Lists information about a file (default is the current directory), if you do not specify -cftuvSUV
or --sort
when 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 -l with 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 -lt display and to ctime arrange; with the -l show ctime and also the file names are listed; otherwise, to ctime order, newest first row |
|
-C | Press column shows the file (alone and ls one effect) |
|
- -color[=WHEN ] |
Shading result; WHEN alternatively 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 Emacs design dired model 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, WORD alternatively 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 -l use, the output like 1k,23M,2G this friendly file size unit |
- -and | Above, but using 1000 hexadecimal instead of 1024 decimal |
|
-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 PATTERN the 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 pattern the 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 用户id and组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-iso 、long-iso 、iso 、locale ,或者+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 -a
或 ls --all
注:列出所有文件,包括 .
和 ..
2、ls -A
或 ls --almost-all
注:列出所有文件,但不包括 .
和 ..
3、ls --author
注1:配合 -l
使用列出文件的作者。
注2:有时候文件的作者和所有者是不一样的。
4、ls -b
或 ls --escape
5、ls --block-size=M
6、ls -B
或 ls --ignore-backups
7、ls -c
补充:
ls -l
内容更改时间:modification time(mtime) 指文件内容发生改变的时间;
ls -l --time=ctime
状态更改时间:status time(ctime) 指文件的权限或属性发生改变的时间;
ls -l --time=atime
最近访问时间:access time(atime) 指文件最近被读取的时间;
8、ls -C
9、ls --color[=WHEN]
10、ls -d
11、ls -D
或 ls --dired
12、ls -f
13、ls -F
或 ls --classify
补充:
普通文件:没有
普通可执行文件:*
目录:/
符号链接:@
FIFOs管道文件:|
套接字文件:=
doors:>
14、ls --full-time
15、ls -h
或 ls --human-readable
16、ls --hide=PATTERN
17、ls -l
18、ls -t
补充综合:
下表中的等价于
列中的ctime
可用status
替换,atime
可用access
或use
替换。
命令 | 显示内容 | 排列顺序 | 等价于 |
---|---|---|---|
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 |
使用样例
19、ls --sort=WORD
WORD
可选none
、time
、size
、extension
、version