文件管理类命令
命令1
cd
cd命令,也称为chdir(更改目录),是一个命令行操作系统shell命令,用于更改操作系统中的当前工作目录,如Unix,DOS,OS / 2,TRIPOS ,AmigaOS (如果给出了裸路径,暗示了cd),Microsoft Windows,ReactOS和Linux。它可以在shell脚本和批处理文件中使用。该命令也可以在开源MS-DOS模拟器DOSBox和EFI shell中使用。该命令在MPE / iX中命名为chdir。

在大多数操作系统中影响命令的系统调用是由POSIX定义的chdir。该命令类似于OpenVOS change_current_dir命令

cd本身或cd~将始终将您放在您的主目录中。
cd. 将离开您当前所在的目录(即您当前的目录不会更改)。如果shell的内部代码无法处理您正在重新创建的目录,这将非常有用;运行cd。将您的shell放在重新创建的目录中。
cd~username 将把你放在用户名的主目录中。
cd dir(没有/)会把你放在一个子目录中;例如,如果您在/ usr中,键入cd bin会将您放入/ usr / bin,而cd / bin会将您放入/ bin。
cd .. 会将你移动到一个目录。所以,如果你是/ usr / bin / tmp,cd ..会把你带到/ usr / bin,而cd ../ ..会把你带到/ usr(即两个级别)。您也可以使用此间接访问子目录。因此,从/ usr / bin / tmp,您可以使用cd ../../local转到/ usr / local。
cd - 将切换到上一个目录。例如,如果您在/ usr / bin / tmp中,并转到/ etc,则可以键入cd - 以返回/ usr / bin / tmp。您可以使用它在两个目录之间来回切换。

特殊符号包括~、-、..等。
~表示用户主目录,即HOME变量指定的目录,如root用户的主目录为/root。

[kiosk@foundation0 567]$ cd ~
[kiosk@foundation0 ~]$

-表示前一个工作目录。

[kiosk@foundation0 ~]$ cd -
/home/kiosk/567
[kiosk@foundation0 567]$

..表示上级目录。

[kiosk@foundation0 ~]$ cd -
/home/kiosk/567
[kiosk@foundation0 567]$ cd ..
[kiosk@foundation0 ~]$ pwd
/home/kiosk

.表示当前目录。
[kiosk@foundation0 ~]$ cd .
[kiosk@foundation0 ~]$ pwd
/home/kiosk

选项:

-P 如果要切换到的目标目录是一个符号连接,直接切换到符号连接指向的目标目录
[kiosk@foundation0 123]$ ln -s /tmp/123 567#创建软连接
[kiosk@foundation0 ~]$ ll
total 128
drwxrwxr-x. 2 kiosk kiosk 6 Feb 27 17:10 456
lrwxrwxrwx. 1 kiosk kiosk 8 Feb 27 17:12 567 -> /tmp/123
[kiosk@foundation0 ~]$ cd 567
[kiosk@foundation0 567]$ pwd
/home/kiosk/567 #路径显示是567
[kiosk@foundation0 123]$ cd ~
[kiosk@foundation0 ~]$ cd -P 567
[kiosk@foundation0 123]$ pwd
/tmp/123 #真实路径

(目录切换到567)

-L 如果要切换的目标目录是一个符号的连接,直接切换到字符连接名代表的目录,而非符号连接所指向的目标目录。

[kiosk@foundation0 ~]$ cd -L 567
[kiosk@foundation0 567]$ pwd
/home/kiosk/567

  • 当仅实用"-"一个选项时,当前工作目录将被切换到环境变量"OLDPWD"所表示的目录

(补充说明:.也是一个硬链接,是对目录的一个特殊硬链接)

命令2
ls
在计算中,ls是在Unix和类Unix操作系统中列出计算机文件的命令。 ls由POSIX和Single UNIX Specification指定。在没有任何参数的情况下调用时,ls列出当前工作目录中的文件。该命令也可以在EFI shell中使用。在其他环境中,例如DOS,OS / 2和Microsoft Windows,dir命令提供了类似的功能。

选项类型

-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file
-b, --escape print C-style escapes for nongraphic characters
--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
-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
-C list entries by columns
--color[=WHEN] colorize the output; WHEN can be 'never', 'auto',
or 'always' (the default); more info below
-d, --directory list directories themselves, not their contents
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -ls --color
-F, --classify append indicator (one of /=>@|) to entries
--file-type likewise, except do not append '
'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g like -l, but do not list owner
--group-directories-first
group directories before files;
can be augmented with a --sort option, but any
use of --sort=none (-U) disables grouping
-G, --no-group in a long listing, don't print group names
-h, --human-readable with -l, print sizes in human readable format
(e.g., 1K 234M 2G)
--si likewise, but use powers of 1000 not 1024
-H, --dereference-command-line
follow symbolic links listed on the command line
--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
(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)
-i, --inode print the index number of each file
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN
-k, --kibibytes default to 1024-byte blocks for disk usage
-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
-n, --numeric-uid-gid like -l, but list numeric user and group IDs
-N, --literal print raw entry names (don't treat e.g. control
characters specially)
-o like -l, but do not list group information
-p, --indicator-style=slash
append / indicator to directories
-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)
-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
-R, --recursive list subdirectories recursively
-s, --size print the allocated size of each file, in blocks
-S sort by file size
--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 -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 list one file per line

常见类型及例子
-a:显示所有档案及目录(ls内定将档案名或目录名称为“.”的视为影藏,不会列出);

[root@server0 tmp]# ls -a
. 19.txt 7.txt systemd-private-U4UeGf
.. 1.txt 8.txt systemd-private-UpllOx
10.txt 20.txt 9.txt systemd-private-usovJD

-A:显示除影藏文件“.”和“..”以外的所有文件列表;

[root@server0 tmp]# ls -A
10.txt 18.txt 4.txt systemd-private-2Fzohz systemd-private-usovJD
11.txt 19.txt 567 systemd-private-B7vtVY systemd-private-v9b809
123 1.txt 5.txt systemd-private-bHZOU7 systemd-private-Yb0zgZ

--color=auto:默认的--color=auto。这是默认选项;

[root@server0 tmp]# alias
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'

-l:与“-C”选项功能相反,所有输出信息用单列格式输出,不输出为多列;
显示 ctime 但根据名称排序否则:根据 ctime 排序
[root@server0 tmp]# ls -i
20201256 10.txt 20201251 5.txt
20201257 11.txt 20201252 6.txt
20201258 12.txt 20201253 7.txt

-c 配合 -lt:根据 ctime 排序及显示 ctime (文件状态最后更改的时间)配合

[root@server0 tmp]# ls -clt
total 0
-rw-r--r--. 1 root root 0 Feb 28 09:26 10.txt
-rw-r--r--. 1 root root 0 Feb 28 09:26 11.txt
-rw-r--r--. 1 root root 0 Feb 28 09:26 12.txt
-rw-r--r--. 1 root root 0 Feb 28 09:26 13.txt
-rw-r--r--. 1 root root 0 Feb 28 09:26 14.txt
-rw-r--r--. 1 root root 0 Feb 28 09:26 15.txt

–color[=WHEN] 控制是否使用色彩分辨文件。WHEN 可以是'never'、'always'或'auto'其中之一

-d, –directory 将目录象文件一样显示,而不是显示其下的文件。

