[test@bogon ~]$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
文件(默认为当前的工作目录)信息列表
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
如果没有指定任何一个-cftuvSUX或-排序,那么按照排序条目的排序
Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
不忽略当前目录标识.的文件和文件夹(linux下文件隐藏文件是以.开头的,如果存在..代表存在着父目录)
-A, --almost-all do not list implied . and ..
显示所有文件(隐藏文件)但是不展示.和.. linux下文件.为当前目录,存在..代表存在着父目录)
--author with -l, print the author of each file
使用-l : 打印每个文件的author
-b, --escape print C-style escapes for nongraphic characters
为非图形字符打印c样式转义,把文件名中不可输出的字符用反斜杠加字符编号
--block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'--block-size=M' prints sizes in units of
1,048,576 bytes; see SIZE format below
打印前合计当前文件的大小 ls -l --block-size=M
-B, --ignore-backups do not list implied entries ending with ~
忽略备份 不要列出以结束为结尾的隐含条目
-c with -lt: sort by, and show, ctime (time of last
modification of file status information);
with -l: show ctime and sort by name;
otherwise: sort by ctime, newest first
使用 -ltc 根据文件状态信息中的最近修改时间来排序并显示, 使用-l 显示ctime和name排序,另外 ctime排序 更改时间的文件最新的第一
-C list entries by columns
--color[=WHEN] colorize the output; WHEN can be 'never', 'auto',
or 'always' (the default); more info below
彩色化输出 --color=when 'never', 'auto', or 'always' (the default);
-d, --directory list directories themselves, not their contents
列出目录本身,而不是它们的内容
-D, --dired generate output designed for Emacs' dired mode
生成为Emacs的dired模式设计的输出
-f do not sort, enable -aU, disable -ls --color
不排序 具有ls -aU功能 打印无颜色 ls -aU --color=never
-F, --classify append indicator (one of */=>@|) to entries
在每个文件名后附上一个字符以说明该文件的类型,“*”表示可执行的普通文件;“/”表示目 录;“@”表示符号链接;“|”表示FIFOs;“=”表示套接字(sockets)
--file-type likewise, except do not append '*' 文件类型: 除*
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
利用关键词来完成ls的输出模式,这些关键词也可以利用其他选项来完成,可用的关键词有(括号内为替代选 项):across(-x),commas(-m),horizontal(-x),long(-l),single-column(-l),vertical(-C).
--full-time like -l --time-style=full-iso 完整时间格式 非简约时间格式
-g like -l, but do not list owner 功能雷同 -l 但是不列出所有人
--group-directories-first
group directories before files; 显示组名于文件名前
can be augmented with a --sort option, but any
use of --sort=none (-U) disables grouping
可以使用参数a --sort arguments are: -none - time - size - extension - version是使用 --sort=none 不以组进行排序
-G, --no-group in a long listing, don't print group names -lG 不打印组信息
-h, --human-readable with -l, print sizes in human readable format 使用-l 打印可读格式的文件大小
(e.g., 1K 234M 2G)
--si likewise, but use powers of 1000 not 1024
--si 以1000取代1024作为统计单位,例如,1024bytes会被显示为1.024KB
-H, --dereference-command-line
follow symbolic links listed on the command line 执行命令行上列出的符号链接 ??
https://superuser.com/questions/593196/cp-h-vs-cp-l-what-is-a-command-line-symbolic-link
--dereference-command-line-symlink-to-dir 使用命令列中的符号链接指示的真正目的地
follow each command line symbolic link
that points to a directory
--hide=PATTERN do not list implied entries matching shell PATTERN 与-a-A一起使用,则会被-a或者-A覆盖
(overridden by -a or -A)
--indicator-style=WORD append indicator with style WORD to entry names:
none (default), slash (-p),
file-type (--file-type), classify (-F)
指定在每个项目名称后加上指示符号<方式>:none (默认),classify (-F),file-type (-p)
-i, --inode print the index number of each file 打印文件索引号
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN 不匹配隐含条目shell模式列表
[root@bogon ~]# ls -I Desktop
anaconda-ks.cfg Documents initial-setup-ks.cfg Music Pictures Templates
dnspod-sr Downloads mike
-k, --kibibytes default to 1024-byte blocks for disk usage 磁盘默认使用1024字节块
-l use a long listing format 使用长格式清单
-L, --dereference when showing file information for a symbolic 当显示文件信息为动态链接,显示文件的链接的信息而不是文件本身
link, show information for the file the link
references rather than for the link itself ?????
-m fill width with a comma separated list of entries 列表条目之间使用逗号间隔
[root@bogon ~]# ls -m
anaconda-ks.cfg, Desktop, dnspod-sr, Documents, Downloads, initial-setup-ks.cfg, mike, Music, opencms_init.log, Pictures,
Public, Templates, Videos
-n, --numeric-uid-gid like -l, but list numeric user and group IDs 类似参数l, 但是user&group 显示的他们的IDs
[root@bogon ~]# ls -n
total 8
-rw-------. 1 0 0 1827 Jun 19 2017 anaconda-ks.cfg
drwxr-xr-x. 2 0 0 6 Jun 19 2017 Desktop
drwxr-xr-x. 7 0 0 215 Aug 16 22:21 dnspod-sr
-N, --literal print raw entry names (don't treat e.g. control characters specially)打印原始条目名称(不要特别处理控制字符)
-o like -l, but do not list group information 类似参数l,但是列表无组信息
-p, --indicator-style=slash
append / indicator to directories 添加多文件
[root@bogon ~]# mkdir -p ./Desktop/test/001/002/
[root@bogon ~]# cd ./Desktop/
[root@bogon Desktop]# ls
test
[root@bogon Desktop]# tree test/
test/
└── 001
└── 002
-q, --hide-control-chars print ? instead of nongraphic characters 打印或者替换非图形化字符
--show-control-chars show nongraphic characters as-is (the default,
unless program is 'ls' and output is a terminal)
按原样显示非图形字符(默认情况下,除非程序是“ls”,输出是一个终端) ???
-Q, --quote-name enclose entry names in double quotes 将文件名使用双引号
--quoting-style=WORD use quoting style WORD for entry names:
literal, locale, shell, shell-always, c, escape
-r, --reverse reverse order while sorting 按照反序方式排列
[root@bogon ~]# ls -lr
total 8
drwxr-xr-x. 2 root root 6 Jun 19 2017 Videos
drwxr-xr-x. 2 root root 6 Jun 19 2017 Templates
drwxr-xr-x. 2 root root 6 Jun 19 2017 Public
drwxr-xr-x. 2 root root 6 Jun 19 2017 Pictures
-rw-r--r--. 1 root root 0 Aug 24 18:56 opencms_init.lo
-R, --recursive list subdirectories recursively 递归每个子文件
./dnspod-sr/tool:
total 12
-rw-r--r--. 1 root root 2477 Aug 16 22:21 client.c
-rw-r--r--. 1 root root 141 Aug 16 22:21 Makefile
-rw-r--r--. 1 root root 118 Aug 16 22:21 README
-s, --size print the allocated size of each file, in blocks 在块中打印每个文件的分配大小
[root@bogon ~]# ls -s
total 8
4 anaconda-ks.cfg 0 dnspod-sr 0 Downloads 0 mike 0 opencms_init.log 0 Public 0 Videos
0 Desktop 0 Documents 4 initial-setup-ks.cfg 0 Music 0 Pictures 0 Templates
-S sort by file size 按照文件大小排序
[root@bogon ~]# ls -sSr
total 8
0 opencms_init.log 0 Videos 0 Public 0 Music 0 Documents 0 dnspod-sr 4 initial-setup-ks.cfg
0 mike 0 Templates 0 Pictures 0 Downloads 0 Desktop 4 anaconda-ks.cfg
--sort=WORD sort by WORD instead of name: none (-U), size (-S),
time (-t), version (-v), extension (-X)
--time=WORD with -l, show time as WORD instead of default
modification time: atime or access or use (-u)
ctime or status (-c); also use specified time
as sort key if --sort=time
--time-style=STYLE with -l, show times using style STYLE:
full-iso, long-iso, iso, locale, or +FORMAT;
FORMAT is interpreted like in 'date'; if FORMAT
is FORMAT1<newline>FORMAT2, then FORMAT1 applies
to non-recent files and FORMAT2 to recent files;
if STYLE is prefixed with 'posix-', STYLE
takes effect only outside the POSIX locale
-t sort by modification time, newest first 最新的更新时间排序
-T, --tabsize=COLS assume tab stops at each COLS instead of 8 ??
-u with -lt: sort by, and show, access time; with -lt 显示访问时间和按照访问时间排序
with -l: show access time and sort by name; 按照名字排序并显示访问时间
otherwise: sort by access time 访问时间
-U do not sort; list entries in directory order 不排序 目录顺序的列表项
-v natural sort of (version) numbers within text 文本中自然的(版本)数字安排
-w, --width=COLS assume screen width instead of current value ??
-x list entries by lines instead of by columns 列表项使用行填充代表列填充
-X sort alphabetically by entry extension 按字母顺序排序
-1 (yi) list one file per line 每行列出一个文件
SELinux options:
--lcontext Display security context. Enable -l. Lines 显示安全内容, 使用参数-1,会尽可能在每行显示更多的内容
will probably be too wide for most displays.
[root@bogon ~]# ls --lcontext -1
total 8
-rw-------. 1 system_u:object_r:admin_home_t:s0 root root 1827 Jun 19 2017 anaconda-ks.cfg
drwxr-xr-x. 3 unconfined_u:object_r:admin_home_t:s0 root root 18 Feb 8 09:46 Desktop
drwxr-xr-x. 7 unconfined_u:object_r:admin_home_t:s0 root root 215 Aug 16 22:21 dnspod-sr
drwxr-xr-x. 2 unconfined_u:object_r:admin_home_t:s0 root root 6 Jun 19 2017 Documents
drwxr-xr-x. 2 unconfined_u:object_r:admin_home_t:s0 root root 6 Jun 19 2017 Downloads
-Z, --context Display security context so it fits on most
displays. Displays only mode, user, group,
security context and file name.
[root@bogon ~]# ls -Z
-rw-------. root root system_u:object_r:admin_home_t:s0 anaconda-ks.cfg
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 Desktop
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 dnspod-sr
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 Documents
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 Downloads
-rw-r--r--. root root system_u:object_r:admin_home_t:s0 initial-setup-ks.cfg
--scontext Display only security context and file name.
--help display this help and exit
--version output version information and exit
[root@bogon ~]# ls --scontext
system_u:object_r:admin_home_t:s0 anaconda-ks.cfg
unconfined_u:object_r:admin_home_t:s0 Desktop
unconfined_u:object_r:admin_home_t:s0 dnspod-sr
SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).
Using color to distinguish file types is disabled both by default and
with --color=never. With --color=auto, ls emits color codes only when
standard output is connected to a terminal. The LS_COLORS environment
variable can change the settings. Use the dircolors command to set it.
Exit status:
0 if OK,
1 if minor problems (e.g., cannot access subdirectory),
2 if serious trouble (e.g., cannot access command-line argument).
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'ls invocation'
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
文件(默认为当前的工作目录)信息列表
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
如果没有指定任何一个-cftuvSUX或-排序,那么按照排序条目的排序
Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
不忽略当前目录标识.的文件和文件夹(linux下文件隐藏文件是以.开头的,如果存在..代表存在着父目录)
-A, --almost-all do not list implied . and ..
显示所有文件(隐藏文件)但是不展示.和.. linux下文件.为当前目录,存在..代表存在着父目录)
--author with -l, print the author of each file
使用-l : 打印每个文件的author
-b, --escape print C-style escapes for nongraphic characters
为非图形字符打印c样式转义,把文件名中不可输出的字符用反斜杠加字符编号
--block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'--block-size=M' prints sizes in units of
1,048,576 bytes; see SIZE format below
打印前合计当前文件的大小 ls -l --block-size=M
-B, --ignore-backups do not list implied entries ending with ~
忽略备份 不要列出以结束为结尾的隐含条目
-c with -lt: sort by, and show, ctime (time of last
modification of file status information);
with -l: show ctime and sort by name;
otherwise: sort by ctime, newest first
使用 -ltc 根据文件状态信息中的最近修改时间来排序并显示, 使用-l 显示ctime和name排序,另外 ctime排序 更改时间的文件最新的第一
-C list entries by columns
--color[=WHEN] colorize the output; WHEN can be 'never', 'auto',
or 'always' (the default); more info below
彩色化输出 --color=when 'never', 'auto', or 'always' (the default);
-d, --directory list directories themselves, not their contents
列出目录本身,而不是它们的内容
-D, --dired generate output designed for Emacs' dired mode
生成为Emacs的dired模式设计的输出
-f do not sort, enable -aU, disable -ls --color
不排序 具有ls -aU功能 打印无颜色 ls -aU --color=never
-F, --classify append indicator (one of */=>@|) to entries
在每个文件名后附上一个字符以说明该文件的类型,“*”表示可执行的普通文件;“/”表示目 录;“@”表示符号链接;“|”表示FIFOs;“=”表示套接字(sockets)
--file-type likewise, except do not append '*' 文件类型: 除*
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
利用关键词来完成ls的输出模式,这些关键词也可以利用其他选项来完成,可用的关键词有(括号内为替代选 项):across(-x),commas(-m),horizontal(-x),long(-l),single-column(-l),vertical(-C).
--full-time like -l --time-style=full-iso 完整时间格式 非简约时间格式
-g like -l, but do not list owner 功能雷同 -l 但是不列出所有人
--group-directories-first
group directories before files; 显示组名于文件名前
can be augmented with a --sort option, but any
use of --sort=none (-U) disables grouping
可以使用参数a --sort arguments are: -none - time - size - extension - version是使用 --sort=none 不以组进行排序
-G, --no-group in a long listing, don't print group names -lG 不打印组信息
-h, --human-readable with -l, print sizes in human readable format 使用-l 打印可读格式的文件大小
(e.g., 1K 234M 2G)
--si likewise, but use powers of 1000 not 1024
--si 以1000取代1024作为统计单位,例如,1024bytes会被显示为1.024KB
-H, --dereference-command-line
follow symbolic links listed on the command line 执行命令行上列出的符号链接 ??
https://superuser.com/questions/593196/cp-h-vs-cp-l-what-is-a-command-line-symbolic-link
--dereference-command-line-symlink-to-dir 使用命令列中的符号链接指示的真正目的地
follow each command line symbolic link
that points to a directory
--hide=PATTERN do not list implied entries matching shell PATTERN 与-a-A一起使用,则会被-a或者-A覆盖
(overridden by -a or -A)
--indicator-style=WORD append indicator with style WORD to entry names:
none (default), slash (-p),
file-type (--file-type), classify (-F)
指定在每个项目名称后加上指示符号<方式>:none (默认),classify (-F),file-type (-p)
-i, --inode print the index number of each file 打印文件索引号
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN 不匹配隐含条目shell模式列表
[root@bogon ~]# ls -I Desktop
anaconda-ks.cfg Documents initial-setup-ks.cfg Music Pictures Templates
dnspod-sr Downloads mike
-k, --kibibytes default to 1024-byte blocks for disk usage 磁盘默认使用1024字节块
-l use a long listing format 使用长格式清单
-L, --dereference when showing file information for a symbolic 当显示文件信息为动态链接,显示文件的链接的信息而不是文件本身
link, show information for the file the link
references rather than for the link itself ?????
-m fill width with a comma separated list of entries 列表条目之间使用逗号间隔
[root@bogon ~]# ls -m
anaconda-ks.cfg, Desktop, dnspod-sr, Documents, Downloads, initial-setup-ks.cfg, mike, Music, opencms_init.log, Pictures,
Public, Templates, Videos
-n, --numeric-uid-gid like -l, but list numeric user and group IDs 类似参数l, 但是user&group 显示的他们的IDs
[root@bogon ~]# ls -n
total 8
-rw-------. 1 0 0 1827 Jun 19 2017 anaconda-ks.cfg
drwxr-xr-x. 2 0 0 6 Jun 19 2017 Desktop
drwxr-xr-x. 7 0 0 215 Aug 16 22:21 dnspod-sr
-N, --literal print raw entry names (don't treat e.g. control characters specially)打印原始条目名称(不要特别处理控制字符)
-o like -l, but do not list group information 类似参数l,但是列表无组信息
-p, --indicator-style=slash
append / indicator to directories 添加多文件
[root@bogon ~]# mkdir -p ./Desktop/test/001/002/
[root@bogon ~]# cd ./Desktop/
[root@bogon Desktop]# ls
test
[root@bogon Desktop]# tree test/
test/
└── 001
└── 002
-q, --hide-control-chars print ? instead of nongraphic characters 打印或者替换非图形化字符
--show-control-chars show nongraphic characters as-is (the default,
unless program is 'ls' and output is a terminal)
按原样显示非图形字符(默认情况下,除非程序是“ls”,输出是一个终端) ???
-Q, --quote-name enclose entry names in double quotes 将文件名使用双引号
--quoting-style=WORD use quoting style WORD for entry names:
literal, locale, shell, shell-always, c, escape
-r, --reverse reverse order while sorting 按照反序方式排列
[root@bogon ~]# ls -lr
total 8
drwxr-xr-x. 2 root root 6 Jun 19 2017 Videos
drwxr-xr-x. 2 root root 6 Jun 19 2017 Templates
drwxr-xr-x. 2 root root 6 Jun 19 2017 Public
drwxr-xr-x. 2 root root 6 Jun 19 2017 Pictures
-rw-r--r--. 1 root root 0 Aug 24 18:56 opencms_init.lo
-R, --recursive list subdirectories recursively 递归每个子文件
./dnspod-sr/tool:
total 12
-rw-r--r--. 1 root root 2477 Aug 16 22:21 client.c
-rw-r--r--. 1 root root 141 Aug 16 22:21 Makefile
-rw-r--r--. 1 root root 118 Aug 16 22:21 README
-s, --size print the allocated size of each file, in blocks 在块中打印每个文件的分配大小
[root@bogon ~]# ls -s
total 8
4 anaconda-ks.cfg 0 dnspod-sr 0 Downloads 0 mike 0 opencms_init.log 0 Public 0 Videos
0 Desktop 0 Documents 4 initial-setup-ks.cfg 0 Music 0 Pictures 0 Templates
-S sort by file size 按照文件大小排序
[root@bogon ~]# ls -sSr
total 8
0 opencms_init.log 0 Videos 0 Public 0 Music 0 Documents 0 dnspod-sr 4 initial-setup-ks.cfg
0 mike 0 Templates 0 Pictures 0 Downloads 0 Desktop 4 anaconda-ks.cfg
--sort=WORD sort by WORD instead of name: none (-U), size (-S),
time (-t), version (-v), extension (-X)
--time=WORD with -l, show time as WORD instead of default
modification time: atime or access or use (-u)
ctime or status (-c); also use specified time
as sort key if --sort=time
--time-style=STYLE with -l, show times using style STYLE:
full-iso, long-iso, iso, locale, or +FORMAT;
FORMAT is interpreted like in 'date'; if FORMAT
is FORMAT1<newline>FORMAT2, then FORMAT1 applies
to non-recent files and FORMAT2 to recent files;
if STYLE is prefixed with 'posix-', STYLE
takes effect only outside the POSIX locale
-t sort by modification time, newest first 最新的更新时间排序
-T, --tabsize=COLS assume tab stops at each COLS instead of 8 ??
-u with -lt: sort by, and show, access time; with -lt 显示访问时间和按照访问时间排序
with -l: show access time and sort by name; 按照名字排序并显示访问时间
otherwise: sort by access time 访问时间
-U do not sort; list entries in directory order 不排序 目录顺序的列表项
-v natural sort of (version) numbers within text 文本中自然的(版本)数字安排
-w, --width=COLS assume screen width instead of current value ??
-x list entries by lines instead of by columns 列表项使用行填充代表列填充
-X sort alphabetically by entry extension 按字母顺序排序
-1 (yi) list one file per line 每行列出一个文件
SELinux options:
--lcontext Display security context. Enable -l. Lines 显示安全内容, 使用参数-1,会尽可能在每行显示更多的内容
will probably be too wide for most displays.
[root@bogon ~]# ls --lcontext -1
total 8
-rw-------. 1 system_u:object_r:admin_home_t:s0 root root 1827 Jun 19 2017 anaconda-ks.cfg
drwxr-xr-x. 3 unconfined_u:object_r:admin_home_t:s0 root root 18 Feb 8 09:46 Desktop
drwxr-xr-x. 7 unconfined_u:object_r:admin_home_t:s0 root root 215 Aug 16 22:21 dnspod-sr
drwxr-xr-x. 2 unconfined_u:object_r:admin_home_t:s0 root root 6 Jun 19 2017 Documents
drwxr-xr-x. 2 unconfined_u:object_r:admin_home_t:s0 root root 6 Jun 19 2017 Downloads
-Z, --context Display security context so it fits on most
displays. Displays only mode, user, group,
security context and file name.
[root@bogon ~]# ls -Z
-rw-------. root root system_u:object_r:admin_home_t:s0 anaconda-ks.cfg
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 Desktop
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 dnspod-sr
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 Documents
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 Downloads
-rw-r--r--. root root system_u:object_r:admin_home_t:s0 initial-setup-ks.cfg
--scontext Display only security context and file name.
--help display this help and exit
--version output version information and exit
[root@bogon ~]# ls --scontext
system_u:object_r:admin_home_t:s0 anaconda-ks.cfg
unconfined_u:object_r:admin_home_t:s0 Desktop
unconfined_u:object_r:admin_home_t:s0 dnspod-sr
SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).
Using color to distinguish file types is disabled both by default and
with --color=never. With --color=auto, ls emits color codes only when
standard output is connected to a terminal. The LS_COLORS environment
variable can change the settings. Use the dircolors command to set it.
Exit status:
0 if OK,
1 if minor problems (e.g., cannot access subdirectory),
2 if serious trouble (e.g., cannot access command-line argument).
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'ls invocation'