[root@server0 tmp]# ls -ld
drwxrwxrwt. 22 root root 4096 Feb 28 14:29 .
(#仅显示当前目录,不显示其他内容)

-D, –dired 产生适合 Emacs 的 dired 模式使用的结果

[root@server0 tmp]# ls -D
10.txt 17.txt 2.txt 9.txt systemd-private-U4UeGf
11.txt 18.txt 3.txt systemd-private-2Fzohz systemd-private-UpllOx
123 19.txt 4.txt systemd-private-B7vtVY systemd-private-usovJD
12.txt 1.txt 567 systemd-private-bHZOU7 systemd-private-v9b809
13.txt 20.txt 5.txt systemd-private-dKm1nw systemd-private-Yb0zgZ
14.txt 21.txt 6.txt systemd-private-G6SMwJ systemd-private-yILolc
15.txt 22.txt 7.txt systemd-private-HJCqz6 systemd-private-yY3Xrm
16.txt 23.txt 8.txt systemd-private-huSQgJ

-f 对输出的文件不进行排序,-aU 选项生效,-lst 选项失效
[root@server0 tmp]# ls -f
. systemd-private-usovJD 2.txt 14.txt
.. 567 3.txt 15.txt
.X11-unix systemd-private-yY3Xrm 4.txt 16.txt
.ICE-unix systemd-private-B7vtVY 5.txt 17.txt
.XIM-unix systemd-private-bHZOU7 6.txt 18.txt
.font-unix systemd-private-huSQgJ 7.txt 19.txt
.Test-unix systemd-private-Yb0zgZ 8.txt 20.txt
systemd-private-yILolc systemd-private-U4UeGf 9.txt 21.txt
systemd-private-UpllOx systemd-private-v9b809 10.txt 22.txt
systemd-private-dKm1nw .X0-lock 11.txt 23.txt
systemd-private-2Fzohz systemd-private-G6SMwJ 12.txt 123
systemd-private-HJCqz6 1.txt 13.txt

-g 类似 -l,但不列出所有者(仅列出组)
[root@server0 tmp]# groupadd 123
[root@server0 tmp]# chgrp 123 10.txt
[root@server0 tmp]# ls -al
total 12
drwxrwxrwt. 22 root root 4096 Feb 28 16:14 .
drwxr-xr-x. 17 root root 4096 Feb 28 09:18 ..
-rw-r--r--. 1 root 123 0 Feb 28 09:26 10.txt
-rw-r--r--. 1 root root 0 Feb 28 09:26 11.txt
[root@server0 tmp]# ls -g
total 0
-rw-r--r--. 1 123 0 Feb 28 09:26 10.txt

-G, –no-group 不列出任何有关组的信息

[root@server0 tmp]# ls -alG
total 12
drwxrwxrwt. 22 root 4096 Feb 28 16:14 .
drwxr-xr-x. 17 root 4096 Feb 28 09:18 ..
-rw-r--r--. 1 root 0 Feb 28 09:26 10.txt
-rw-r--r--. 1 root 0 Feb 28 09:26 11.txt
drwxr-xr-x. 2 root 6 Feb 28 14:29 123

-h, –human-readable 以容易理解的格式列出文件大小 (例如 1K 234M 2G)

[root@server0 tmp]# ls -alh
total 12K
drwxrwxrwt. 22 root root 4.0K Feb 28 16:14 .
drwxr-xr-x. 17 root root 4.0K Feb 28 09:18 ..
(#直接显示4.0k)

--si 类似 -h,但文件大小取 1000 的次方而不是 1024

-H, –dereference-command-line 使用命令列中的符号链接指示的真正目的地

–indicator-style=方式 指定在每个项目名称后加上指示符号<方式>:none (默认),classify (-F),file-type (-p)

-i, –inode 印出每个文件的 inode 号

[root@server0 tmp]# ls -i
20201256 10.txt 20201251 5.txt
20201257 11.txt 20201252 6.txt
8846781 123 20201253 7.txt

-I, –ignore=样式 不印出任何符合 shell 万用字符<样式>的项目

-k 即 –block-size=1K,以 k 字节的形式表示文件的大小。

-l(l) 除了文件名之外,还将文件的权限、所有者、文件大小等信息详细列出来。
[root@server0 /]# ls -l
total 32
lrwxrwxrwx. 1 root root 5 Feb 17 23:52 1.txt -> i.txt
lrwxrwxrwx. 1 root root 7 May 7 2014 bin -> usr/bin
dr-xr-xr-x. 4 root root 4096 Jul 11 2014 boot
drwxr-xr-x. 19 root root 2860 Feb 28 09:18 dev
drwxr-xr-x. 133 root root 8192 Feb 28 16:14 etc

-L, –dereference 当显示符号链接的文件信息时,显示符号链接所指示的对象而并非符号链接本身的信息

[root@server0 123]# ll
total 0
-rw-r--r--. 1 root root 0 Feb 28 17:54 222.txt
-rw-r--r--. 1 root root 0 Feb 28 17:56 223.txt
lrwxrwxrwx. 1 root root 7 Feb 28 17:56 225 -> 223.txt
lrwxrwxrwx. 1 root root 11 Feb 28 17:57 226 -> /tmp/12.txt
[root@server0 123]# ls -L
222.txt 223.txt 225 226
(#仅显示软连接,不显示软连接的实质)
-m 所有项目以逗号分隔,并填满整行行宽

[root@server0 tmp]# ls -m
10.txt, 11.txt, 123, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt,
19.txt, 1.txt, 20.txt, 21.txt, 22.txt, 23.txt

-o 类似 -l,显示文件的除组信息外的详细信息。

root@server0 tmp]# ls -o
total 0
-rw-r--r--. 1 root 0 Feb 28 09:26 10.txt
-rw-r--r--. 1 root 0 Feb 28 09:26 11.txt
drwxr-xr-x. 2 root 54 Feb 28 17:57 123
-rw-r--r--. 1 root 0 Feb 28 09:26 12.txt
(#不显示组信息)

-r, –reverse 依相反次序排列

[root@server0 123]# ls
222.txt 223.txt 225 226
[root@server0 123]# ls -r
226 225 223.txt 222.txt

-R, –recursive 同时列出所有子目录层

[root@server0 123]# ls -lR
.:
total 0
-rw-r--r--. 1 root root 0 Feb 28 17:54 222.txt
-rw-r--r--. 1 root root 0 Feb 28 17:56 223.txt
lrwxrwxrwx. 1 root root 7 Feb 28 17:56 225 -> 223.txt
lrwxrwxrwx. 1 root root 11 Feb 28 17:57 226 -> /tmp/12.txt
drwxr-xr-x. 2 root root 20 Feb 28 18:03 456

./456:
total 0
-rw-r--r--. 1 root root 0 Feb 28 18:03 227.txt

-s, –size 以块大小为单位列出所有文件的大小

[root@server0 123]# ls -s
total 8
4 222.txt 4 223.txt 0 225 0 226 0 456

-S 根据文件大小排序
[root@server0 123]# ls -Ssal
total 12
4 drwxrwxrwt. 22 root root 4096 Feb 28 18:04 ..
0 drwxr-xr-x. 3 root root 64 Feb 28 18:03 .
4 -rw-r--r--. 1 root root 39 Feb 28 18:04 223.txt
0 drwxr-xr-x. 2 root root 20 Feb 28 18:03 456
4 -rw-r--r--. 1 root root 16 Feb 28 18:04 222.txt
0 lrwxrwxrwx. 1 root root 11 Feb 28 17:57 226 -> /tmp/12.txt
0 lrwxrwxrwx. 1 root root 7 Feb 28 17:56 225 -> 223.txt

–sort=WORD 以下是可选用的 WORD 和它们代表的相应选项:

extension -X status -c

none -U time -t

size -S atime -u

time -t access -u

version -v use -u

-t 以文件修改时间排序

[root@server0 123]# stat 222.txt
File: ‘222.txt’
Size: 16 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 8846783 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-02-28 18:07:24.849515516 +0800
Modify: 2019-02-28 18:04:33.993515516 +0800
Change: 2019-02-28 18:04:33.993515516 +0800
Birth: -
[root@server0 123]# stat 223.txt
File: ‘223.txt’
Size: 39 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 8846784 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-02-28 17:56:22.905515516 +0800
Modify: 2019-02-28 18:04:49.538515516 +0800
Change: 2019-02-28 18:04:49.538515516 +0800

[root@server0 123]# ls -alt #升序
total 12
-rw-r--r--. 1 root root 39 Feb 28 18:04 223.txt
-rw-r--r--. 1 root root 16 Feb 28 18:04 222.txt
drwxrwxrwt. 22 root root 4096 Feb 28 18:04 ..
drwxr-xr-x. 2 root root 20 Feb 28 18:03 456
drwxr-xr-x. 3 root root 64 Feb 28 18:03 .
lrwxrwxrwx. 1 root root 11 Feb 28 17:57 226 -> /tmp/12.txt
lrwxrwxrwx. 1 root root 7 Feb 28 17:56 225 -> 223.txt

-u 配合 -lt:显示访问时间而且依访问时间排序

[root@server0 tmp]# ls -ult
total 0
lrwxrwxrwx. 1 root root 3 Mar 1 16:34 567 -> 123
drwx------. 3 root root 16 Mar 1 11:23 systemd-private-SH7owA
drwx------. 3 root root 16 Mar 1 11:23 systemd-private-1zuk9W
drwxr-xr-x. 3 root root 64 Feb 28 18:03 123
-rw-r--r--. 1 root 123 0 Feb 28 09:26 10.txt
[root@server0 tmp]# echo 123 > 10.txt
[root@server0 tmp]# stat 10.txt
File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-02-28 09:26:31.948515516 +0800
[root@server0 tmp]# cat 10.txt
123
[root@server0 tmp]# stat 10.txt
File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-01 16:36:59.077557282 +0800

[root@server0 tmp]# ls -ult
total 4
-rw-r--r--. 1 root 123 4 Mar 1 16:36 10.txt
lrwxrwxrwx. 1 root root 3 Mar 1 16:34 567 -> 123

配合 -l:显示访问时间但根据名称排序
否则:根据访问时间排序

-U 不进行排序;依文件系统原有的次序列出项目
[root@server0 tmp]# ls -U
systemd-private-yILolc systemd-private-huSQgJ 8.txt 18.txt
systemd-private-UpllOx systemd-private-Yb0zgZ 9.txt 19.txt
systemd-private-dKm1nw systemd-private-U4UeGf 10.txt 20.txt

-v 根据版本进行排序

[root@server0 tmp]# ls -v
1.txt 9.txt 17.txt 567 systemd-private-Yb0zgZ
2.txt 10.txt 18.txt systemd-private-1zuk9W systemd-private-bHZOU7

-w, –width=COLS 自行指定屏幕宽度而不使用目前的数值

Example1

[root@server0 tmp]# echo $COLUMNS
100

[root@server0 tmp]# ls -w 10
10.txt
11.txt
123
12.txt
13.txt
14.txt

Example2[root@server0 tmp]# ls -w 100
10.txt 11.txt 123 12.txt 13.txt 14.txt 15.txt 16.txt 17.txt 18.txt 19.txt 1.txt 20.txt 21.txt 22.txt 23.txt 2.txt 3.txt 4.txt 567 5.txt 6.txt

-x 逐行列出项目而不是逐栏列出

[root@server0 tmp]# ls -x
10.txt 11.txt 123
12.txt 13.txt 14.txt
15.txt 16.txt 17.txt

-X 根据扩展名排序

[root@server0 tmp]# ls -X
123 systemd-private-HJCqz6 systemd-private-yILolc 15.txt 21.txt 6.txt
567 systemd-private-huSQgJ systemd-private-yY3Xrm 16.txt 22.txt 7.txt

-1 每行只列出一个文件

[root@server0 tmp]# ls -1
10.txt
11.txt
123

–help 显示此帮助信息并离开

–version 显示版本信息并离开

命令3
mkdir

mkdir-生成目录

简介

mkdir[选项]…目录。。。

描述

如果目录不存在,则创建目录。

长选项的强制参数对短选项也是强制的。

-m,-MODE=MODE

设置文件模式(如chmod),而不是a=rwx-umask

[root@server0 tmp]# mkdir 234
[root@server0 tmp]# mkdir -m 777 456
[root@server0 tmp]# ls -al | grep -E '234|456'
drwxr-xr-x. 2 root root 6 Mar 1 18:19 234
drwxrwxrwx. 2 root root 6 Mar 1 18:19 456

-p,-parents

没有错误如果存在,根据需要创建父目录

[root@server0 tmp]# mkdir -p /234/123/123/12345
[root@server0 tmp]# cd /234
[root@server0 234]# ls -alR
.:
total 4
drwxr-xr-x. 3 root root 16 Mar 1 18:21 .
drwxr-xr-x. 18 root root 4096 Mar 1 18:21 ..
drwxr-xr-x. 3 root root 16 Mar 1 18:21 123

./123:
total 0
drwxr-xr-x. 3 root root 16 Mar 1 18:21 .
drwxr-xr-x. 3 root root 16 Mar 1 18:21 ..
drwxr-xr-x. 3 root root 18 Mar 1 18:21 123

./123/123:
total 0
drwxr-xr-x. 3 root root 18 Mar 1 18:21 .
drwxr-xr-x. 3 root root 16 Mar 1 18:21 ..
drwxr-xr-x. 2 root root 6 Mar 1 18:21 12345

./123/123/12345:
total 0
drwxr-xr-x. 2 root root 6 Mar 1 18:21 .
drwxr-xr-x. 3 root root 18 Mar 1 18:21 ..

-V,-verbose

为每个创建的目录打印消息

[root@server0 234]# mkdir -v abc
mkdir: created directory ‘abc’

-Z,--context[=CTX]

将每个已创建目录的SELinux安全上下文设置为默认类型或

CTX(如有规定)

[root@server0 234]# mkdir -Z def
[root@server0 234]# ls -Z
drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 123
drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 abc
drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 def

缺示例 待补充

--help
display this help and exit

--version
output version information and exit

命令4
touch
作用:更改文件的时间戳,创建文件

用法:touch[选项] ...文件...
将每个FILE的访问和修改时间更新为当前时间。

除非-c或-h,否则不存在的FILE参数将为空
供应。

一个FILE参数字符串 - 被特殊处理并导致触摸
更改与标准输出关联的文件的时间。

对于空头期权而言,长期期权的强制性论据也是强制性的。
-a 仅更改访问时间(仅更改atime)

[root@server0 tmp]# stat 10.txt

File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-04 10:59:48.764737455 +0800
Modify: 2019-03-01 16:36:37.375557282 +0800
Change: 2019-03-04 10:59:17.993737455 +0800
Birth: -
[root@server0 tmp]# touch -a 10.txt
[root@server0 tmp]# stat 10.txt
File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-04 11:01:27.206737455 +0800

-c, - no-create不创建任何文件

[root@server0 tmp]# touch -c 12333333.txt

[root@server0 tmp]# ls
10.txt 19.txt 456 systemd-private-1zuk9W systemd-private-u2kx8c
11.txt 1.txt 4.txt systemd-private-2Fzohz systemd-private-U4UeGf
123 20180901 567 systemd-private-5GFH6G systemd-private-UpllOx
12.txt 20.txt 5.txt systemd-private-B7vtVY systemd-private-usovJD
13.txt 21.txt 678 systemd-private-bHZOU7 systemd-private-wqXel1
14.txt 22.txt 6.txt systemd-private-dKm1nw systemd-private-Yb0zgZ
15.txt 234 789 systemd-private-HJCqz6 systemd-private-yILolc
16.txt 23.txt 7.txt systemd-private-huSQgJ systemd-private-yY3Xrm
17.txt 2.txt 8.txt systemd-private-sFzcdw
18.txt 3.txt 9.txt systemd-private-SH7owA

-d, - date = STRING解析STRING并使用它而不是当前时间(指定日期参数)

[root@server0 tmp]# touch -d 20180901 122222.txt

[root@server0 tmp]# ll
total 4
-rw-r--r--. 1 root 123 4 Mar 1 16:36 10.txt
-rw-r--r--. 1 root root 0 Feb 28 09:26 11.txt
-rw-r--r--. 1 root root 0 Sep 1 2018 122222.txt
drwxr-xr-x. 3 root root 64 Feb 28 18:03 123

-f(忽略)

-h, -  no-dereference影响每个符号链接而不是任何引用file(仅适用于可以更改的系统)符号链接的时间戳)

-m仅更改修改时间(mtime和ctime都会改变)

[root@server0 tmp]# stat 10.txt

File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-04 11:01:27.206737455 +0800
Modify: 2019-03-04 12:21:06.142737455 +0800
Change: 2019-03-04 12:21:06.142737455 +0800
Birth: -
[root@server0 tmp]# touch -m 10.txt
[root@server0 tmp]# stat 10.txt
File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-04 11:01:27.206737455 +0800
Modify: 2019-03-04 12:21:36.918737455 +0800
Change: 2019-03-04 12:21:36.918737455 +0800

-r, - reference = FILE使用此文件的时间而不是当前时间

[root@server0 tmp]# stat 10.txt

File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-04 11:01:27.206737455 +0800
Modify: 2019-03-04 12:21:36.918737455 +0800
Change: 2019-03-04 12:21:36.918737455 +0800
Birth: -
[root@server0 tmp]# stat 11.txt
File: ‘11.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd01h/64769d Inode: 20201257 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-02-28 09:26:31.948515516 +0800
Modify: 2019-02-28 09:26:31.948515516 +0800
Change: 2019-02-28 09:26:31.948515516 +0800
Birth: -
[root@server0 tmp]# touch -r 11.txt 10.txt
[root@server0 tmp]# stat 10.txt
File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-02-28 09:26:31.948515516 +0800
Modify: 2019-02-28 09:26:31.948515516 +0800
Change: 2019-03-04 13:54:20.499737455 +0800
Birth: -

-t STAMP使用[[CC] YY] MMDDhhmm [.ss]代替当前时间
--time = WORD更改指定的时间:
WORD是access,atime或use:相当于-a
WORD是modify或mtime:相当于-m

    [root@server0 tmp]# stat 10.txt

File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-02-28 09:26:31.948515516 +0800
Modify: 2019-02-28 09:26:31.948515516 +0800
Change: 2019-03-04 13:54:20.499737455 +0800
Birth: -
[root@server0 tmp]# touch -t 201809092323 10.txt
[root@server0 tmp]# stat 10.txt
File: ‘10.txt’
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20201256 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 1001/ 123)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2018-09-09 23:23:00.000000000 +0800
Modify: 2018-09-09 23:23:00.000000000 +0800
Change: 2019-03-04 14:10:40.173737455 +0800
Birth: -

  --help显示此帮助并退出--version输出版本信息并退出

命令5
mv
移动文件或重命名文件
mv --help
用法:mv [OPTION] ... [ - T] SOURCE DEST
或者:mv [OPTION] ......来源......目录
或者:mv [OPTION] ... -t DIRECTORY SOURCE ...
将SOURCE重命名为DEST,或将SOURCE(s)移至DIRECTORY。

--backup [= CONTROL]备份每个现有目标文件
--backup该选项指定如果目标文件存在时的动作,共有四种备份策略:
1.CONTROL=none或off : 不备份。
2.CONTROL=numbered或t:数字编号的备份
3.CONTROL=existing或nil:如果存在以数字编号的备份,则继续编号备份m+1...n:
执行mv操作前已存在以数字编号的文件log2.txt.~1~,那么再次执行将产生log2.txt~2~,以次类推。如果之前没有以数字编号的文件,则使用下面讲到的简单备份。
4.CONTROL=simple或never:使用简单备份:在被覆盖前进行了简单备份,简单备份只能有一份,再次被覆盖时,简单备份也会被覆盖。

-b --backup但不接受参数,mv会去读取环境变量VERSION_CONTROL来作为备份策略。

[root@server0 tmp]# cd 567
[root@server0 567]# ls
222.txt 223.txt 225 226 456
[root@server0 567]# cd ..
[root@server0 tmp]# touch 222.txt
[root@server0 tmp]# mv -b 222.txt /tmp/567
mv: overwrite ‘/tmp/567/222.txt’? y
[root@server0 tmp]# cd 567
[root@server0 567]# ls
222.txt 222.txt~ 223.txt 225 226 456
(覆盖前生成备份文件)

-f, - force在覆盖之前不提示

[root@server0 tmp]# touch 223.txt
[root@server0 tmp]# echo 232323 > 223.txt
[root@server0 tmp]# mv -f 223.txt /tmp/567/223.txt
[root@server0 tmp]# cd 567
[root@server0 567]# ls
222.txt 222.txt~ 223.txt 225 226 456
[root@server0 567]# cat 223
cat: 223: No such file or directory
[root@server0 567]# cat 223.txt
232323

-i, - 覆盖前的交互式提示(alias 默认)

alias mv='mv -i'

-n, - no-clobber不会覆盖现有文件
如果指定-i,-f,-n中的多个,则只有最后一个生效。

[root@server0 tmp]# mv -n 223.txt /tmp/567/
[root@server0 tmp]# cd 567
[root@server0 567]# stat 223.txt
File: ‘223.txt’
Size: 7 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 20203461 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-04 15:25:53.897737455 +0800
Modify: 2019-03-04 15:25:12.776737455 +0800
Change: 2019-03-04 15:25:32.588737455 +0800
Birth: -
[root@server0 567]# ls
222.txt 222.txt~ 223.txt 225 226 456

  --strip-trailing-slashes从每个SOURCE中删除任何尾部斜杠争论

-S, - stuff = SUFFIX覆盖通常的备份后缀

[root@server0 tmp]# mv -S 23 223.txt /tmp/567(#23为后缀)

mv: overwrite ‘/tmp/567/223.txt’? y
[root@server0 tmp]# cd 567
[root@server0 567]# ls
222.txt 222.txt~ 223.txt 223.txt23 225 226 456

-t, - target-directory = DIRECTORY将所有SOURCE参数移动到DIRECTORY

[root@server0 567]# mv -t /tmp/ 223.txt
[root@server0 567]# cd ..
[root@server0 tmp]# ls -t
123 14.txt 7.txt
223.txt 15.txt systemd-private-U4UeGf
223

-T, - no-target-directory将DEST视为普通文件
普通模式

-u, - update仅在SOURCE文件较新时移目标文件
[root@server0 tmp]# mv -u 34.txt /tmp/123/
[root@server0 tmp]# cd 123
[root@server0 123]# stat 34.txt
File: ‘34.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd01h/64769d Inode: 8846753 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-04 17:01:01.855737455 +0800
Modify: 2019-03-04 17:01:01.855737455 +0800
Change: 2019-03-04 17:01:01.855737455 +0800
Birth: -
[root@server0 123]# cd ..
[root@server0 tmp]# ls
10.txt 19.txt 2.txt 7.txt systemd-private-sFzcdw
122222.txt 1.txt 34.txt
(#文件比现在的新就不移动文件)

-v, - verbose解释正在做什么

[root@server0 tmp]# mv -v 34.txt /tmp/123/

mv: overwrite ‘/tmp/123/34.txt’? y
‘34.txt’ -> ‘/tmp/123/34.txt’

-Z, - context设置SELinux目的地的安全上下文文件为默认类型

[root@server0 tmp]# ls -Z 35.txt

-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 35.txt
[root@server0 tmp]# mv -Z 35.txt /var/www/
[root@server0 tmp]# ls -Z /var/www/
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 35.txt
drwxr-xr-x. root root system_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 ht

  --help显示此帮助并退出--version输出版本信息并退出

命令6
cp
cp - 复制文件和目录

语法
-a, - 与-dR --preserve = all相同(含目录)
-a 会保留原文件或目录的属性

[root@server0 tmp]# cp -a 1* /tmp/cpuse
[root@server0 cpuse]# ls
10.txt 1222.txt 12.txt 14.txt 16.txt 18.txt 1.txt
122222.txt 123 13.txt 15.txt 17.txt 19.txt

--attributes-only不复制文件数据,只复制属性

[root@server0 tmp]# chmod 777 10.txt
[root@server0 tmp]# ls -al
total 24
drwxrwxrwt. 31 root root 4096 Mar 4 18:14 .
drwxr-xr-x. 18 root root 4096 Mar 4 14:35 ..
-rwxrwxrwx. 1 root 123 4 Sep 9 23:23 10.txt
-rw-r--r--. 1 root root 0 Feb 28 09:26 19.txt
[root@server0 tmp]# cp --attributes-only --preserve 19.txt 10.txt
[root@server0 tmp]# ls -al
total 24
drwxrwxrwt. 31 root root 4096 Mar 4 18:14 .
drwxr-xr-x. 18 root root 4096 Mar 4 14:35 ..
-rw-r--r--. 1 root root 4 Feb 28 09:26 10.txt

--backup [= CONTROL]备份每个现有目标文件

[root@server0 tmp]# cp --backup 10.txt 1900.txt
[root@server0 tmp]# cat 1900.txt
123

-b --backup但不接受参数
--copy-contents在递归时复制特殊文件的内容
-d 与--no-dereference --preserve = links相同
-f, - force如果不能存在现有目标文件打开,删除它并再试一次(此选项 在使用-n选项时被忽略)

[root@server0 tmp]# cd 12

[root@server0 12]# touch {5..9}.txt
[root@server0 12]# cd ..
[root@server0 tmp]# echo 1212121212112 > 5.txt
[root@server0 tmp]# cp -f 5.txt /tmp/12
cp: overwrite ‘/tmp/12/5.txt’? y
[root@server0 tmp]# ls /tmp/12
5.txt 6.txt 7.txt 8.txt 9.txt
[root@server0 tmp]# ls -al /tmp/12
total 8
drwxr-xr-x. 2 root root 66 Mar 5 10:36 .
drwxrwxrwt. 22 root root 4096 Mar 5 10:35 ..
-rw-r--r--. 1 root root 14 Mar 5 10:39 5.txt

-i, - 覆盖前的交互式提示(覆盖前一个-n选项,默认选项)

    [root@server0 tmp]# alias
alias cp='cp -i'

-H 遵循SOURCE中的命令行符号链接(保持对源的符号链接)
(关于-HL选项的详细理解,参考 https://superuser.com/questions/593196/cp-h-vs-cp-l-what-is-a-command-line-symbolic-link )

[root@server0 tmp]# ln -s 8.txt 123
[root@server0 tmp]# ls -al
lrwxrwxrwx. 1 root root 5 Mar 5 10:57 123 -> 8.txt
[root@server0 tmp]# cp -H 123 13
[root@server0 tmp]# cd 13
[root@server0 13]# ls
123 233
[root@server0 13]# file 123
123: empty
[root@server0 13]# cd ..
[root@server0 tmp]# file 123
123: symbolic link to `8.txt'

-l, - 链接硬链接文件而不是复制()

[root@server0 tmp]# cp -l 2.txt 2H
[root@server0 tmp]# echo 12312312312321 > 2.txt
[root@server0 tmp]# file 2H
2H: ASCII text
[root@server0 tmp]# cat 2H
12312312312321

-L, - dereference始终遵循SOURCE中的符号链接(仅复制文件本身,不复制符号链接内容,如果符号链接为空,将不进行复制)

(关于-HL选项的详细理解,参考 https://superuser.com/questions/593196/cp-h-vs-cp-l-what-is-a-command-line-symbolic-link   )[root@server0 tmp]# ls -al

total 24
drwxrwxrwt. 25 root root 4096 Mar 5 16:03 .
drwxr-xr-x. 17 root root 4096 Mar 5 16:02 ..
drwxr-xr-x. 3 root root 76 Mar 5 10:45 12
lrwxrwxrwx. 1 root root 5 Mar 5 10:57 123 -> 8.txt
[root@server0 tmp]# cp -L 123 /tmp/12
[root@server0 tmp]# cd /tmp/12
[root@server0 12]# ls
[root@server0 12]# ls -al
total 8
drwxr-xr-x. 3 root root 86 Mar 5 16:06 .
drwxrwxrwt. 25 root root 4096 Mar 5 16:03 ..
-rw-r--r--. 1 root root 0 Mar 5 16:06 123

(-HL的示例如下)

[root@server0 tmp]# mkdir -p test1/test2
[root@server0 tmp]# mkdir -p test3
[root@server0 tmp]# cd test1
[root@server0 test1]# ls
test2
[root@server0 test1]# echo 123123 > testonly
[root@server0 test1]# ls
test2 testonly
[root@server0 test1]# touch 213123.txt
[root@server0 test1]# ln -s testonly testfor
[root@server0 test1]# cd test2
[root@server0 test2]# touch test123
[root@server0 test2]# ln -s test2 test2use
[root@server0 test2]# ls
test123 test2use
[root@server0 test2]# ls -al
total 0
drwxr-xr-x. 2 root root 35 Mar 5 10:14 .
drwxr-xr-x. 3 root root 64 Mar 5 10:13 ..
-rw-r--r--. 1 root root 0 Mar 5 10:13 test123
lrwxrwxrwx. 1 root root 5 Mar 5 10:14 test2use -> test2
[root@server0 test2]# cd ..
[root@server0 test1]# cd ..
[root@server0 tmp]# cp -Hr test1 test3
[root@server0 tmp]# cd test3
[root@server0 test3]# ls-al
bash: ls-al: command not found...
[root@server0 test3]# ls -al
total 4
drwxr-xr-x. 3 root root 18 Mar 5 10:20 .
drwxrwxrwt. 34 root root 4096 Mar 5 10:18 ..
drwxr-xr-x. 3 root root 64 Mar 5 10:20 test1
[root@server0 test3]# cdtest1
bash: cdtest1: command not found...
[root@server0 test3]# cd test1
[root@server0 test1]# ls -al
total 4
drwxr-xr-x. 3 root root 64 Mar 5 10:20 .
drwxr-xr-x. 3 root root 18 Mar 5 10:20 ..
-rw-r--r--. 1 root root 0 Mar 5 10:20 213123.txt
drwxr-xr-x. 2 root root 35 Mar 5 10:20 test2
lrwxrwxrwx. 1 root root 8 Mar 5 10:20 testfor -> testonly
-rw-r--r--. 1 root root 7 Mar 5 10:20 testonly
[root@server0 test1]# cd test2
[root@server0 test2]# ls -al
total 0
drwxr-xr-x. 2 root root 35 Mar 5 10:20 .
drwxr-xr-x. 3 root root 64 Mar 5 10:20 ..
-rw-r--r--. 1 root root 0 Mar 5 10:20 test123
lrwxrwxrwx. 1 root root 5 Mar 5 10:20 test2use -> test2
[root@server0 test2]# cd ..
[root@server0 test1]# cd ..
[root@server0 test3]# rm -rf /tmp/test3/test1
[root@server0 test3]# ls
[root@server0 test3]# cd ..
[root@server0 tmp]# cp -Lr test1 test3
cp: cannot stat ‘test1/test2/test2use’: No such file or directory
[root@server0 tmp]# cd test3
[root@server0 test3]# ls
test1
[root@server0 test3]# cd test1
[root@server0 test1]# ls
213123.txt test2 testfor testonly
[root@server0 test1]# ls -al
total 8
drwxr-xr-x. 3 root root 64 Mar 5 10:23 .
drwxr-xr-x. 3 root root 18 Mar 5 10:23 ..
-rw-r--r--. 1 root root 0 Mar 5 10:23 213123.txt
drwxr-xr-x. 2 root root 20 Mar 5 10:23 test2
-rw-r--r--. 1 root root 7 Mar 5 10:23 testfor
-rw-r--r--. 1 root root 7 Mar 5 10:23 testonly
[root@server0 test1]# cd test2
[root@server0 test2]# ls
test123

-n, - no-clobber不会覆盖现有文件(覆盖前一个-i选项)
复制但是不覆盖原文件

[root@server0 tmp]# cp -ni 123 12

cp: overwrite ‘12/123’? y
[root@server0 tmp]# stat 123
File: ‘123’ -> ‘8.txt’
Size: 5 Blocks: 0 IO Block: 4096 symbolic link
Device: fd01h/64769d Inode: 20198311 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-05 10:57:56.887021713 +0800
Modify: 2019-03-05 10:57:55.302021713 +0800
Change: 2019-03-05 10:57:55.302021713 +0800
Birth: -
[root@server0 tmp]# cd 12
[root@server0 12]# stat 123
File: ‘123’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd01h/64769d Inode: 8846753 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-05 16:06:18.399263140 +0800
Modify: 2019-03-05 16:24:29.036263140 +0800
Change: 2019-03-05 16:24:29.036263140 +0800
Birth: -

-P, - no-dereference从不遵循SOURCE中的符号链接(源里面复制符号链接如果没有链接文件会亮红,不检查符号链接的可靠性)

[root@server0 tmp]# cp -P 123 13
[root@server0 tmp]# cd 13
[root@server0 13]# ls
123 233
[root@server0 13]# ls -al
total 4
drwxr-xr-x. 3 root root 26 Mar 5 16:39 .
drwxrwxrwt. 25 root root 4096 Mar 5 16:30 ..
lrwxrwxrwx. 1 root root 5 Mar 5 16:39 123 -> 8.txt

-p与--preserve = mode,ownership,timestamps相同

  --preserved [= ATTR_LIST]保留指定的属性(默认值: 模式,所有权,时间戳,如果可能的话 其他属性:context,links,xattr, 所有

-c已弃用,与--preserve = context相同

  --no-preserve = ATTR_LIST不保留指定的属性-- parents在DIRECTORY下使用完整的源文件名

递归复制-R,-r, - 递归复制目录

[root@server0 tmp]# cp -rp test1 test3
[root@server0 tmp]# cd test3
[root@server0 test3]# ls -al
total 8
drwxr-xr-x. 3 root root 64 Mar 5 10:13 .
drwxrwxrwt. 34 root root 4096 Mar 5 10:35 ..
-rw-r--r--. 1 root root 0 Mar 5 10:12 213123.txt
drwxr-xr-x. 2 root root 35 Mar 5 10:14 test2
lrwxrwxrwx. 1 root root 8 Mar 5 10:13 testfor -> testonly
-rw-r--r--. 1 root root 7 Mar 5 10:12 testonly

  --reflink [= WHEN]控制克隆/ CoW副本。见下文--remove-destination之前删除每个现有目标文件试图打开它(与--force对比)--sparse = WHEN控制稀疏文件的创建。见下文--strip-trailing-slashes从每个SOURCE中删除任何尾部斜杠争论

-s, - symbol-link制作符号链接而不是复制

[root@server0 tmp]# cp -s 6.txt 666

[root@server0 tmp]# ls -al 666
lrwxrwxrwx. 1 root root 5 Mar 5 10:37 666 -> 6.txt

-S, - stuff = SUFFIX覆盖通常的备份后缀(和-b一起使用)

[root@server0 tmp]# cp -b --suffix=exe 10.txt test1
cp: overwrite ‘test1/10.txt’? y
[root@server0 tmp]# cd test1
[root@server0 test1]# ls
10.txt 10.txtexe 213123.txt test2 testfor testonly

-t, -  target-directory = DIRECTORY将所有SOURCE参数复制到DIRECTORY中[root@server0 test1]# cp -t /tmp/test1 /tmp/19.txt

[root@server0 test1]# ls
10.txt 10.txtexe 19.txt 213123.txt test2 testfor testonly

-T, - no-target-directory将DEST视为普通文件
正常模式

-u, - 仅当SOURCE文件较新时才更新比目标文件或当目标文件丢失
(如果另一边文件更新就不进行覆盖)

[root@server0 test1]# echo 1212121 > 19.txt

[root@server0 test1]# cp -ut /tmp/test1 /tmp/19.txt
[root@server0 test1]# cat 19.txt
1212121

-v, - verbose解释正在做什么

[root@server0 test1]# echo 2323232323 >> /tmp/19.txt
[root@server0 test1]# cp -v /tmp/19.txt 19.txt

cp: overwrite ‘19.txt’? y
‘/tmp/19.txt’ -> ‘19.txt’
[root@server0 test1]# cat 19.txt
2323232323

-x, - one-file-system保留在此文件系统上

-Z, - context [= CTX]设置目的地的SELinux安全上下文文件为默认类型,如果指定则为CTX(保留安全上下文)

[root@server0 test1]# ls -Z 19.txt

-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 19.txt
[root@server0 test1]# cp -Z 19.txt /var/www/
[root@server0 test1]# ls -Z /var/www/19.txt
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/19.txt

  --help显示此帮助并退出--version输出版本信息并退出

命令7
rmdir

Remove the DIRECTORY(ies), if they are empty.
(移除目录,如果那个目录是空的)
--ignore-fail-on-non-empty

          ignore each failure that is solely because a directoryis non-empty-p, --parents(移除多级目录)remove  DIRECTORY  and  its ancestors; e.g., 'rmdir -p a/b/c' issimilar to 'rmdir a/b/c a/b a'

[root@server0 test1]# mkdir -p test1/test2/test3/test4
[root@server0 test1]# touch test1/test2/test3/123
[root@server0 test1]# rmdir -p test1/test2/test3
rmdir: failed to remove ‘test1/test2/test3’: Directory not empty
[root@server0 test1]# rm test1/test2/test3/123
rm: remove regular empty file ‘test1/test2/test3/123’? y
[root@server0 test1]# rmdir -p test1/test2/test3
rmdir: failed to remove ‘test1/test2/test3’: Directory not empty
[root@server0 test1]# rmdir -p test1/test2/test3/test4
[root@server0 test1]# rmdir -p test1/test2/test3/
rmdir: failed to remove ‘test1/test2/test3/’: No such file or directory

   -v, --verboseoutput a diagnostic for every directory processed--help display this help and exit

命令8
rm
rm - remove files or directories
(删除文件或文件夹 使用该命令需要谨慎)

OPTIONS(选项)
删除(取消链接)文件。

   -f, -  force忽略不存在的文件和参数,永远不会提示

[root@server0 test1]# ls
10.txt 10.txtexe 19.txt 213123.txt test2 testfor testonly
[root@server0 test1]# rm -f 10.txtexe
[root@server0 test1]# ls
10.txt 19.txt 213123.txt test2 testfor testonly

   -i 在每次删除之前提示alias rm='rm -i' 默认值

-I 在删除三个以上文件之前提示一次,或者在递归删除时提示;比-i更少侵入,同时仍然可以防止大多数错误

[root@server0 test3]# touch 1{2..9}.txt
[root@server0 test3]# ls
12.txt 13.txt 14.txt 15.txt 16.txt 17.txt 18.txt 19.txt
[root@server0 test3]# rm -I 1*
rm: remove 8 arguments? y

--interactive [= WHEN]
根据WHEN提示:从不,一次(-I)或总是(-i);
没有WHEN,总是提示

--one-file-system
在递归删除层次结构时,跳过文件系统上与目标命令行参数不同的任何目录

--no-preserve-root不要特别对待'/'--preserve-root不要删除'/'(默认)-r,-R, -  recursive以递归方式删除目录及其内容

[root@server0 test1]# mkdir -p test3/test4
[root@server0 test1]# touch test3/test4/1{2..9}.txt
[root@server0 test1]# rm -rf test3
[root@server0 test1]# ls
10.txt 19.txt 213123.txt test2 testfor testonly

   -d, -  dir删除空目录

[root@server0 test1]# mkdir testnull
[root@server0 test1]# rm testnull
rm: cannot remove ‘testnull’: Is a directory
[root@server0 test1]# rm -d testnull
rm: remove directory ‘testnull’? y

   -v, -  verbose解释正在做什么

[root@server0 test1]# rm -v 10.txt
rm: remove regular file ‘10.txt’? y
removed ‘10.txt’

   --help显示此帮助并退出

命令9
chmod

将每个文件的模式更改为MODE。
使用--reference,将每个FILE的模式更改为RFILE的模式。

(使用该命令时,可以先查询umask值)

-c, - 更改类似于详细信息,但仅在进行更改时报告

[root@server0 test1]# touch 10.txt

[root@server0 test1]# chmod -c 777 10.txt
mode of ‘10.txt’ changed from 0644 (rw-r--r--) to 0777 (rwxrwxrwx)
(#有一段提示信息)

-f, - silent, - quiet抑制大多数错误消息

[root@server0 test1]# chmod -f 755 10.txt

[root@server0 test1]# ls -al 10.txt
-rwxr-xr-x. 1 root root 0 Mar 5 16:33 10.txt

-v, - verbose为每个处理的文件输出诊断

[root@server0 test1]# chmod -v 722 10.txt

mode of ‘10.txt’ changed from 0755 (rwxr-xr-x) to 0722 (rwx-w--w-)

  --no-preserve-root不要特别处理'/'(默认值)--preserve-root无法在'/'上递归操作--reference = RFILE使用RFILE的模式而不是MODE值

-R, - 递归地递归更改文件和目录

[root@server0 test1]# mkdir testchmod
[root@server0 test1]# mkdir testchmod/chmod1{2..7}
[root@server0 testchmod]# touch {1..9}.txt
[root@server0 test1]# chmod -R 777 testchmod
[root@server0 test1]# ls -al
[root@server0 test1]# cd testchmod
[root@server0 testchmod]# ls -al
total 8
drwxrwxrwx. 8 root root 4096 Mar 5 16:55 .
drwxr-xr-x. 4 root root 4096 Mar 5 16:54 ..
-rwxrwxrwx. 1 root root 0 Mar 5 16:55 1.txt
-rwxrwxrwx. 1 root root 0 Mar 5 16:55 2.txt
-rwxrwxrwx. 1 root root 0 Mar 5 16:55 3.txt

  --help显示此帮助并退出--version输出版本信息并退出

命令10

setfacl

设置文件访问控制列表

用法:setfacl [-bkndRLP] {-m | -M | -x | -X ...}文件...

-m, - modify = acl修改文件的当前ACL(必须后面接属性)

@server0 tmp]# setfacl -m u:test1:rw 12

[root@server0 tmp]# getfacl 12
# file: 12<br/># owner: root
`# group: root
user::rwx
user:test1:rw-
group::r-x
mask::rwx
other::r-x

[root@server0 tmp]# setfacl -m g:test1:rwx 12
[root@server0 tmp]# getfacl 12
# file: 12<br/># owner: root
`# group: root
user::rwx
user:test1:rw-
group::r-x
group:test1:rwx
mask::rwx
other::r-x

-M, - modify-file = file读取要从文件修改的ACL条目

[root@server0 tmp]# touch 12222

[root@server0 tmp]# echo u:test2:rw > 12222
[root@server0 tmp]# setfacl -M /tmp/12222 12
[root@server0 tmp]# getfacl
[root@server0 tmp]# getfacl 12
`# file: 12<br/># owner: root
`# group: root
user::rwx
user:test1:rw-
user:test2:rw-
group::r-x
group:test1:rwx
mask::rwx
other::r-x

-x, - remove = acl从文件的ACL中删除条目

[root@server0 tmp]# setfacl -x g:test1 12 #只需要条目定义,不需要加文件读写执行属性
[root@server0 tmp]# getfacl
[root@server0 tmp]# getfacl 12
# file: 12<br/># owner: root
`# group: root
user::rwx
user:test1:rw-
user:test2:rw-
group::r-x
mask::rwx
other::r-x

-X, - remove-file = file读取要从文件中删除的ACL条目(不需要读写执行权限)

[root@server0 tmp]# setfacl -X /tmp/12222 12

setfacl: Invalid argument in line 1 of file /tmp/12222
[root@server0 tmp]# vim /tmp/12222
[root@server0 tmp]# setfacl -X /tmp/12222 12
[root@server0 tmp]# getfacl 12
·# file: 12
·# owner: root
·# group: root
user::rwx
user:test1:rw-
group::r-x
mask::rwx
other::r-x

-b, - remove-all删除所有扩展ACL条目

[root@server0 tmp]# getfacl  12

·# file: 12
·# owner: root
·# group: root
user::rwx
user:test1:rw-
user:test3:rw-
group::r-x
group:test1:rwx
group:test3:rwx
mask::rwx
[root@server0 tmp]# setfacl -b 12
[root@server0 tmp]# getfacl 12
·# file: 12
#· owner: root
·# group: root
user::rwx
group::r-x
other::r-x

-k, - remove-default删除默认ACL
[root@server0 tmp]# setfacl -d -m u:test1:rw 12
[root@server0 tmp]# getfacl 12
#· file: 12
#· owner: root
#· group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:test1:rw-
default:group::r-x
default:mask::rwx
default:other::r-x
[root@server0 tmp]# setfacl -k 12
[root@server0 tmp]# getfacl 12
#· file: 12
#· owner: root
#· group: root
user::rwx
group::r-x
other::r-x

  --set = acl设置文件的ACL,替换当前的ACL--set-file = file读取要从文件设置的ACL条目--mask会重新计算有效的权限掩码

-n, - no-mask不重新计算有效权限掩码
(需要查阅)

-d, - default操作适用于默认ACL

[root@server0 tmp]# setfacl -d -m u:test2:rw 12

[root@server0 tmp]# getfacl 12
·# file: 12
·# owner: root
·# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:test2:rw-
default:group::r-x
default:mask::rwx
default:other::r-x

-R, - 递归递归到子目录()

[root@server0 tmp]# mkdir -p test1/test2/test3

[root@server0 tmp]# setfacl -Rm u:test2:rw test1
[root@server0 tmp]# getfacl test1
·# file: test1
· owner: root
·# group: root
user::rwx
user:test2:rw-
group::r-x
mask::rwx
other::r-x[root@server0 tmp]# cd test1
[root@server0 test1]# getfacl -a test2
·# file: test2
·# owner: root
·# group: root
user::rwx
user:test2:rw-
group::r-x
mask::rwx
other::r-x

L, - 逻辑步行,遵循目录的符号链接。默认行为是遵循符号链接参数,并跳过子目录中遇到的符号链接。仅在与-R组合中有效。此选项不能与`--restore'混合使用。

[root@server0 tmp]# setfacl -R -L -m u:acltest1:rw test1
setfacl: test1/test2/test2use: No such file or directory
setfacl: test1/tssl/test2use: No such file or directory
[root@server0 tmp]# getfacl test1
·# file: test1
·# owner: root
·# group: root
user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x

[root@server0 tmp]# cd test1/
[root@server0 test1]# ls
10.txt 19.txt 213123.txt test2 testchmod testfor testonly tssl
[root@server0 test1]# getfacl tssl
·# file: tssl
·# owner: root
·# group: root
user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x

-P, - 物理
物理漫步,不要遵循目录的符号链接。这也会跳过符号链接参数。仅与-R组合有效。此选项不能与`--restore'混合使用。
[root@server0 tmp]# setfacl -R -P -m u:acltest1:rw test1
[root@server0 tmp]# getfacl test1
·# file: test1
·# owner: root
·# group: root
user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x

                 (就这样做出来了题目,然而我也没搞懂-LP之间的区别,也没有在谷歌上找到,望有识之士帮我补充)--restore =文件恢复ACL(与`getfacl -R'相反)- 测试模式(不修改ACL)

-v, - version print version并退出
-h, - 帮助这个帮助文本

命令11

getfacl

getfacl 2.2.51 - 获取文件访问控制列表
用法:getfacl [-aceEsRLPtpndvh]文件...

-a, - access仅显示文件访问控制列表

[root@server0 tmp]# setfacl -d -m u:acltest2:rwx test1

[root@server0 tmp]# getfacl -a test1
·# file: test1
·# owner: root
·# group: root
user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x

-d, - default仅显示默认访问控制列表

[root@server0 tmp]# getfacl -d test1

·# file: test1
·# owner: root
·# group: root
user::rwx
user:acltest2:rwx
group::r-x
mask::rwx
other::r-x

-c, - omom-header不显示注释标题

[root@server0 tmp]# getfacl -c test1

user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:user:acltest2:rwx
default:group::r-x
default:mask::rwx
default:other::r-x

[root@server0 tmp]# getfacl test1
·# file: test1
·# owner: root
·# group: root
user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:user:acltest2:rwx
default:group::r-x
default:mask::rwx
default:other::r-x

-e, - all-effective打印所有有效权利

[root@server0 tmp]# getfacl -e test1

·# file: test1
·# owner: root
·# group: root
user::rwx
user:acltest1:rw- #effective:rw-
group::r-x #effective:r-x
mask::rwx
other::r-x
default:user::rwx
default:user:acltest2:rwx #effective:rwx
default:group::r-x #effective:r-x
default:mask::rwx
default:other::r-x

-E, - 无效打印无效权利

oot@server0 tmp]# getfacl -E test1

·# file: test1
·# owner: root
·# group: root
user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:user:acltest2:rwx
default:group::r-x
default:mask::rwx
default:other::r-x

-s, - skip-skip跳过只有基本条目的文件

[root@server0 tmp]# getfacl -s test1

·# file: test1
·# owner: root
·# group: root
user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:user:acltest2:rwx
default:group::r-x
default:mask::rwx
default:other::r-x

-R, - 递归递归到子目录

[root@server0 tmp]# getfacl -R test1

·# file: test1
·# owner: root
·# group: root
user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:user:acltest2:rwx
default:group::r-x
default:mask::rwx
default:other::r-x

·# file: test1/test2
·# owner: root
·# group: root
user::rwx
user:acltest1:rw-
group::r-x
mask::rwx
other::r-x

-L, - 逻辑逻辑步行,遵循符号链接(意义尚且不明)

-P, - 物理步行,不要遵循符号链接

-t, - 表格使用表格输出格式

[root@server0 tmp]# getfacl -t test1

·# file: test1
USER root rwx rwx
user acltest1 rw-
user acltest2 rwx
GROUP root r-x r-x
mask rwx rwx
other r-x r-x

-n, - 数字打印数字用户/组标识符

-p, - 绝对名称不会在路径名中删除前导'/'

-v, - version print version并退出
-h, - 帮助这个帮助文本

命令12
pwd

pwd - 打印当前/工作目录的名称

概要
pwd [选项] ......

描述
打印当前工作目录的完整文件名。

   -L, - 逻辑使用环境中的PWD,即使它包含符号链接[root@server0 test1]# ls -al tssllrwxrwxrwx. 1 root root 5 Mar  6 09:37 tssl -> test2-P, - 物理避免所有符号链接--help显示此帮助并退出--version输出版本信息并退出

命令13
tree

tree- 以树状格式列出目录的内容

-------侦听选项-------
-a列出所有文件。

[root@server0 test1]# tree -a
.
├── 10.txt
├── 19.txt
├── 213123.txt
├── test2
│   ├── test123
│   ├── test2use -> test2
│   ├── test3
│   ├── test33
│   └── tssl2 -> test33
├── testchmod
│   ├── 1.txt
│   ├── 2.txt
│   ├── 3.txt
│   ├── 4.txt
│   ├── 5.txt
│   ├── 6.txt
│   ├── 7.txt
│   ├── 8.txt
│   ├── 9.txt
│   ├── chmod12
│   ├── chmod13
│   ├── chmod14
│   ├── chmod15
│   ├── chmod16
│   └── chmod17
├── testfor -> testonly
├── testonly
└── tssl -> test2

-d仅列出目录。
[root@server0 test1]# tree -d
.
├── test2
│   ├── test3
│   ├── test33
│   └── tssl2 -> test33
├── testchmod
│   ├── chmod12
│   ├── chmod13
│   ├── chmod14
│   ├── chmod15
│   ├── chmod16
│   └── chmod17
└── tssl -> test2

12 directories

-l遵循目录等符号链接。
[root@server0 test1]# tree -i
.
10.txt
19.txt
213123.txt
test2
test123
test2use -> test2
test3
test33
tssl2 -> test33
testchmod
1.txt
2.txt
3.txt
4.txt
5.txt
6.txt
7.txt
8.txt
9.txt
chmod12
chmod13
chmod14
chmod15
chmod16
chmod17
testfor -> testonly
testonly
tssl -> test2

12 directories, 16 files

-f打印每个文件的完整路径前缀。

[root@server0 test1]# tree -f

.
├── ./10.txt
├── ./19.txt
├── ./213123.txt
├── ./test2
│   ├── ./test2/test123
│   ├── ./test2/test2use -> test2
│   ├── ./test2/test3
│   ├── ./test2/test33
│   └── ./test2/tssl2 -> test33
├── ./testchmod
│   ├── ./testchmod/1.txt
│   ├── ./testchmod/2.txt
│   ├── ./testchmod/3.txt
│   ├── ./testchmod/4.txt
│   ├── ./testchmod/5.txt
│   ├── ./testchmod/6.txt
│   ├── ./testchmod/7.txt
│   ├── ./testchmod/8.txt
│   ├── ./testchmod/9.txt
│   ├── ./testchmod/chmod12
│   ├── ./testchmod/chmod13
│   ├── ./testchmod/chmod14
│   ├── ./testchmod/chmod15
│   ├── ./testchmod/chmod16
│   └── ./testchmod/chmod17
├── ./testfor -> testonly
├── ./testonly
└── ./tssl -> test2

-x仅保留当前文件系统。

-L level只降低级别目录深度。

-R当达到最大目录级别时重新运行树。

-P pattern仅列出与给定模式匹配的文件。

-I pattern不列出与给定模式匹配的文件。

--noreport在树列表末尾关闭文件/目录计数。

--charset X使用charset X进行终端/ HTML和缩进行输出。

--filelimit#不要在其中包含多于#个文件的dirs。

--timefmt <f>根据格式<f>打印和格式化时间。

-o filename输出到文件而不是stdout。

--du打印目录大小。
[root@server0 test1]# tree --du
.
├── [ 0] 10.txt
├── [ 11] 19.txt
├── [ 0] 213123.txt
├── [ 95] test2
│   ├── [ 0] test123
│   ├── [ 5] test2use -> test2
│   ├── [ 6] test3
│   ├── [ 6] test33
│   └── [ 6] tssl2 -> test33
├── [ 4132] testchmod
│   ├── [ 0] 1.txt
│   ├── [ 0] 2.txt
│   ├── [ 0] 3.txt
│   ├── [ 0] 4.txt
│   ├── [ 0] 5.txt
│   ├── [ 0] 6.txt
│   ├── [ 0] 7.txt
│   ├── [ 0] 8.txt
│   ├── [ 0] 9.txt
│   ├── [ 6] chmod12
│   ├── [ 6] chmod13
│   ├── [ 6] chmod14
│   ├── [ 6] chmod15
│   ├── [ 6] chmod16
│   └── [ 6] chmod17
├── [ 8] testfor -> testonly
├── [ 7] testonly
└── [ 5] tssl -> test2

    8354 bytes used in 12 directories, 16 files

--prune修剪输出中的空目录。

--------文件选项---------
-q将不可打印的字符打印为“?”。

-N按原样打印不可打印的字符。

-Q引用带双引号的文件名。

[root@server0 tmp]# tree -Q

.
├── "10.txt"
├── "122222.txt"
├── "1222.txt"
├── "123"
│   ├── "222.txt"

-p打印每个文件的保护。

[root@server0 tmp]# tree -p

.
├── [-rw-r--r--] 10.txt
├── [-rw-r--r--] 122222.txt
├── [-rw-r--r--] 1222.txt
├── [drwxr-xr-x] 123
│   ├── [-rw-r--r--] 222.txt
│   ├── [-rw-r--r--] 222.txt~

-u显示文件所有者或UID号。

[root@server0 tmp]# tree -u

.
├── [root ] 10.txt
├── [root ] 122222.txt
├── [root ] 1222.txt
├── [root ] 123
│   ├── [root ] 222.txt
│   ├── [root ] 222.txt~
│   ├── [root ] 223.txt23
│   ├── [root ] 225 -> 223.txt
│   ├── [root ] 226 -> /tmp/12.txt

-g显示文件组所有者或GID编号。

[root@server0 tmp]# tree -g

.
├── [root ] 10.txt
├── [root ] 122222.txt
├── [root ] 1222.txt
├── [root ] 123
│   ├── [root ] 222.txt

-s打印每个文件的大小(以字节为单位)。

[root@server0 tmp]# tree -s

.
├── [ 4] 10.txt
├── [ 0] 122222.txt
├── [ 0] 1222.txt
├── [ 4096] 123
│   ├── [ 0] 222.txt
│   ├── [ 16] 222.txt~

-h以更易读的方式打印尺寸。

[root@server0 tmp]# tree -h

.
├── [ 4] 10.txt
├── [ 0] 122222.txt
├── [ 0] 1222.txt
├── [4.0K] 123
│   ├── [ 0] 222.txt
│   ├── [ 16] 222.txt~
│   ├── [ 7] 223.txt23

--si与-h相似,但以SI单位(1000的幂)使用。

[root@server0 tmp]# tree --si

.
├── [ 4] 10.txt
├── [ 0] 122222.txt
├── [ 0] 1222.txt
├── [4.1k] 123
│   ├── [ 0] 222.txt
│   ├── [ 16] 222.txt~
│   ├── [ 7] 223.txt23

-D打印上次修改日期或(-c)状态更改。

[root@server0 tmp]# tree -D

.
├── [Feb 28 9:26] 10.txt
├── [Sep 1 2018] 122222.txt
├── [Mar 4 11:55] 1222.txt
├── [Mar 4 17:25] 123
│   ├── [Mar 4 15:08] 222.txt
│   ├── [Feb 28 18:04] 222.txt~

-F附加'/','=','*','@','|'或者按照ls -F的'>'。
--inodes打印每个文件的inode编号。

[root@server0 tmp]# tree --inodes

.
├── [20201256] 10.txt
├── [20203457] 122222.txt
├── [20203458] 1222.txt
├── [8846781] 123
│   ├── [20203460] 222.txt
│   ├── [8846783] 222.txt~
│   ├── [20203461] 223.txt23

--device打印每个文件所属的设备ID号。

[root@server0 tmp]# tree --device
.
├── [64769] 10.txt
├── [64769] 122222.txt
├── [64769] 1222.txt
├── [64769] 123
│   ├── [64769] 222.txt
│   ├── [64769] 222.txt~
│   ├── [64769] 223.txt23

-------排序选项-------
-v 按版本按字母数字排序文件。

[root@server0 tmp]# tree -v

.
├── 1.txt
├── 2.txt
├── 3.txt
├── 4.txt
├── 5.txt
├── 6.txt

-r按反向字母数字顺序对文件进行排序。

[root@server0 tmp]# tree -r

.
├── test1
│   ├── tssl -> test2
│   ├── testonly
│   ├── testfor -> testonly
│   ├── testchmod
│   │   ├── chmod17

-t按上次修改时间对文件进行排序。

[root@server0 tmp]# tree -tD

.
├── [Mar 6 17:42] systemd-private-Ch7K2O
│   └── [Mar 6 17:42] tmp
├── [Mar 6 17:42] systemd-private-K49UiR
│   └── [Mar 6 17:42] tmp
├── [Mar 6 17:41] systemd-private-RQSjJt
│   └── [Mar 6 17:41] tmp
├── [Mar 6 9:37] test1
│   ├── [Mar 6 9:40] test2
│   │   ├── [Mar 6 9:40] tssl2 -> test33
│   │   ├── [Mar 6 9:38] test33
│   │   ├── [Mar 6 9:36] test3
│   │   ├── [Mar 5 10:14] test2use -> test2
│   │   └── [Mar 5 10:13] test123

-c按上次状态更改时间对文件进行排序。

[root@server0 tmp]# tree -cD

.
├── [Mar 6 17:42] systemd-private-Ch7K2O
│   └── [Mar 6 17:42] tmp
├── [Mar 6 17:42] systemd-private-K49UiR
│   └── [Mar 6 17:42] tmp
├── [Mar 6 17:41] systemd-private-RQSjJt
│   └── [Mar 6 17:41] tmp
├── [Mar 6 10:55] test1
│   ├── [Mar 6 10:42] 10.txt
│   ├── [Mar 6 10:42] 19.txt

-U保持文件未排序。

[root@server0 tmp]# tree -U | head -n 20

.
├── systemd-private-yILolc
│   └── tmp
├── systemd-private-UpllOx
│   └── tmp
├── systemd-private-dKm1nw
│   └── tmp
├── systemd-private-2Fzohz
│   └── tmp
├── systemd-private-HJCqz6
│   └── tmp
├── systemd-private-usovJD
│   └── tmp
├── 567 -> 123

--dirsfirst列出文件前的目录(-U禁用)。

-------图形选项------

-i不要打印缩进线。

[root@server0 tmp]# tree -i | head -n 20

.
10.txt
122222.txt
1222.txt
123
222.txt
222.txt~
223.txt23
225 -> 223.txt
226 -> /tmp/12.txt
34.txt
35.txt
456

-A打印ANSI线条图形缩进线。

[root@server0 tmp]# tree -A | head -n 20

.
├── 10.txt
├── 122222.txt
├── 1222.txt
├── 123
│ ├── 222.txt
│ ├── 222.txt~
│ ├── 223.txt23
│ ├── 225 -> 223.txt
│ ├── 226 -> /tmp/12.txt
│ ├── 34.txt
│ ├── 35.txt
│ └── 456
│ └── 227.txt

-S使用ASCII图形缩进线打印。

[root@server0 tmp]# tree -S | head -n 20

.
��� 10.txt
��� 122222.txt
��� 1222.txt
��� 123
� ��� 222.txt
� ��� 222.txt~
� ��� 223.txt23
� ��� 225 -> 223.txt
� ��� 226 -> /tmp/12.txt

-n始终关闭着色(-C覆盖)。

[root@server0 tmp]# tree -n | head -n 20

.
├── 10.txt
├── 122222.txt
├── 1222.txt
├── 123
│   ├── 222.txt
│   ├── 222.txt~
│   ├── 223.txt23
│   ├── 225 -> 223.txt

-C始终打开着色。(会显示文件特有颜色)

[root@server0 tmp]# tree -C | head -n 20

.
├── 10.txt
├── 122222.txt
├── 1222.txt
├── 123
│   ├── 222.txt
│   ├── 222.txt~
│   ├── 223.txt23
│   ├── 225 -> 223.txt
│   ├── 226 -> /tmp/12.txt
│   ├── 34.txt
│   ├── 35.txt
│   └── 456

------- XML / HTML选项-------

-X打印出树的XML表示形式。

[root@server0 tmp]# tree -X | head -n 20

<?xml version="1.0" encoding="UTF-8"?>
<tree>
<directory name=".">
<file name="10.txt"></file>
<file name="122222.txt"></file>
<file name="1222.txt"></file>
<directory name="123">
<file name="222.txt"></file>
<file name="222.txt~"></file>
<file name="223.txt23"></file>
<link name="225" target="223.txt"></link>
<link name="226" target="/tmp/12.txt"></link>
<file name="34.txt"></file>
<file name="35.txt"></file>
<directory name="456">
<file name="227.txt"></file>
</directory>
</directory>
<file name="12.txt"></file>
<file name="13.txt"></file>

-H baseHREF使用baseHREF作为顶级目录打印出HTML格式。(结果不明)

-T string用字符串替换默认的HTML标题和H1标题。(结果不明)

--nolinks关闭HTML输出中的超链接。

----其他选择----

--version打印版本并退出。

--help打印用法和此帮助消息并退出。

命令14
find

find - 搜索目录层次结构中的文件

选项
-H,-L和-P选项控制符号链接的处理。
后面的命令行参数被视为文件的名称
或者要检查的目录,直到开始的第一个参数
- '或参数('或`!'。那个参数和以下任何一个
参数被认为是描述内容的表达式
搜索。如果没有给出路径,则使用当前目录。
如果没有给出表达式,则使用表达式-print(但是你
不管怎样,应该考虑使用-print0。

   本手册页面讨论表达式列表中的“选项”。这些选项控制查找的行为,但是直接指定在最后一个路径名之后。五个“真实”选项-H,-L,-P,-D和-O必须出现在第一个路径名之前(如果有的话)。一双dash  - 也可用于表示任何剩余的参数不是选项(尽管确保所有起点都以`./'开头如果在start列表中使用通配符,则“/”通常更安全点)。

选项 OPTIONS

   所有的选项都总是返回真值,它们总会被执行,除非放在表达式中执行不到的地方。因此,清楚起见,最好把它们放在表达式的开头部分。-daystart从当日起始时开始而不是从24小时之前,计算时间(for  -amin, -atime,-cmin, -ctime, -mmin, and -mtime)。-mtime   -n +n                #按文件更改时间来查找文件,-n指n天以内,+n指n天以前

-atime -n +n #按文件访问时间来查GIN: 0px">

-ctime -n +n #按文件创建时间来查找文件,-n指n天以内,+n指n天以前

[root@test tmp]# find /tmp -ctime -1 | head -n 10
/tmp
/tmp/.X11-unix
/tmp/.X11-unix/X0
/tmp/.font-unix
/tmp/.ICE-unix
/tmp/.ICE-unix/1495
/tmp/.ICE-unix/9789
/tmp/.esd-0
/tmp/.esd-0/socket
/tmp/systemd-private-0be8f39d207d487bb238e5e7c01c80c1-chronyd.service-eOxRDd

[root@test tmp]# find /tmp -ctime +1 | head -n 10
/tmp/.Test-unix
/tmp/.XIM-unix
/tmp/.ICE-unix/1486
/tmp/tracker-extract-files.0
/tmp/test111
/tmp/test111/test222
/tmp/test111/test222/123.txt

-depth 先处理目录的内容再处理目录本身。(加速搜素内容)

[root@test tmp]# find /tmp -depth | head -n 10
/tmp/.Test-unix
/tmp/.X11-unix/X0
/tmp/.X11-unix
/tmp/.XIM-unix
/tmp/.font-unix
/tmp/.ICE-unix/1486
/tmp/.ICE-unix/1495
/tmp/.ICE-unix/9789
/tmp/.ICE-unix
/tmp/.esd-0/socket

        -follow不检索符号链接。隐含了 -noleaf。-help, --help列出 find 的命令行用法的概要,然后退出。-maxdepth levels进入命令行参数指定的目录下层目录时,最深不超过levels(一个非负整数) 层。`-maxdepth 0' 意味着只在命令行参数指定的目录中执行测试和动作。

[root@test tmp]# find /tmp -maxdepth 1 -name "1"
/tmp/12.txt
/tmp/13.txt
/tmp/14.txt
/tmp/15.txt
/tmp/16.txt
/tmp/17.txt
/tmp/18.txt
/tmp/12sl
/tmp/13sl
/tmp/16hl
/tmp/19.txt
/tmp/17hl
[root@test tmp]# find /tmp -maxdepth 2 -name "1
"
/tmp/.ICE-unix/1486
/tmp/.ICE-unix/1495
/tmp/12.txt

   -mindepth levels不在levels(一个非负整数)层之内执行任何测试和动作。`-mindepth 1'意 味着处理所有的文件,除了命令行参数指定的目录中的文件。

[root@test tmp]# find /tmp -mindepth 2 -name "1"
/tmp/.ICE-unix/1486
/tmp/.ICE-unix/1495
/tmp/test1/12.txt
/tmp/test1/13.txt
/tmp/test1/14.txt
/tmp/test1/15.txt
/tmp/test1/16.txt
/tmp/test1/17.txt
/tmp/test1/18.txt
/tmp/test1/19.txt
/tmp/test111/test222/123.txt
[root@test tmp]# find /tmp -mindepth 3 -name "1
"
/tmp/test111/test222/123.txt

   -mount 不进入处于其它文件系统之上的目录。可以用-xdev代替,从而和一些其他版本的 find 兼容。

[root@test newdev]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
fd0
sda
├─sda1 xfs 93e6872d-44bc-42d4-880b-3937848b02cf /boot
├─sda2 LVM2_member dcdEeX-Z0yQ-YopF-0eWd-hK6c-46DB-ENNU24
│ ├─centos-root xfs 5a5aa0af-6042-4dfa-b92c-3a59931bc06e /
│ └─centos-swap swap e3b119ad-3c1d-46a5-83e1-af6ec9f72c9f [SWAP]
└─sda3 LVM2_member ReqJLX-uSgG-5Sr7-pCb0-QTOG-66nB-diNEIe
└─vgnew1-lvnew1 btrfs 001540a0-ce56-4584-b406-e47f3ad4f22a /newdev

[root@test newdev]# cd /newdev
[root@test newdev]# ls
1.txt

[root@test newdev]# find / -mount -name "1.txt"
/etc/1.txt
/tmp/1.txt

[root@test newdev]# find / -name "1.txt"
/etc/1.txt
/tmp/1.txt
/newdev/1.txt

(由于find命令会搜素不同系统分区,如果只想搜素find命令所在分区,就加入-mount指令,可以减少不必要的搜素)

   -noleaf不为“目录中子目录数量比硬连接数少2”这种假设做优化。这个选项在搜索那些不遵循UNIX文件系统链接约定的文件系统时用,比如CDROM,MS-DOS文件系统或AFS卷的加载点。在普通的UNIX文件系统中,每个目录至少有两个硬连接,它的名字和它       的'.'条目。另外,它的子目录(假如有)还会各有一个 '..' 链接到它。在find检索一个目录时,发现子目录数比它的连接数少二时,它就知道目录中的其他条目并非目录(而是目录树中的叶(`leaf')节点)。除非需要检索的是这个叶节点,否则没必要去处理它。这样可以带来很大的搜索速度提升。-version, --version打印find的版本号然后退出。

-xdev 不进入处于其他文件系统之上的目录。

测试 TESTS
数字参数可以这样给出:

   +n     是比 n 大,-n     是比 n 小,n      正好是 n 。-amin n对文件的最近一次访问是在 n 分钟之前。

[root@server0 tmp]# find /tmp -amin 1
/tmp
/tmp/systemd-private-ecKHdn

   -anewer file对文件的最近一次访问比 file 修改时间要晚。如果命令行中 -follow 在 -anewer 之前,(也只有在这种情况下) -anewer 会受 -follow 的影响。

[root@server0 tmp]# touch 2.txt
[root@server0 tmp]# touch 3.txt
[root@server0 tmp]# find /tmp -anewer 2.txt
/tmp/3.txt

   -atime n对文件的最近一次访问是在 n*24 小时之前。(最近一次文件访问在多少日之前)

[root@server0 tmp]# find /tmp -atime 1
/tmp/.ICE-unix/1129
/tmp/test1/12.txt

[root@server0 tmp]# find /tmp -atime 2
/tmp/.ICE-unix/1286
/tmp/.ICE-unix/1308
/tmp/12222

   -cmin n对文件状态的最近一次修改是在 n 分钟之前。[root@server0 tmp]# echo 222 >> 2.txt
[root@server0 tmp]# find /tmp -cmin 1

/tmp/2H
/tmp/2.txt

   -cnewer file对文件状态的最近一次修改比 file 修改时间要晚。如果命令行中 -follow 在 -cnewer 之前,(也只有在这种情况下) -cnewer 会受 -follow 的影响。[root@server0 tmp]# echo 222 >> 2.txt
[root@server0 tmp]# find /tmp -cnewer 3.txt

/tmp/2H
/tmp/2.txt

                -ctime n对文件状态的最近一次修改是在 n*24 小时之前。

[root@server0 tmp]# find /tmp -ctime 0
/tmp
/tmp/3.txt
[root@server0 tmp]# stat 3.txt
File: ‘3.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd01h/64769d Inode: 20198315 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-08 13:39:26.700552840 +0800
Modify: 2019-03-08 13:39:26.700552840 +0800
Change: 2019-03-08 13:39:26.700552840 +0800

   -empty 文件是空的普通文件或者空目录。[root@server0 tmp]# find /tmp -empty

/tmp/.XIM-unix
/tmp/.font-unix
/tmp/.Test-unix
/tmp/systemd-private-ecKHdn/tmp
/tmp/systemd-private-lAXhGU/tmp
/tmp/systemd-private-I7Y660/tmp
/tmp/systemd-private-KPPr9P/tmp
/tmp/13H

   -false 总是false。-fstype type文件处于  type  类型的文件系统之上。有效的文件系统类型在不同版本的Unix中是不同的;一些Unix中的不完全的文件系统类型列表是这样:ufs,  4.2,  4.3,  nfs,  tmp,  mfs, S51K, S52K.你可以用 -printf 加上 %F 指令来查看你的文件系统的类型。-gid n 文件的数字形式的组ID是 n。

[root@test tmp]# chgrp test2 12.txt
[root@test tmp]# chgrp test2 13.txt
[root@test tmp]# find / -gid 1507
find: ‘/proc/27265/task/27265/fd/5’: 没有那个文件或目录
find: ‘/proc/27265/task/27265/fdinfo/5’: 没有那个文件或目录
find: ‘/proc/27265/fd/6’: 没有那个文件或目录
find: ‘/proc/27265/fdinfo/6’: 没有那个文件或目录
/tmp/12.txt
/tmp/13.txt
/home/test2

[root@server0 tmp]# chgrp 1001 1.txt
[root@server0 tmp]# find /tmp -group 1001
/tmp/1.txt

   -group gname文件属于 gname (也允许使用数字形式的组ID).

[root@server0 tmp]# chgrp 1001 1.txt
[root@server0 tmp]# find /tmp -group test1
/tmp/1.txt

   -ilname pattern和 -lname 类似,但是匹配时是不区分大小写的。-iname pattern和 -name 类似,但是匹配时是不区分大小写的。例如,`fo*' and `F??' 模式与文件名 `Foo', `FOO', `foo', `fOo' 等等相匹配。

[root@test tmp]# find /tmp -iname test1
/tmp/test1
/tmp/Test1

   -inum n文件的 i 结点数是 n。(按inode号来说)

[root@test tmp]# ls -i | grep Test1
85 Test1
[root@test tmp]# find /tmp -inum 85
/tmp/Test1

   -ipath pattern和 -path 类似,但是匹配时是不区分大小写的。

[root@test tmp]# find /tmp -ipath /tmp/test1
/tmp/test1
/tmp/Test1
(需要绝对路径)

   -iregex pattern和 -regex 类似, 但是匹配时是不区分大小写的。

[root@test tmp]# touch /tmp/81397018-b84a-11e0-9d2a-001b77dc0bed.jpg
[root@test tmp]# find /tmp -regextype sed -regex ".*/[a-f0-9-]{36}.jpg"
/tmp/81397018-b84a-11e0-9d2a-001b77dc0bed.jpg
(#搬运自
https://stackoverflow.com/questions/6844785/how-to-use-regex-with-find-command

-links n
文件有 n 个链接。
touch 16.txt
ln 16.txt 16hl1
ln 16.txt 16hl2
ln 16.txt 16hl3
[root@test tmp]# find /tmp -links 5
/tmp/16hl3
/tmp/16.txt
/tmp/16hl
/tmp/16hl1
/tmp/16hl2

   -lname pattern文件是一个与pattern 匹配的符号链接。元字符不会对`/' 或 `.' 做特殊处理。-mmin n对文件数据的最近一次修改是在 n 分钟之前。

[root@test tmp]# echo 121212 >> 12.txt
[root@test tmp]# find /tmp -mmin 1
/tmp/12.txt

   -mtime n对文件数据的最近一次修改是在 n*24 小时之前。

[root@test tmp]# find /tmp -mtime 7
[root@test tmp]# find /tmp -mtime 6
/tmp/.ICE-unix/1495
/tmp/.ICE-unix/9789

   -name pattern基本的文件名(将路径去掉了前面的目录)与shell模式pattern相匹配。元字符(`*', `?', 还有`[]'  )  不会匹配文件名开头的`.'  。使用  -prune  来略过一个目录及其中的文件。查看  -path的描述中的范例。

[root@test tmp]# find /tmp -name 12.txt
/tmp/12.txt
/tmp/test1/12.txt

   -newer file对文件的最近一次修改比 file 修改时间要晚。如果命令行中 -follow 在 -newer 之前,(也只有在这种情况下) -newer 会受 -follow 的影响。

[root@test tmp]# echo 121121212 >> 12.txt
[root@test tmp]# echo 121121212 >> 13.txt
[root@test tmp]# find /tmp -newer 12.txt
/tmp/13.txt

   -nouser没有符合文件的数字形式的用户ID的用户。-nogroup没有符合文件的数字形式的组ID的组。

-path pattern
文件名与shell模式pattern相匹配。元字符不会对/' 或.' 做特殊处理。因此,例如:
find . -path './sr*sc'
如果存在 './src/misc' 的话,会将它打印出来。想要忽略一个完整的目录树,应当使用-prune 而不是检查目录树中所有的文件。例如:要跳过 'src/emacs'
目录和其中所有的文件和子目录,把其他找到的文件打印出来,应当这样:
find . -path './src/emacs' -prune -o -print

   -perm mode文件的权限位恰好是 mode (八进制或符号)。 Symbolic modes use mode 0 as a point of departure.

[root@test tmp]# mkdir test16
[root@test tmp]# chmod 770 test16
[root@test tmp]# find /tmp -perm 770
/tmp/test16

   -perm -mode(含有此设定的所有全限值)所有的权限位 mode 都被设置了的文件。

[root@test test16]# touch {1..6}.txt
[root@test test16]# chmod 750 1.txt
[root@test test16]# chmod 777 2.txt
[root@test test16]# chmod 772 3.txt
[root@test test16]# chmod 774 4.txt
[root@test test16]# chmod 771 5.txt
[root@test test16]# find /tmp/test16 -perm -007
/tmp/test16/2.txt
[root@test test16]# find /tmp/test16 -perm -002
/tmp/test16/2.txt
/tmp/test16/3.txt
[root@test test16]# find /tmp/test16 -perm -004
/tmp/test16/2.txt
/tmp/test16/4.txt
/tmp/test16/6.txt

-perm +mode
任何权限位 mode 被设置了的文件。

[root@test tmp]# find /tmp -perm +007
find: warning: you are using -perm +MODE'. The interpretation of-perm +omode' changed in findutils-4.5.11. The syntax -perm +omode' was removed in findutils-4.5.12, in favour of-perm /omode'.

   -regex pattern文件名与正则表达式 pattern 匹配。这是对整个路径的匹配,不是搜索文件。例如,要匹配名为`./fubar3' 的文件,可以使用正则表达式 `.*bar.' 或者 `.*b.*3',但是不能用`b.*r3'。-size n[bckw]文件使用了 n 单位个存储单元。默认的单位是512字节的块,也可以用n后面加上  `b'  来指定这个值。其他的单位是字节,如果在  n  后面加上  `c'  ;千字节(kB),如果在  n  后面加上`k';两字节的字,如果在 n 后面加上 `w' 。大小不会计入 indirect blocks,但是会计入没有真正分配空间的疏松文件中的块。

[root@test etc]# find /etc -size +8k -size -10k(大于8k 小于10k)
/etc/pki/nssdb/cert9.db
/etc/grub.d/00_header
/etc/dbus-1/system.d/org.freedesktop.login1.conf
/etc/xdg/autostart/gnome-keyring-pkcs11.desktop

   -true  总是true。-type c文件是 c 类型的。类型可取值如下:b      特殊块文件(缓冲的)

[root@test dev]# find / -type b
/dev/dm-2
/dev/dm-1
/dev/dm-0

             c      特殊字符文件(不缓冲)

[root@test dev]# find / -type c
/dev/vcsa6
/dev/vcs6
/dev/vcsa5

                        d      目录

[root@test dev]# find /tmp/test1 -type d
/tmp/test1
/tmp/test1/test12

          p      命名管道 (FIFO)

[root@test dev]# find / -type p | head -n 10
/run/dmeventd-client
/run/dmeventd-server
/run/systemd/inhibit/9.ref
/run/systemd/inhibit/7.ref
/run/systemd/inhibit/6.ref
/run/systemd/inhibit/5.ref
/run/systemd/inhibit/4.ref
/run/systemd/inhibit/2.ref
/run/systemd/inhibit/1.ref
/run/systemd/sessions/2.ref

                     f     普通文件

[root@test dev]# find / -type f | head -n 10
/boot/efi/EFI/centos/BOOT.CSV
/boot/efi/EFI/centos/BOOTX64.CSV
/boot/efi/EFI/centos/MokManager.efi
/boot/efi/EFI/centos/mmx64.efi
/boot/efi/EFI/centos/shim.efi
/boot/efi/EFI/centos/shimx64-centos.efi
/boot/efi/EFI/centos/shimx64.efi
/boot/efi/EFI/centos/fwupia32.efi
/boot/efi/EFI/centos/fwupx64.efi
/boot/efi/EFI/BOOT/BOOTX64.EFI

          l      符号链接

[root@test dev]# find /tmp -type l | head -n 10
/tmp/12sl
/tmp/13sl
/tmp/tss3sl
/tmp/test3sl
/tmp/tss33sl

          s      套接字

[root@test dev]# find / -type s | head -n 5
/dev/log
/run/mcelog-client
/run/abrt/abrt.socket
/run/NetworkManager/private-dhcp
/run/chrony/chronyd.sock

          D      门 (Solaris 特有)-uid n 文件的数字形式的用户ID是 n 。

test1:x:1506:1506::/home/test1:/bin/bash
test2:x:1507:1507::/home/test2:/bin/bash
saned:x:375:371:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
[root@test dev]# find / -uid 1506 | head -n 10
find: ‘/proc/21468/task/21468/fd/5’: 没有那个文件或目录
find: ‘/proc/21468/task/21468/fdinfo/5’: 没有那个文件或目录
find: ‘/proc/21468/fd/6’: 没有那个文件或目录
find: ‘/proc/21468/fdinfo/6’: 没有那个文件或目录
/var/spool/mail/test1
/home/test1

   -used n文件最后一次存取是在最后一次修改它的状态的 n 天之后。[root@test dev]# find /tmp -used 1

/tmp/.X11-unix/X0
/tmp/.ICE-unix/1486
/tmp/.ICE-unix/1495

            -user uname文件的所有者是 uname (也可以使用数字形式的用户ID).

[root@test dev]# find /tmp -user test1
/tmp/1111.txt
/tmp/222

-xtype c
和 -type 相同,除非文件是一个符号链接。对于符号链接:如果没有给出 -follow ,如果文件是一个指向 c 类型文件的链接,那么返回true;如果给出了 -follow ,如果 c 是 `l' 那么返回true。换句话说,对于符号链接,-xtype 检查那些 -type 不检查的文件。

动作 ACTIONS
-exec command ;
执行 command;如果命令返回状态值0,那么 exec 返回true。所有 find 其余的命令行参数将作为提供给命令的参数,直到遇到一个由 ;' 组成的参数为止。命令的参数中,字符串{}' 将以正在处理的文件名替换。所有的 {}' 都会被替换,不仅是在单独的一个参数中。有些版本的 find 不是这样做的。这些参数可能需要用\' 来escape 或者用括号括住,防止它们被shell展开。命令是从起始目录执行的。

[root@test tmp]# touch 1.txt
[root@test tmp]# touch 2.txt
[root@test tmp]# find /tmp -type f -name "?.txt" -exec rm -rf {} \; #建两个txt文件
并删除它
[root@test tmp]# ls
1111.txt

   -fls file返回true;类似 -ls 但是像 -fprint 那样写入 file。-fprint file返回true;将文件全名打印到文件    file    中。如果运行    find    时    file     不存在,那么它将被创建。如果它存在,它将被覆盖。文件名``/dev/stdout''     和``/dev/stderr''会作特殊处理;它们分别指的是标准输出和标准错误输出。-fprint0 file返回true;类似 -print0 但是像 -fprint 那样写入 file。-fprintf file format返回true;类似 -printf 但是像 -fprint 那样写入 file。-ok command ;类似 -exec 但是会先向用户询问 (在标准输入); 如果回应不是以 `y' 或 `Y' 起始则不会运行 command 而是返回false。-print 返回true;在标准输出打印文件全名,然后是一个换行符。(打印全路径)

[root@test tmp]# find /tmp -type d -perm 755 -print -exec chmod 644 {} \;

   -print0返回true;在标准输出打印文件全名,然后是一个null字符。这样可以使得处理 find 的输出的程序可以正确地理解带有换行符的文件名。

[root@test tmp]# find /tmp -print0 #不换行输出所有find内容的结果
/tmp/tmp/.Test-unix/tmp/.X11-unix/tmp/.X11-unix/X0/tmp/.XIM-unix/tmp/.font-unix/tmp/.ICE-unix/tmp/.ICE-unix/1486/tmp/.ICE-unix/1495/

    -printf format返回true;在标准输出打印    format    ,    解释    `\'    escape    还有    `%'   指令。字段宽度和精度可以像C函数   `printf'   那样来指定。与   -print   不同的是,   -printf 在字符串末端不会添加一个新行。可用的escape 和指令如下:\a     警告铃声\b     回退\c     立即停止以当前格式输出,刷新输出设备。\f     表格结束\n     新行\r     回车\t     水平tab\v     竖直tab\\     输出自身`\'\NNN   ASCII编码是NNN(八进制)的字符在一个 `\' 字符后面使用任何其他字符会被作为普通的字符,因此它们都会被打印出来。%%     输出自身`%'%a     文件最后一次存取的时间。格式是C函数 `ctime' 返回值的格式。

[root@test tmp]# find /tmp -printf '%s %p\n' | head -n 10
4096 /tmp
6 /tmp/.Test-unix
16 /tmp/.X11-unix
0 /tmp/.X11-unix/X0
6 /tmp/.XIM-unix
6 /tmp/.font-unix
90 /tmp/.ICE-unix

                        %Ak    文件最后一次存取的时间。格式以 k 指定,可以是 `@' 或者是C函数 `strftime' 的指令格式。下面列出了 k 可用的值;有一些并不是在所有系统上都可用,因为不同系统中 `strftime'也不同。@      从 Jan. 1, 1970, 00:00 GMT 起的秒数时间字段:H      小时 (00..23)I      小时 (01..12)k      小时 ( 0..23)l      小时 ( 1..12)M      分钟 (00..59)p      本地的 AM 或者 PMr      12小时格式的时间 (hh:mm:ss [AP]M)S      秒 (00..61)T      24小时格式的时间 (hh:mm:ss)X      本地的时间表示方法 (H:M:S)Z      时区(例如,EDT),如果不能决定时区就是空日期字段:a      本地一星期中每天的名称的缩写(Sun..Sat)A      本地一星期中每天的全名,可变长度 (Sunday..Saturday)b      本地每月的名称的缩写 (Jan..Dec)B      本地每月的全名,可变长度 (January..December)c      本地的日期和时间表示 (Sat Nov 04 12:02:33 EST 1989)d      一个月当中的日子 (01..31)D      日期 (mm/dd/yy)h      与 b 相同j      一年当中的日子 (001..366)m      月份 (01..12)U      以星期日作为每周起始,一年当中的星期 (00..53)w      一星期当中的日子 (0..6)W      以星期一当作每周起始,一年当中的星期 (00..53)x      本地的日期表示 (mm/dd/yy)y      年份的最后两位 (00..99)Y      年份 (1970...)

[root@test tmp]# find /tmp -printf '%s %p %AT\n' | head -n 10
8192 /tmp 18:27:08.5452416420
6 /tmp/.Test-unix 17:29:44.9237984530
16 /tmp/.X11-unix 09:57:17.5413560240
0 /tmp/.X11-unix/X0 09:45:48.0877671560
6 /tmp/.XIM-unix 17:29:44.9248011950
6 /tmp/.font-unix 09:57:17.5413560240
90 /tmp/.ICE-unix 09:57:17.5413560240

运算符 OPERATORS
以优先级高低顺序排列:

   ( expr )强制为优先! expr 如果 expr 是false则返回true-not expr与 ! expr 相同expr1 expr2与 (隐含的默认运算符);如果 expr1 为false则不会执行 expr2

[root@test tmp]# find /tmp -size -1b -size +10M -name ".txt"
[root@test tmp]# find /tmp -size +1b -size -10M -name "
.txt"
/tmp/test111/test222/123.txt

  expr1 -a expr2与 expr1 expr2 相同expr1 -and expr2与 expr1 expr2 相同expr1 -o expr2或;如果 expr1 为true 则不会执行 expr2(加了-o就会显示所有表达式各自执行出来可以显示的结果)

[root@test tmp]# find /tmp -size -1b -o -size +10M -name "*.txt"
/tmp/.X11-unix/X0
/tmp/.ICE-unix/1486
/tmp/.ICE-unix/1495

   expr1 -or expr2与 expr1 -o expr2 相同expr1 , expr2列表;expr1 和 expr2 都会被执行。expr1 的值被忽略,列表的值是 expr2的值                                       

命令15
cat

cat - 连接文件并在标准输出上打印

概要
猫[选项] ... [文件] ...

描述
将FILE(或标准输入)连接到标准输出。

   -A, -  show-all相当于-vET

[root@test tmp]# cat -A 1.txt
ewqeqweqwe$
qweqwdasdasd$
sadasdasdas$
xxcsasdasdas$

-b, - number-nonblank
number非空输出行,覆盖-n

[root@test tmp]# cat -b 1.txt
1 ewqeqweqwe
2 qweqwdasdasd
3 sadasdasdas
4 xxcsasdasdas
5 xczx
6 czxc
7 zx
8 czx
9 czx
10 c
11 zxc

12  qweqwewq-e相当于-vE

[root@test tmp]# cat -e 1.txt
ewqeqweqwe$
qweqwdasdasd$
sadasdasdas$
xxcsasdasdas$
xczx$
czxc$
zx$
czx$
czx$
c$
zxc$
$
$
$
$
qweqwewq$

   -E, -  show-ends在每行末尾显示$[root@test tmp]# cat -E 1.txt

ewqeqweqwe$
qweqwdasdasd$
sadasdasdas$
xxcsasdasdas$
xczx$
czxc$
zx$
czx$
czx$
c$
zxc$
$
$
$
$
qweqwewq$

-t相当于-vT

[root@test tmp]# cat -t 1.txt
ewqeqweqwe
qweqwdasdasd
sadasdasdas
xxcsasdasdas
xczx
czxc
zx
czx
czx
c
zxc

qweqwewq

   -T, -  show-tabs将TAB字符显示为^ I-u(忽略)-v, -  show-nonprinting使用^和M-表示法,LFD和TAB除外--help显示此帮助并退出--vision输出版本信息并退出如果没有FILE,或者FILE是 - ,则读取标准输入。

命令16
dd

dd - 转换和拷贝文件

描述
当进行非强制的转换的时候,使用指定的输入和输出块大小拷贝文件
(默认是从标准输入到标准输出。)

   它每次从输入读取指定大小的一个块(默认是512字节)。如果使用bs=bytes选项,并且没有转换,除了指定sync, noerror,或notrunc之外,那么dd将把全部读到的数据(可以比请求读的少)写到独立的输出块去。这个输出块的长度和读到的数据完全一样,除非指定使用sync(同步)转换,那样的话,数据结尾处将追加NUL字符(或空格,见下)。其他情况下,输入的时候每次读一个块,然后处理,并将输出结果收集起来,最后写到指定大小的数据块中去。最终的输出块可能会比指定的大小短一些。数字值选项(以字节或块为单位)后面可以跟一个乘数:

k=1024,b=512,w=2,c=1(w和c是GNU扩展语法。最好别使用w,因为在system V中,它表示2,在4.2 BSD中,它表示4)。两个或更多的数值表达式可以通过“x”乘起来。GEU fileutils 4.0并且允许在数据块大小的叙述中使用

   下列乘法后缀(用bs=,cbs=,obs=):M=1048576,G=1073741824,同理可得T,P,E,Z,Y。D后缀表示数值是以十进制表示的:kD=1000,MD=1000000,GD=1000000000等等。(注意,在ls、df、du命令中,M等标记的大小是由环境变量确定的,而在DD中,它的值是固定的。)

选项
if=file
从 file 中读而不是标准输入。

   of=file写到 file 里去而不是标准输出。除非指定 conv=notrunc  ,否则,  dd  将把file 截为O字节(或由 seek= 选项指定的大小)

例1,备份整个硬盘

dd if = /dev/sda of = /dev/sdb

例2,将/dev/sda全盘数据备份到指定路径的image文件

dd if=/dev/sda of=/path/to/image

dd if = /dev/ssda of = ~/sdadisk.img

例3,将备份镜像文件恢复到指定盘

dd if=/path/to/image of=/dev/sda

dd if = sdadisk.img of = /dev/sdb

例4,备份/dev/hdx全盘数据,并利用gzip工具进行压缩,保存到指定路径

dd if=/dev/hdb | gzip > /root/image.gz

例5,将压缩的备份文件恢复到指定盘

gzip -dc /root/image.gz | dd of=/dev/

   ibs=bytes一次读 bytes 字节。默认是512。

[root@test tmp]# dd if=/dev/zero of=123456.txt ibs=1024 count=1
记录了1+0 的读入
记录了2+0 的写出
1024字节(1.0 kB)已复制,0.000514843 秒,2.0 MB/秒

obs=bytes
一次写 bytes 字节。默认是512。

[root@test tmp]# dd if=/dev/zero of=123456.txt obs=1024 count=1
记录了1+0 的读入
记录了0+1 的写出
512字节(512 B)已复制,0.000800044 秒,640 kB/秒

   bs=bytes一次读和写  bytes  字节。这将覆盖  ibs  和  obs 设定的值(并且,设定 bs不等于同时将 ibs 和 obs 设为同一个值,至少在 只使用  sync,  noerror  or notrunc      转换时是这样的。因为bs规定,每个输入块都应作为单独的数据块拷贝到输出,而不把较短的块组合到一起)。例6,备份磁盘开始的512个字节大小的MBR信息到指定文件:

dd if=/dev/sda of=/root/image count=1 bs=512

[root@test tmp]# dd if=/dev/zero of=123456.txt bs=1024 count=1
记录了1+0 的读入
记录了1+0 的写出
1024字节(1.0 kB)已复制,0.000682695 秒,1.5 MB/秒

   cbs=bytes为 block 转换和 unblock 转换指定转换块的大小。

[root@test tmp]# dd if=/dev/zero of=123456.txt cbs=1024 count=1
记录了1+0 的读入
记录了1+0 的写出
512字节(512 B)已复制,0.000819904 秒,624 kB/秒

            skip=blocks在拷贝之前,跳过输入文件的前 blocks 块,每块大小为 ibs-byte 字节。

[root@test tmp]# dd if=/dev/zero of=123456.txt skip=1024 count=1
记录了1+0 的读入
记录了1+0 的写出
512字节(512 B)已复制,0.000545457 秒,939 kB/秒

   seek=blocks在拷贝之前,跳过输出文件的前 blocks 块,每块大小为 obs-byte 字节。

[root@test tmp]# dd if=/dev/zero of=123456.txt seek=1024 count=1
记录了1+0 的读入
记录了1+0 的写出
512字节(512 B)已复制,0.000356572 秒,1.4 MB/秒

count=blocks只拷贝输入文件的前  blocks 块(每块的大小为  ibs-byte字节),而不是全部内容,直到文件末尾。(复制的块的数量)

[root@test tmp]# dd if=/dev/zero of=123456.txt bs=1024 count=3
记录了3+0 的读入
记录了3+0 的写出
3072字节(3.1 kB)已复制,0.000492789 秒,6.2 MB/秒
[root@test tmp]# dd if=/dev/zero of=123456.txt bs=1024 count=4
记录了4+0 的读入
记录了4+0 的写出
4096字节(4.1 kB)已复制,0.000545623 秒,7.5 MB/秒
[root@test tmp]# dd if=/dev/zero of=123456.txt bs=1024 count=10
记录了10+0 的读入
记录了10+0 的写出
10240字节(10 kB)已复制,0.000606515 秒,16.9 MB/秒

   conv=转换"[,"转换"]..."将文件按 转换 参数指定的方式转换(在“,”两边没有空格)。转换方式包括:ascii  将EBCDIC转换成ascii。ebcdic 将ascii转换成ebcdic。ibm    将ascii转换成alternative ebcdic。block  每一行输入,无论长短,输出都是  cbs 字节,并且其中的“换行”(NEW‐LINE,即c中的'0)用 空格替换。如有必要,行尾会填充空格。unblock用“换行”替换每个输入块( cbs 字节大小)末尾的空格。lcase  将大写字母转换成小写。ucase  将小写字母转换成大写。swab   交换每对输入字节。如果读入的字节数是奇数,最后一个字节只是简单的复制到输出(因为没有能跟它交换的字节了)(POSIX 1003.26,PASC翻译1003.2 3号和4号)。noerror发生读错误时,继续进行。

dd if = /dev/sda of = /dev/sdb conv=noerror, sync

          notrunc不截断输出文件。sync   用0填充到每个输入块的末尾,使其大小为 ibs 字节。             

dd if = /dev/sda of = /dev/sdb conv=noerror, sync

命令17
stat
stat - 打印信息节点(inode)内容

[root@test tmp]# stat 1.txt
文件:"1.txt"
大小:99 块:8 IO 块:4096 普通文件
设备:fd00h/64768d Inode:8388674 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:user_tmp_t:s0
最近访问:2019-03-15 11:02:00.154094204 +0800
最近更改:2019-03-15 11:01:57.901921274 +0800
最近改动:2019-03-15 11:01:57.901921274 +0800
创建时间:-

命令18
scp
scp — 安全复制(远程文件复制程序)

命令参数:

-1 强制scp命令使用协议ssh1 (两边协议需要一致)

[root@server0 tmp]# scp -1 /tmp/1.txt root@desktop0:/tmp
Protocol major versions differ: 1 vs. 2
lost connection

-2 强制scp命令使用协议ssh2

[root@server0 tmp]# scp -2 /tmp/1.txt root@desktop0:/tmp
root@desktop0's password:
1.txt 100% 0 0.0KB/s 00:00

-4 强制scp命令只使用IPv4寻址

默认就是4

-6 强制scp命令只使用IPv6寻址

-B 使用批处理模式(传输过程中不询问传输口令或短语)

-C 允许压缩。(将-C标志传递给ssh,从而打开压缩功能)

[root@server0 tmp]# scp -r -C /tmp/test1 root@desktop0:/tmp
root@desktop0's password:
123.txt 100% 0 0.0KB/s 00:00
1.txt 100% 0 0.0KB/s 00:00
2.txt 100% 0 0.0KB/s 00:00
3.txt 100% 0 0.0KB/s 00:00

-p 保留原文件的修改时间,访问时间和访问权限。

[root@desktop0 test3]# stat 123.txt
File: ‘123.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd01h/64769d Inode: 20201539 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-16 17:36:15.434797243 +0800
Modify: 2019-03-16 17:38:30.679797243 +0800
Change: 2019-03-16 17:38:30.679797243 +0800
Birth: -
[root@server0 tmp]# scp -r -p /tmp/test1 root@desktop0:/tmp

123.txt 100% 0 0.0KB/s 00:00
[root@server0 test3]# stat 123.txt
File: ‘123.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd01h/64769d Inode: 1566795 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-16 17:13:27.509389615 +0800
Modify: 2019-03-16 17:13:27.509389615 +0800
Change: 2019-03-16 17:13:27.509389615 +0800
Birth: -
[root@server0 test3]# scp -r -p /tmp/test1 root@desktop0:/tmp
root@desktop0's password:
123.txt 100% 0 0.0KB/s 00:00

[root@desktop0 test3]# stat 123.txt
File: ‘123.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd01h/64769d Inode: 27915005 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-03-16 17:13:27.000000000 +0800
Modify: 2019-03-16 17:13:27.000000000 +0800
Change: 2019-03-16 17:42:22.466797243 +0800
Birth: -

-q 不显示传输进度条。

[root@server0 test3]# scp -r -q /tmp/test1 root@desktop0:/tmp
root@desktop0's password:
[root@server0 test3]#

-r 递归复制整个目录。

[root@server0 tmp]# mkdir -p /tmp/test1/test2/test3
[root@server0 tmp]# touch /tmp/test1/test2/test3/123.txt
[root@server0 tmp]# scp -r /tmp/test1 root@desktop0:/tmp
root@desktop0's password:
123.txt 100% 0 0.0KB/s 00:00

[root@desktop0 test1]# tree
.
├── test2
│   └── test3
│   └── 123.txt

-v 详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接,验证和配置问题。

[root@server0 tmp]# scp -rv /tmp/test1 root@desktop0:/tmp
Executing: program /usr/bin/ssh host desktop0, user root, command scp -v -r -t /tmp
OpenSSH_6.4, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 51: Applying options for *
debug1: Connecting to desktop0 [172.25.0.10] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0

-c cipher 以cipher将数据传输进行加密,这个选项将直接传递给ssh。

-F ssh_config 指定一个替代的ssh配置文件,此参数直接传递给ssh。

-i identity_file 从指定文件中读取传输时使用的密钥文件,此参数直接传递给ssh。

-l limit 限定用户所能使用的带宽,以Kbit/s为单位。

[root@server0 tmp]# scp -r -l 10 /tmp/test1 root@desktop0:/tmp
root@desktop0's password:
Permission denied, please try again.
root@desktop0's password:
123.txt 100% 0 0.0KB/s 00:00
1.txt 100% 0 0.0KB/s 00:00
2.txt 100% 0 0.0KB/s 00:00
3.txt 100% 0 0.0KB/s 00:00

-o ssh_option 如果习惯于使用ssh_config(5)中的参数传递方式,

-P port 注意是大写的P, port是指定数据传输用到的端口号

[root@server0 tmp]# scp -r -P 10000 /tmp/test1 root@desktop0:/tmp
ssh: connect to host desktop0 port 10000: No route to host
lost connection
[root@server0 tmp]# scp -r -P 22 /tmp/test1 root@desktop0:/tmp #ssh默认端口22
root@desktop0's password:
123.txt 100% 0 0.0KB/s 00:00
1.txt 100% 0 0.0KB/s 00:00
2.txt 100% 0 0.0KB/s 00:00

-S program 指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项。

命令20

wget Wget - 非交互式网络下载工具

总览

wget [选项]… [URL]…

描述

GNU Wget是一个用于在Web上下载文件的非交互式免费工具,支持HTTP,HTTPS和FTP协议,以及HTTP代理的方式。

(其余暂缺)

选项

启动:

-V, –version 显示 Wget 的版本并且退出。

-h, –help 打印此帮助。

-b, -background 启动后进入后台操作。

-e, -execute=COMMAND 运行‘.wgetrc’形式的命令。

日志记录及输入文件:

-o, –output-file=文件 将日志消息写入到指定文件中。

-a, –append-output=文件 将日志消息追加到指定文件的末端。

-d, –debug 打印调试输出。

-q, –quiet 安静模式(不输出信息)。

-v, –verbose 详细输出模式(默认)。

-nv, –non-verbose 关闭详细输出模式,但不进入安静模式。

-i, –input-file=文件 下载从指定文件中找到的 URL。

-F, –force-html 以 HTML 方式处理输入文件。

-B, –base=URL 使用 -F -i 文件选项时,在相对链接前添加指定的 URL。

下载:

-t, –tries=次数 配置重试次数(0 表示无限)。

–retry-connrefused 即使拒绝连接也重试。

-O –output-document=文件 将数据写入此文件中。

-nc, –no-clobber 不更改已经存在的文件,也不使用在文件名后

添加 .#(# 为数字)的方法写入新的文件。

-c, –continue 继续接收已下载了一部分的文件。

–progress=方式 选择下载进度的表示方式。

-N, –timestamping 除非远程文件较新,否则不再取回。

-S, –server-response 显示服务器回应消息。

–spider 不下载任何数据。

-T, –timeout=秒数 配置读取数据的超时时间 (秒数)。

-w, –wait=秒数 接收不同文件之间等待的秒数。

–waitretry=秒数 在每次重试之间稍等一段时间 (由 1 秒至指定的 秒数不等)。

–random-wait 接收不同文件之间稍等一段时间(由 0 秒至 2*WAIT 秒不等)。

-Y, –proxy=on/off 打开或关闭代理服务器。

-Q, –quota=大小 配置接收数据的限额大小。

–bind-address=地址 使用本机的指定地址 (主机名称或 IP) 进行连接。

–limit-rate=速率 限制下载的速率。

–dns-cache=off 禁止查找存于高速缓存中的 DNS。

–restrict-file-names=OS 限制文件名中的字符为指定的 OS (操作系统) 所允许的字符。

目录:

-nd –no-directories 不创建目录。

-x, –force-directories 强制创建目录。

-nH, –no-host-directories 不创建含有远程主机名称的目录。

-P, –directory-prefix=名称 保存文件前先创建指定名称的目录。

–cut-dirs=数目 忽略远程目录中指定数目的目录层。

HTTP 选项:

–http-user=用户 配置 http 用户名。

–http-passwd=密码 配置 http 用户密码。

-C, –cache=on/off (不)使用服务器中的高速缓存中的数据 (默认是使用的)。

-E, –html-extension 将所有 MIME 类型为 text/html 的文件都加上 .html 扩展文件名。

–ignore-length 忽略“Content-Length”文件头字段。

–header=字符串 在文件头中添加指定字符串。

–proxy-user=用户 配置代理服务器用户名。

–proxy-passwd=密码 配置代理服务器用户密码。

–referer=URL 在 HTTP 请求中包含“Referer:URL”头。

-s, –save-headers 将 HTTP 头存入文件。

-U, –user-agent=AGENT 标志为 AGENT 而不是 Wget/VERSION。

–no-http-keep-alive 禁用 HTTP keep-alive(持久性连接)。

–cookies=off 禁用 cookie。

–load-cookies=文件 会话开始前由指定文件载入 cookie。

–save-cookies=文件 会话结束后将 cookie 保存至指定文件。

–post-data=字符串 使用 POST 方法,发送指定字符串。

–post-file=文件 使用 POST 方法,发送指定文件中的内容。

HTTPS (SSL) 选项:

–sslcertfile=文件 可选的客户段端证书。

–sslcertkey=密钥文件 对此证书可选的“密钥文件”。

–egd-file=文件 EGD socket 文件名。

–sslcadir=目录 CA 散列表所在的目录。

–sslcafile=文件 包含 CA 的文件。

–sslcerttype=0/1 Client-Cert 类型 0=PEM (默认) / 1=ASN1 (DER)

–sslcheckcert=0/1 根据提供的 CA 检查服务器的证书

–sslprotocol=0-3 选择 SSL 协议;0=自动选择,

1=SSLv2 2=SSLv3 3=TLSv1

FTP 选项:

-nr, –dont-remove-listing 不删除“.listing”文件。

-g, –glob=on/off 设置是否展开有通配符的文件名。

–passive-ftp 使用“被动”传输模式。

–retr-symlinks 在递归模式中,下载链接所指示的文件(连至目录

则例外)。

递归下载:

-r, –recursive 递归下载。

-l, –level=数字 最大递归深度(inf 或 0 表示无限)。

–delete-after 删除下载后的文件。

-k, –convert-links 将绝对链接转换为相对链接。

-K, –backup-converted 转换文件 X 前先将其备份为 X.orig。

-m, –mirror 等效于 -r -N -l inf -nr 的选项。

-p, –page-requisites 下载所有显示完整网页所需的文件,例如图像。

–strict-comments 打开对 HTML 备注的严格(SGML)处理选项。

递归下载时有关接受/拒绝的选项:

-A, –accept=列表 接受的文件样式列表,以逗号分隔。

-R, –reject=列表 排除的文件样式列表,以逗号分隔。

-D, –domains=列表 接受的域列表,以逗号分隔。

–exclude-domains=列表 排除的域列表,以逗号分隔。

–follow-ftp 跟随 HTML 文件中的 FTP 链接。

–follow-tags=列表 要跟随的 HTML 标记,以逗号分隔。

-G, –ignore-tags=列表 要忽略的 HTML 标记,以逗号分隔。

-H, –span-hosts 递归时可进入其它主机。

-L, –relative 只跟随相对链接。

-I, –include-directories=列表 要下载的目录列表。

-X, –exclude-directories=列表 要排除的目录列表。

-np, –no-parent 不搜索上层目录。

栗子1:下载文件到指定目录

wget -o /tmp/GPL http://cla***oom.example.com/content/rhel7.0/x86_64/dvd/GPL

栗子2:递归下载到指定目录

wget -r /tmp/img/ http://cla***oom.example.com/content/rhel7.0/x86_64/dvd/images/

栗子3:断点续传

wget -c /tmp/img/ http://cla***oom.example.com/content/rhel7.0/x86_64/dvd/images/

栗子4:限速下载

[root@desktop0 tmp]# wget --limit-rate=200k /tmp/img/ http://cla***oom.example.com/content/rhel7.0/x86_64/dvd/images/
/tmp/img/: Scheme missing.
--2019-03-18 10:07:23-- http://cla***oom.example.com/content/rhel7.0/x86_64/dvd/images/
Resolving cla***oom.example.com (cla***oom.example.com)... 172.25.254.254
Connecting to cla***oom.example.com (cla***oom.example.com)|172.25.254.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1395 (1.4K) [text/html]
Saving to: ‘index.html’

100%[======================================>] 1,395 --.-K/s in 0s

2019-03-18 10:07:23 (168 MB/s) - ‘index.html’ saved [1395/1395]

栗子5:使用wget -b后台下载
[root@desktop0 tmp]# wget -ob /tmp/GGG http://cla***oom.example.com/content/rhel7.0/x86_64/dvd/GPL

使用命令行展开功能,创建/tmp/a1, /tmp/a2, /tmp/a1/a, /tmp/a1/b,在/tmp目录下创建目录:x_y, x_z, q_y, q_z

[root@desktop0 tmp] #mkdir -p a{1/{a,b},2}
[root@desktop0 tmp]# mkdir -p {x,q}{_y,_z}
[root@desktop0 tmp]# ls

复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。

find /etc -name p*[^[:digit:]] -exec cp -avr {} /tmp/mytest1 \;

创建用户tom,指定UID为5001,指定家目录为/tmp/tom, 指定shell为/bin/zsh, 指定基本组为tom,附加组为jack

[root@centos7 ~]# useradd -u 5001 -s /bin/zsh -d /tmp/tom -G jack tom
useradd: user 'tom' already exists
[root@centos7 ~]# cat /etc/passwd
tom:x:5001:5001::/tmp/tom:/bin/zsh

重要参考:

https://www.cnblogs.com/analyzer/archive/2010/05/04/1727438.html

https://superuser.com/questions/593196/cp-h-vs-cp-l-what-is-a-command-line-symbolic-link

https://www.cnblogs.com/MLibra/p/6240209.html

https://www.cnblogs.com/yorkyang/p/6294894.html

http://www.cnblogs.com/peida/archive/2013/03/18/2965369.html

转载于:https://blog.51cto.com/micself/2364433

linux命令及使用技巧 week2相关推荐

  1. linux 命令行使用技巧linux 下的文件管理

    ##1.什么是linux### linux 是指Linux内核 内核               ##系统的核心程序 ##相当于人的大脑 #负责系统程序和硬件分配及调度 ##2.什么是shell## ...

  2. Linux命令行使用技巧

    1.什么是Linux Linux操作系统          GUN/Linux GUN是开源组织 Linux是指Linux内核 内核                          系统核心程序 相 ...

  3. 分享一些Linux命令实用小技巧,欢迎评论区补充

    1.Tab自动补全:在Linux下,命令记得不清楚,你可以只打命令的前几个字符,然后敲击两次TAB键来补齐命令的全称,如果有重复的,那么Linux会把其列出来. 2.无所不能的man:所有的命令作用你 ...

  4. 【linux基础1】linux命令行使用技巧

    Linux的命令行 一.linux操作系统 一.操作系统 二.内核 三.shell定义 二.shell的使用 一.shell的打开方式 二.shell命令行提示符 三.shell快捷键的使用+ ##取 ...

  5. Linux 命令行小技巧《叹号的用处》

    bash 的历史记录里保留了输入的命令行记录.以下是如何充分利用该记录和!符号的使用教程. history的基础 HISTSIZE 变量值设置保存在历史列表中的命令数.默认情况下,该值为 500.这些 ...

  6. 20个超高效的Linux命令与技巧

    简介:这里有一些很有用的 Linux 命令,终端技巧和快捷方式,可以在使用Linux命令行时节省大量时间. 在本文中,我将向您演示一些专业的Linux命令技巧,这些技巧将使您节省大量时间,在某些情况下 ...

  7. 20个提高生产力的 Linux 命令与技巧,用完带你起飞

    简介:这里有一些很有用的Linux命令,终端技巧和快捷方式,可以在使用Linux命令行时节省大量时间. 在本文中,我将向您演示一些专业的Linux命令技巧,这些技巧将使您节省大量时间,在某些情况下还可 ...

  8. Linux命令学习资料总结

    对 Linux 新手非常有用的 20 个命令 1. ls命令 ls命令是列出目录内容(List Directory Contents)的意思.运行它就是列出文件夹里的内容,可能是文件也可能是文件夹. ...

  9. linux保存动态进程信息,Linux 命令 - top: 动态显示进程信息

    命令格式 top -hv | -abcHimMsS -d delay -n iterations -p pid [, pid ...] 命令参数 -a 根据内存的使用排序. -b 以批处理模式操作. ...

最新文章

  1. 算法和数据结构c语言源代码,【资料分享】 数据结构与算法全集(C源代码+详细注释)!...
  2. 2020 我的C++学习之路 C++PrimerPlus第四章课后习题
  3. 如何通过 C# kill 指定进程?
  4. struct类型重定义 不同的基类型_C++构造数据类型
  5. css3宽度变大动画_动画演示流量计的工作原理
  6. goland gorm分组查询统计_golang gorm 计算字段和获取sum()值的实现
  7. 【个人项目总结】四则运算生成器
  8. 论文赏析[TACL18]隐式句法树模型真的能学到句子中有意义的结构吗?
  9. android自定义sufaceview,Android自定义SurfaceView实现画板功能
  10. 概率论基础知识(书本摘录总结)
  11. 免费的Access数据库员工管理系统下载-IT技术网站 企业人员管理系统源码
  12. 笛卡尔心形函数表达式_如何用几何画板画笛卡尔心形函数
  13. SpaceX星链技术取代不了5G,但会让打仗变成打游戏
  14. java中竖线怎么画_java split | (竖线)
  15. 在手机与计算机之间进行文件传输的方式,电脑和手机传输文件方法_电脑和手机如何传文件-win7之家...
  16. 互联网企业的盈利模式
  17. logstash问题记录:Attempted to resurrect connection to dead ES instance, but got an error
  18. mui.fire运用
  19. 悲情的AI四小龙,背后不是专利无用
  20. Fedora 安装字体

热门文章

  1. 智能AI文章写作伪原创-免费API接口
  2. 联想服务器的系统安装教程视频教程,联想服务器装linux系统怎么安装教程
  3. 转换器max1166相关文章
  4. 计算机软件比硬件特性,硬件工程师笔试及面试问题
  5. 理光打印机Ricoh_MP_C2003_C2503_Pcl6祥闰内部打印机安装使用教程
  6. OceanBase-安装
  7. 探究:光伏电站三大并网模式哪个更适合你?
  8. 推荐一个好用的免费开源的笔记本软件CherryTree
  9. 数据安全与数据备份存储技术(转)
  10. 利用python爬取电影天堂搜索部分,并利用pyqt可视化