1. shutdown
选项:
-h
-r
-c
案例:
[root@centos ~]
[root@centos ~]
Shutdown scheduled for Thu 2019-11-28 18:00:00 CST, use 'shutdown -c' to cancel.
[root@centos ~]
[root@centos ~]
Broadcast message from root@centos (Thu 2019-11-28 16:08:19 CST):
The system shutdown has been cancelled at Thu 2019-11-28 16:09:19 CST!
[root@centos ~]
Shutdown scheduled for Thu 2019-11-28 18:00:00 CST, use 'shutdown -c' to cancel.
2. poweroff
3. halt
选项:
-p
4. init
0 关机
6 重启
5. reboot
6. logout
[root@centos ~]
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(模板机) at 16:11:11.
Type `help' to learn how to use Xshell prompt.
[E:\~]$
7. exit
[root@centos ~]
logout
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(模板机) at 16:10:41.
Type `help' to learn how to use Xshell prompt.
[E:\~]$
8. clear
9.显示命令帮助信息
man
[root@centos ~]
[root@centos ~]
help
[root@centos ~]
[root@centos ~]
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.
Mandatory arguments to long options are mandatory for short options too.
-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
[root@centos ~]
help: help [-dms] [pattern ...]
Display information about builtin commands.
Displays brief summaries of builtin commands. If PATTERN is
specified, gives detailed help on all commands matching PATTERN,
otherwise the list of help topics is printed.
Options:
-d output short description for each topic
-m display usage in pseudo-manpage format
-s output only a short usage synopsis for each topic matching
PATTERN
Arguments:
PATTERN Pattern specifiying a help topic
Exit Status:
Returns success unless PATTERN is not found or an invalid option is given.
info
10. ip
ip address / ip a
ip address show eth0 / ip a s eth0
11. ifconfig
ifconfig eth0
12. hostname
#显示系统主机名
选项:
-i #显示IPv6地址及外网ip地址
-I #只显示外网ip地址
[root@centos ~]# hostname -i
fe80::466f:75d3:8e41:406b%eth0 fe80::42:11ff:feba:3a33%docker0 fe80::449c:f6ff:feda:f3df%veth4ebb85c fe80::cc20:1bff:fe93:58c7%veth741145f fe80::c8cf:38ff:fee5:aa9f%vethd439c57 10.0.0.100 172.17.0.1
[root@centos ~]# hostname -I
10.0.0.100 172.17.0.1
13. history
[root@centos ~]
1 yum clean all
2 yum makecache
3 mkdir /repo
4 mv /etc/yum.repos.d/* /repo/
5 cp -p /repo/CentOS-Base.repo /etc/yum.repos.d/
6 ll
7 cd /etc/yum.repos.d/
8 ls
9 yum clean all
选项:
-W
-d
-c
[root@centos ~]
1 yum clean all
2 yum makecache
3 mkdir /repo
4 mv /etc/yum.repos.d/* /repo/
5 cp -p /repo/CentOS-Base.repo /etc/yum.repos.d/
[root@centos ~]
14. alias
[root@centos ~]
[root@centos ~]
[root@centos network-scripts]
/etc/sysconfig/network-scripts
15. unalias
[root@centos ~]
16. ping
-c<完成次数>:设置完成要求回应的次数;
-s<数据包大小>:设置数据包的大小;
-t<存活数值>:设置存活数值TTL的大小;
-i<间隔秒数>:指定收发信息的间隔时间;
[root@centos ~]
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.026 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.051 ms
--- 127.0.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.026/0.038/0.051/0.013 ms
[root@centos ~]
PING 127.0.0.1 (127.0.0.1) 100(128) bytes of data.
108 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.048 ms
108 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.027 ms
--- 127.0.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.027/0.037/0.048/0.012 ms
[root@centos ~]
PING 127.0.0.1 (127.0.0.1) 100(128) bytes of data.
108 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.025 ms
108 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.030 ms
--- 127.0.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 4999ms
rtt min/avg/max/mdev = 0.025/0.027/0.030/0.005 ms
17.pwd
案例:
[root@whb ~]
/root
[root@whb ~]
[root@whb sysconfig]
/etc/sysconfig
18.cd
案例 :
[root@whb /etc/sysconfig]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb /]
/root
[root@whb ~]
19.tree
系统中默认没有此命令,需要自行安装 yum install tree
选项:
-a
-d
-L
-F
*
=
|
/
@
>
案例:
[root@whb /usr/local]
.
├── bin
├── etc
├── games
├── include
├── lib
├── lib64
├── libexec
├── sbin
├── share
[root@whb ~]
.
├── 123
├── anaconda-ks.cfg
├── .bash_history
├── .bash_logout
├── .bash_profile
├── .bashrc
├── .cshrc
├── klefgrjm
├── .pki
│ └── nssdb
└── .tcshrc
2 directories, 9 files
[root@whb ~]
.
├── 123
├── anaconda-ks.cfg
└── klefgrjm
0 directories, 3 files
[root@whb ~]
/var/log
├── anaconda
├── audit
├── mariadb
├── nginx
├── php-fpm
├── rhsm
└── tuned
7 directories
[root@whb ~]
20.ls
选项:
-l
-1
-h
-a
-p
-F
-t
-S
-r
-i
案例:
[root@whb ~]
total 8
-rw-r--r--. 1 root root 8 Nov 28 17:32 123
-rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
-rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
[root@whb ~]
123
anaconda-ks.cfg
klefgrjm
[root@whb ~]
total 32
dr-xr-x---. 3 root root 174 Nov 28 18:25 .
dr-xr-xr-x. 18 root root 236 Nov 28 18:22 ..
-rw-r--r--. 1 root root 8 Nov 28 17:32 123
-rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
-rw-------. 1 root root 762 Nov 28 18:53 .bash_history
-rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc
-rw-r--r--. 1 root root 100 Dec 29 2013 .cshrc
-rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
drwxr-----. 3 root root 19 Nov 26 21:51 .pki
-rw-r--r--. 1 root root 129 Dec 29 2013 .tcshrc
[root@whb ~]
total 8
-rw-r--r--. 1 root root 8 Nov 28 17:32 123
-rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
-rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
[root@whb ~]
total 1.1M
drwxr-xr-x. 2 root root 176 Nov 26 20:28 anaconda
drwx------. 2 root root 23 Nov 26 20:30 audit
-rw-------. 1 root root 0 Nov 29 03:15 boot.log
-rw-------. 1 root root 8.3K Nov 27 03:08 boot.log-20191127
-rw-------. 1 root root 16K Nov 28 03:49 boot.log-20191128
-rw-------. 1 root root 16K Nov 29 03:15 boot.log-20191129
-rw-------. 1 root utmp 384 Nov 27 19:51 btmp
[root@whb ~]
total 1092
drwxr-xr-x. 2 root root 176 Nov 26 20:28 anaconda/
drwx------. 2 root root 23 Nov 26 20:30 audit/
-rw-------. 1 root root 0 Nov 29 03:15 boot.log
-rw-------. 1 root root 8489 Nov 27 03:08 boot.log-20191127
-rw-------. 1 root root 15865 Nov 28 03:49 boot.log-20191128
[root@whb ~]
*
=
|
/
@
>
[root@whb ~]
total 8
-rw-r--r--. 1 root root 8 Nov 28 17:32 123
-rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
-rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
[root@whb ~]
total 8
-rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
-rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
-rw-r--r--. 1 root root 8 Nov 28 17:32 123
[root@whb ~]
total 8
-rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
-rw-r--r--. 1 root root 8 Nov 28 17:32 123
-rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
[root@whb ~]
dr-xr-x---. 3 root root 174 Nov 28 18:25 .
[root@whb ~]
total 8
67157611 -rw-r--r--. 1 root root 8 Nov 28 17:32 123
67157603 -rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
67157607 -rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
21. mkdir
选项:
-p
-m
-v
案例:
[root@whb ~]
[root@whb ~]
[root@whb ~]
mkdir: cannot create directory ‘data’: File exists
[root@whb ~]
[root@whb ~]
total 8
-rw-r--r--. 1 root root 8 Nov 28 17:32 123
-rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 29 19:29 data
-rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
drwxr-xr-x. 3 root root 18 Nov 29 19:32 test
[root@whb ~]
total 0
drwxr-xr-x. 2 root root 6 Nov 29 19:32 data
[root@whb ~]
[root@whb ~]
total 8
-rw-r--r--. 1 root root 8 Nov 28 17:32 123
-rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 29 19:29 data
-rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
drwx------. 2 root root 6 Nov 29 19:34 oldboy
drwxr-xr-x. 3 root root 18 Nov 29 19:32 test
[root@whb ~]
mkdir: created directory ‘data1’
[root@whb ~]
[root@whb ~]
total 8
-rw-r--r--. 1 root root 8 Nov 28 17:32 123
-rw-------. 1 root root 1429 Nov 26 20:28 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 29 19:29 data
drwxr-xr-x. 2 root root 6 Nov 29 19:35 data1
-rw-r--r--. 1 root root 0 Nov 28 17:21 klefgrjm
drwx------. 2 root root 6 Nov 29 19:34 oldboy
drwxr-xr-x. 2 root root 6 Nov 29 19:38 oldboy1
drwxr-xr-x. 2 root root 6 Nov 29 19:38 oldboy2
drwxr-xr-x. 2 root root 6 Nov 29 19:38 oldboy3
drwxr-xr-x. 2 root root 6 Nov 29 19:38 oldboy4
drwxr-xr-x. 2 root root 6 Nov 29 19:38 oldboy5
[root@whb ~]
[root@whb ~]
[root@whb ~]
drwxr-xr-x. 2 root root 6 Nov 29 19:40 oldjia
drwxr-xr-x. 2 root root 6 Nov 29 19:40 oldwhb
drwxr-xr-x. 2 root root 6 Nov 29 19:40 oldzeng
drwxr-xr-x. 3 root root 18 Nov 29 19:32 test
[root@whb ~]
1110 directories, 0 files
[root@whb opt]
[root@whb opt]
total 0
-rw-r--r--. 1 root root 0 Nov 29 19:50 cd
drwxr-xr-x. 2 root root 6 Nov 29 19:48 data
drwxr-xr-x. 2 root root 6 Nov 29 19:53 DATA
{} 特殊字符,通配符 作用:生成序列
22. touch
案例:
[root@whb opt]
[root@whb opt]
total 0
-rw-r--r--. 1 root root 0 Nov 29 19:46 test.txt
[root@whb opt]
[root@whb opt]
total 0
-rw-r--r--. 1 root root 0 Nov 29 19:47 test.txt
[root@whb opt]
[root@whb opt]
total 0
drwxr-xr-x. 2 root root 6 Nov 29 19:47 data
-rw-r--r--. 1 root root 0 Nov 29 19:47 test.txt
[root@whb opt]
[root@whb opt]
total 0
drwxr-xr-x. 2 root root 6 Nov 29 19:48 data
-rw-r--r--. 1 root root 0 Nov 29 19:47 test.txt
[root@whb opt]
[root@whb opt]
total 0
-rw-r--r--. 1 root root 0 Nov 29 19:50 cd
drwxr-xr-x. 2 root root 6 Nov 29 19:48 data
-rw-r--r--. 1 root root 0 Nov 29 19:51 data10.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data1.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data2.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data3.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data4.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data5.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data6.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data7.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data8.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data9.txt
23. cp
选项:
-p
-r
-d
-a == -pdr
-i
-t
案例:
[root@whb opt]
[root@whb opt]
total 0
-rw-r--r--. 1 root root 0 Nov 29 19:59 test.txt
[root@whb opt]
[root@whb opt]
total 0
-rw-r--r--. 1 root root 0 Nov 29 19:51 data9.txt
-rw-r--r--. 1 root root 0 Nov 29 19:59 test.txt
[root@whb opt]
[root@whb opt]
total 0
-rw-r--r--. 1 root root 0 Nov 29 19:51 data9.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data.log
-rw-r--r--. 1 root root 0 Nov 29 19:59 test.txt
[root@whb opt]
[root@whb opt]
cp: omitting directory ‘data/’
[root@whb opt]
[root@whb opt]
total 0
drwxr-xr-x. 2 root root 6 Nov 29 20:03 data
-rw-r--r--. 1 root root 0 Nov 29 19:51 data9.txt
-rw-r--r--. 1 root root 0 Nov 29 19:51 data.log
-rw-r--r--. 1 root root 0 Nov 29 19:59 test.txt
[root@whb opt]
[root@whb opt]
lrwxrwxrwx. 1 root root 22 Nov 29 20:05 grub2.cfg.log -> ../boot/grub2/grub.cfg
[root@whb opt]
[root@whb opt]
lrwxrwxrwx. 1 root root 7 Nov 29 20:07 /binn -> usr/bin
[root@whb opt]
cp: omitting directory ‘/bin’
[root@whb opt]
[root@whb opt]
lrwxrwxrwx. 1 root root 7 Nov 26 20:22 /binnn -> usr/bin
[root@whb opt]
lrwxrwxrwx. 1 root root 7 Nov 26 20:22 /bin -> usr/bin
[root@whb opt]
cp: overwrite ‘/mnt/data9.txt’? n
[root@whb opt]
[root@whb opt]
24. mv
选项:
-f
-i
-t
案例:
[root@whb opt]
[root@whb opt]
total 4
-rw-r--r--. 1 root root 0 Nov 29 20:17 data.log
[root@whb opt]
[root@whb opt]
total 4
drwxr-xr-x. 2 root root 6 Nov 29 19:48 data
-rw-r--r--. 1 root root 0 Nov 29 20:17 data.log
[root@whb opt]
mv: overwrite ‘/tmp/data.log’? n
[root@whb opt]
[root@whb opt]
25. rename
[root@whb opt]
命令 旧的字符串 新的字符串 文件名
26. rm
选项:
-f
-r
-i
案例:
[root@whb opt]
rm: remove symbolic link ‘bin’? n
[root@whb opt]
[root@whb opt]
rm: cannot remove ‘DATA/’: Is a directory
[root@whb opt]
[root@whb opt]
[root@whb ~]
27. echo
选项:
-n
-e
案例:
[root@whb ~]
hello world
[root@whb ~]
hello
world
[root@whb ~]
hello world
[root@whb ~]
\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[36;40m\]\w\[\e[0m\]]\$
[root@whb ~]
root
[root@whb ~]
[root@whb ~]
total 4
-rw-r--r--. 1 root root 12 Dec 2 18:24 test.txt
[root@whb ~]
123
[root@whb ~]
[root@whb ~]
total 4
-rw-r--r--. 1 root root 8 Dec 2 18:28 test.txt
[root@whb ~]
123
456
[root@whb ~]
root
[root@whb ~]
$USER
[root@whb ~]
root
[root@whb ~]
1 2 3 4 5
[root@whb ~]
{1..5}
[root@whb ~]
{1..5}
[root@whb ~]
[root@whb ~]
[root@whb ~]
whb
[root@whb ~]
-bash: alias: -I: not found
[root@whb ~]
[root@whb ~]
10.0.0.100
单双引号及不加引号的区别
不加引号:
单引号:
双引号:
反引号:
[root@whb ~]
whb
[root@whb ~]
whb
echo -e "\033[30m 黑色字 \033[0m"
echo -e "\033[31m 红色字 \033[0m"
echo -e "\033[32m 绿色字 \033[0m"
echo -e "\033[33m 黄色字 \033[0m"
echo -e "\033[34m 蓝色字 \033[0m"
echo -e "\033[35m 紫色字 \033[0m"
echo -e "\033[36m 天蓝字 \033[0m"
echo -e "\033[37m 白色字 \033[0m"
[root@whb ~]
好湿
江山风景美如画;
本想吟诗赞天下。
奈何自己没文化;
一句卧槽浪好大。
28. cat
选项:
-n
-A
案例:
[root@oldboy ~]
123
456
[root@oldboy ~]
1 123
2 456
[root@oldboy ~]
123$
456$
[root@oldboy ~]
[root@oldboy ~]
123
456
123456
[root@oldboy ~]
123$
456$
123456 $
[root@oldboy ~]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@oldboy ~]
123
456
123456
[root@oldboy ~]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
123
456
123456
[root@oldboy ~]
[root@oldboy ~]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
123
456
123456
[root@oldboy ~]
> oldboy
> 123456
> olfgirl
> EOF
[root@oldboy ~]
oldboy
123456
olfgirl
[root@oldboy ~]
> test
> eof
[root@oldboy ~]
oldboy
123456
olfgirl
test
29. tac
案例:
[root@oldboy ~]
test
olfgirl
123456
oldboy
30. more
选项:
-n
+n
案例:
[root@oldboy lianxi]
--More--(0%)
内部命令
空格/f
b
回车键
/
n
q
h
31. less
#分页显示文件内容,文件显示完成后不会自动退出
选项:
-i #搜索时不区分大小写
-N #给显示出的内容加上行号
内部命令:
空格/f #向下翻页
b #向上翻页
回车键 #向下翻一行
/ #搜索指定内容,但不会高亮显示
n #向上搜索
N #向下搜索
= #显示行号、字节、占比等信息
eg: services lines 1-25/11176 byte 1116/670293 0% (press RETURN)
q #退出
32. head
选项:
-n
-c
案例:
[root@oldboy ~]
[root@oldboy ~]
[root@oldboy ~]
[root@oldboy ~]
[root@oldboy ~]
33. tail
选项:
-n
-c
-f
-F
案例:
[root@oldboy ~]
3gpp-cbsp 48049/tcp
isnetserv 48128/tcp
isnetserv 48128/udp
blp5 48129/tcp
blp5 48129/udp
com-bardac-dw 48556/tcp
com-bardac-dw 48556/udp
iqobject 48619/tcp
iqobject 48619/udp
matahari 49000/tcp
[root@oldboy ~]
matahari 49000/tcp
[root@oldboy ~]
matahari 49000/tcp
[root@oldboy ~]
11176 matahari 49000/tcp
|
[root@oldboy ~]
oker
[root@oldboy ~]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
123
456
123456
123
[root@oldboy ~]
[root@oldboy ~]
tail: cannot open ‘file.log’ for reading: No such file or directory
tail: ‘file.log’ has appeared; following end of new file
123
^C
34. tailf
选项:
-n
案例:
[root@oldboy ~]
[root@oldboy ~]
35. grep
选项:
-v
-i
-n
-c
-o
-w
-E
-r
-R
-A
-B
-C
^
$
^$
.
.*
\
| #扩展正则,或者
[root@whb ~]# cp /etc/passwd ./
[root@whb ~]# grep 'root' passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
[root@whb ~]# grep '/sbin/nologin' passwd
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
www:x:666:666::/home/www:/sbin/nologin
nginx:x:665:665:nginx user:/var/cache/nginx:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
[root@whb ~]# grep -v '/sbin/nologin' passwd #-v 排除
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
test:x:1000:1000::/home/test:/bin/bash
[root@whb ~]# grep -i 'root' passwd #忽略大小写
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
ROOT
[root@whb ~]# grep -n 'root' passwd #显示该行内容在文件的所在行号
1:root:x:0:0:root:/root:/bin/bash
10:operator:x:11:0:operator:/root:/sbin/nologin
[root@whb ~]# grep -c 'root' passwd #统计匹配root字符串的行数
2
[root@whb ~]# grep -o 'root' passwd #只显示匹配的内容
root
root
root
root
[root@whb ~]# grep -o 'root' passwd | grep -c 'root'
4
[root@whb ~]
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
roott
rootooo
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
total 680
drwxr-xr-x. 2 root root 22 Dec 3 18:04 data
-rw-r--r--. 1 root root 4 Dec 2 20:19 file.log
-rw-r--r--. 1 root root 27 Dec 2 19:31 file.txt
-rw-r--r--. 1 root root 158 Dec 2 19:26 hosts
-rw-r--r--. 1 root root 1100 Dec 3 18:01 passwd
-rw-r--r--. 1 root root 670293 Dec 2 19:36 services
drwxr-xr-x. 2 root root 22 Dec 3 18:04 test
-rw-r--r--. 1 root root 178 Dec 2 20:14 test.log
-rw-r--r--. 1 root root 16 Dec 2 19:23 test.txt
[root@whb ~]
grep: ./data: Is a directory
./passwd:root:x:0:0:root:/root:/bin/bash
./passwd:operator:x:11:0:operator:/root:/sbin/nologin
./passwd:roott
./passwd:rootooo
./services:rootd 1094/tcp
./services:rootd 1094/udp
grep: ./test: Is a directory
[root@whb ~]
./data/test.txt:root
./passwd:root:x:0:0:root:/root:/bin/bash
./passwd:operator:x:11:0:operator:/root:/sbin/nologin
./passwd:roott
./passwd:rootooo
./services:rootd 1094/tcp
./services:rootd 1094/udp
./test/data.txt:root
[root@whb ~]
./data/test.txt:root
./passwd:root:x:0:0:root:/root:/bin/bash
./passwd:operator:x:11:0:operator:/root:/sbin/nologin
./passwd:roott
./passwd:rootooo
./services:rootd 1094/tcp
./services:rootd 1094/udp
./test/data.txt:root
[root@whb ~]
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
adm:x:3:4:adm:/var/adm:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
roott
rootooo
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
adm:x:3:4:adm:/var/adm:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
roott
rootooo
[root@whb ~]
adm:x:3:4:adm:/var/adm:/sbin/nologin
[root@whb ~]
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
[root@whb ~]
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
[root@whb ~]
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
roott
rootooo
[root@whb ~]
halt:x:7:0:halt:/sbin:/sbin/halt
roott
ooroot
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[root@whb ~]
roottt.
[root@whb ~]
[root@whb ~]
36. locate
-i
-r
[root@whb ~]
[root@whb ~]
/etc/hostname
/etc/dbus-1/system.d/org.freedesktop.hostname1.conf
/etc/selinux/targeted/active/modules/100/hostname
/etc/selinux/targeted/active/modules/100/hostname/cil
/etc/selinux/targeted/active/modules/100/hostname/hll
/etc/selinux/targeted/active/modules/100/hostname/lang_ext
[root@whb ~]
[root@whb ~]
/etc/hostname
/etc/dbus-1/system.d/org.freedesktop.hostname1.conf
/etc/selinux/targeted/active/modules/100/hostname
/etc/selinux/targeted/active/modules/100/hostname/cil
/etc/selinux/targeted/active/modules/100/hostname/hll
/etc/selinux/targeted/active/modules/100/hostname/lang_ext
/root/hostname
/usr/bin/hostname
[root@whb ~]
/etc/hostname
/etc/dbus-1/system.d/org.freedesktop.hostname1.conf
/etc/selinux/targeted/active/modules/100/hostname
/etc/selinux/targeted/active/modules/100/hostname/cil
/etc/selinux/targeted/active/modules/100/hostname/hll
/etc/selinux/targeted/active/modules/100/hostname/lang_ext
/root/HOSTNAME
/root/hostname
[root@whb ~]
/etc/hostname
/etc/selinux/targeted/active/modules/100/hostname
/root/hostname
/usr/bin/hostname
/usr/bin/nmtui-hostname
/usr/lib64/gettext/hostname
[root@whb ~]
[root@whb ~]
/usr/share/doc/hostname-3.13
/usr/share/doc/hostname-3.13/COPYRIGHT
37. whereis
选项:
-b
-m
-s
[root@whb ~]
hostname: /usr/bin/hostname /etc/hostname /usr/share/man/man1/hostname.1.gz /usr/share/man/man5/hostname.5.gz
[root@whb ~]
hostname: /usr/bin/hostname /etc/hostname
[root@whb ~]
hostname: /usr/share/man/man1/hostname.1.gz /usr/share/man/man5/hostname.5.gz
[root@whb ~]
hostname:[root@whb ~]
38. which
[root@whb ~]
/usr/bin/hostname
[root@whb ~]
/usr/bin/hostnamectl
39. type
-a
-p
[root@whb ~]
cd is a shell builtin
[root@whb ~]
[root@whb ~]
cd is a shell builtin
cd is /usr/bin/cd
[root@whb ~]
/usr/bin/ping
40. find
-name
-iname
-maxdepth
-print
[root@whb ~]
/proc/sys/kernel/hostname
/etc/selinux/targeted/active/modules/100/hostname
/etc/hostname
/root/hostname
/usr/bin/hostname
/usr/lib64/gettext/hostname
[root@whb ~]
/proc/sys/kernel/hostname
/etc/selinux/targeted/active/modules/100/hostname
/etc/hostname
/root/hostname
/root/HOSTNAME
/usr/bin/hostname
/usr/lib64/gettext/hostname
/usr/lib64/perl5/auto/Sys/Hostname
[root@whb ~]
/proc/sys/kernel/hostname
/etc/selinux/targeted/active/modules/100/hostname
/etc/hostname
/root/hostname
/root/HOSTNAME
/usr/bin/hostname
/usr/share/man/man1/hostnamectl.1.gz
/usr/share/man/man5/hostname.5.gz
/usr/share/bash-completion/completions/hostnamectl
[root@whb ~]
/proc/sys/kernel/hostname
/sys/kernel/debug/tracing/events/syscalls/sys_enter_sethostname
/sys/kernel/debug/tracing/events/syscalls/sys_exit_sethostname
/etc/selinux/targeted/active/modules/100/hostname
/etc/hostname
/usr/lib64/gettext/hostname
/usr/lib64/perl5/auto/Sys/Hostname
[root@whb ~]
/proc/sys/kernel/hostname
/sys/kernel/debug/tracing/events/syscalls/sys_enter_sethostname
/sys/kernel/debug/tracing/events/syscalls/sys_exit_sethostname
/etc/dbus-1/system.d/org.freedesktop.hostname1.conf
/etc/selinux/targeted/active/modules/100/hostname
/etc/hostname
/root/hostname
/root/HOSTNAME
[root@whb ~]
/etc/selinux/targeted/active/modules/100/hostname
/etc/hostname
[root@whb ~]
/etc/hostname
[root@whb ~]
/etc/hostname
41. rz/sz
rz #上传,不支持4G以上的文件
-E #如果文件已经存在,则上传的时候修改名称,在文件名的后面加上数字 0.1.2...
[root@whb ~]# rz #上传本地文件到服务器上面
[root@whb ~]# ll
total 688
drwxr-xr-x. 2 root root 22 Dec 3 18:04 data
-rw-r--r--. 1 root root 7748 Aug 17 17:25 djangoauth.md
[root@whb ~]# rz -E #如果文件已经存在,则上传的时候修改名称,在文件名的后面加上数字 0.1.2...
[root@whb ~]# ll
total 696
drwxr-xr-x. 2 root root 22 Dec 3 18:04 data
-rw-r--r--. 1 root root 7748 Aug 17 17:25 djangoauth.md
-rw-r--r--. 1 root root 7748 Aug 17 17:25 djangoauth.md.0
sz #下载服务器上的文件到本地
[root@whb ~]# sz file.log
联网下载
42. curl
-o
-s
[root@whb ~]
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2381 100 2381 0 0 27351 0 --:--:-- --:--:-- --:--:-- 27686
[root@whb ~]
total 700
-rw-r--r--. 1 root root 2381 Dec 3 20:11 baidu.html
[root@whb ~]
[root@whb ~]
total 704
-rw-r--r--. 1 root root 2381 Dec 3 20:11 baidu.html
-rw-r--r--. 1 root root 2381 Dec 3 20:12 bd.html
[root@whb ~]
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
29 1008k 29 301k 0 0 6621 0 0:02:35 0:00:46 0:01:49 0
43. wget
-O
-q
--limit-rate=20(k/m)
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
44. sort
选项:
-t
-k
-n
-r
[root@whb ~]
adm:x:3:4:adm:/var/adm:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
bin:x:1:1:bin:/bin:/sbin/nologin
test:x:1000:1000::/home/test:/bin/bash
www:x:666:666::/home/www:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
test:x:1000:1000::/home/test:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
bin:x:1:1:bin:/bin:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
test:x:1000:1000::/home/test:/bin/bash
[root@whb ~]
test:x:1000:1000::/home/test:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
bin:x:1:1:bin:/bin:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
[root@whb ~]
[root@whb ~]
abc/1
abd/11
fgrf/2
fger/8
rgrgh/66
[root@whb ~]
abc/1
abd/11
fger/8
fgrf/2
rgrgh/66
[root@whb ~]
abc/1
abd/11
fgrf/2
rgrgh/66
fger/8
[root@whb ~]
abc/1
fgrf/2
fger/8
abd/11
rgrgh/66
[root@whb ~]
rgrgh/66
abd/11
fger/8
fgrf/2
abc/1
[root@whb ~]
abc/1
abd/11
fgrf/2
fger/8
rgrgh/66
fger/8
abd/11
fgrf/2
[root@whb ~]
abc/1
abd/11
abd/11
fger/8
fger/8
fgrf/2
fgrf/2
rgrgh/66
45. uniq
-c
[root@whb ~]
1 abc/1
2 abd/11
2 fger/8
2 fgrf/2
1 rgrgh/66
[root@whb ~]
1 abc/1
1 rgrgh/66
2 abd/11
2 fger/8
2 fgrf/2
[root@whb ~]
2 fgrf/2
2 fger/8
2 abd/11
1 rgrgh/66
1 abc/1
46. cut
-d
-f
-c
[root@whb ~]
/bin/bash
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/bin/sync
/sbin/shutdown
/sbin/halt
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/bin/bash
/sbin/nologin
[root@whb ~]
/bin/bash
/bin/bash
/bin/sync
/sbin/halt
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/shutdown
[root@whb ~]
/bin/bash
/bin/sync
/sbin/halt
/sbin/nologin
/sbin/shutdown
[root@whb ~]
2 /bin/bash
1 /bin/sync
1 /sbin/halt
19 /sbin/nologin
1 /sbin/shutdown
[root@whb ~]
19 /sbin/nologin
2 /bin/bash
1 /sbin/shutdown
1 /sbin/halt
1 /bin/sync
[root@whb ~]
abc/1
abd/11
fgrf/2
fger/8
rgrgh/66
fger/8
abd/11
fgrf/2
[root@whb ~]
1
11
2
8
66
8
11
2
[root@whb ~]
66
11
11
8
8
2
2
1
[root@whb ~]
[root@whb ~]
I am name is student QQ is 1238376584
[root@whb ~]
name is
[root@whb ~]
name 1238376584
[root@whb ~]
name is student QQ is 1238376584
[root@whb ~]
I am name is student QQ is 1238376584
[root@whb ~]
I a
[root@whb ~]
a
[root@whb ~]
Ia
47. tr
-d
[root@whb ~]
I am name is student QQ is,1238376584
[root@whb ~]
name is,1238376584
[root@whb ~]
name is 1238376584
[root@whb ~]
name 1238376584
[root@whb ~]
tr: extra operand ‘qq.txt’
Try 'tr --help' for more information.
[root@whb ~]
I am name is student QQ is 1238376584
[root@whb ~]
name 1238376584
[root@whb ~]
I 1m n1me is student QQ is,1238376584
[root@whb ~]
I a nae is student QQ is,1238376584
[root@whb ~]
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ae:0b:8a brd ff:ff:ff:ff:ff:ff
inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::c653:602a:38c6:e45/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@whb ~]
inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
[root@whb ~]
inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
[root@whb ~]
inet 10.0.0.100 24 brd 10.0.0.255 scope global noprefixroute eth0
[root@whb ~]
10.0.0.100
[root@whb ~]
inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
[root@whb ~]
10.0.0.100/24
[root@whb ~]
10.0.0.100
[root@whb ~]
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.100 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::c653:602a:38c6:e45 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:ae:0b:8a txqueuelen 1000 (Ethernet)
RX packets 3484131 bytes 4986775944 (4.6 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 364363 bytes 53078581 (50.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@whb ~]
inet 10.0.0.100 netmask 255.255.255.0 broadcast 10.0.0.255
[root@whb ~]
10.0.0.100
[root@whb ~]
root pts/0 10.0.0.1 19:10 9:03 0.01s 0.01s -bash
root pts/1 10.0.0.1 19:10 9:03 0.00s 0.00s -bash
root pts/2 10.0.0.1 Fri20 3.00s 0.95s 0.00s w -h
[root@whb ~]
root
root
root
[root@whb ~]
3 root
[root@whb ~]
3 root
1 test
[root@whb ~]
19:21:39 up 6 days, 32 min, 4 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 10.0.0.1 19:10 43.00s 0.01s 0.01s -bash
root pts/1 10.0.0.1 19:10 11:03 0.00s 0.00s -bash
root pts/2 10.0.0.1 Fri20 3.00s 0.95s 0.00s w
test pts/3 10.0.0.1 19:21 21.00s 0.00s 0.00s -bash
[root@whb ~]
root pts/0 10.0.0.1 19:10 50.00s 0.01s 0.01s -bash
root pts/1 10.0.0.1 19:10 11:10 0.00s 0.00s -bash
root pts/2 10.0.0.1 Fri20 2.00s 0.96s 0.00s w
test pts/3 10.0.0.1 19:21 28.00s 0.00s 0.00s -bash
48. wc
选项:
-l
-c
-w
-L
[root@whb ~]
2 10 158 hosts
[root@whb ~]
-rw-r--r--. 1 root root 158 Dec 2 19:26 hosts
[root@whb ~]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@whb ~]
2 hosts
[root@whb ~]
158 hosts
[root@whb ~]
10 hosts
[root@whb ~]
78 hosts
[root@whb ~]
[root@whb ~]
12423145637892
[root@whb ~]
14
49. sed
-n
-i
-r
内部命令:
p
d
s
g
a
i
;
,
1.查
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[root@whb ~]
ntp:x:38:38::/etc/ntp:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
adm:x:3:4:adm:/var/adm:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
adm:x:3:4:adm:/var/adm:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
2.删除
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
3.增
[root@whb ~]
abc/1
abd/11
fgrf/2
fger/8
rgrgh/66
fger/8
abd/11
fgrf/2
oldboy
[root@whb ~]
abc/1
oldboy
abd/11
fgrf/2
fger/8
rgrgh/66
fger/8
abd/11
fgrf/2
[root@whb ~]
oldboy
abc/1
abd/11
fgrf/2
fger/8
rgrgh/66
fger/8
abd/11
fgrf/2
[root@whb ~]
abc/1
abd/11
fgrf/2
fger/8
rgrgh/66
fger/8
abd/11
oldboy
fgrf/2
[root@whb ~]
oldboy
oldgirl
abc/1
abd/11
fgrf/2
fger/8
rgrgh/66
fger/8
abd/11
fgrf/2
[root@whb ~]
abc/1
abd/11
fgrf/2
fger/8
rgrgh/66
fger/8
abd/11
fgrf/2
oldboy
oldgirl
4.替换
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
[root@whb ~]
oldboy:x:0:0:oldboy:/oldboy:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/oldboy:/sbin/nologin
[root@whb ~]
oldboy:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/oldboy:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/oldboy:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/oldboy:/sbin/nologin
oldboy
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
oldboy
[root@whb ~]
oldboy:x:0:0:oldboy:/oldboy:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
oldboy
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
oldboy
50. awk
-F
NR
NF
$NF
$0
$n
&&
||
!
’
;
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[root@whb ~]
root
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
[root@whb ~]
operator:x:11:0:operator:/root:/sbin/nologin
root
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
[root@whb ~]
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
root
[root@whb ~]
1 root:x:0:0:root:/root:/bin/bash
2 bin:x:1:1:bin:/bin:/sbin/nologin
3 daemon:x:2:2:daemon:/sbin:/sbin/nologin
4 adm:x:3:4:adm:/var/adm:/sbin/nologin
5 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
6 sync:x:5:0:sync:/sbin:/bin/sync
7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
8 halt:x:7:0:halt:/sbin:/sbin/halt
9 mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
10 operator:x:11:0:operator:/root:/sbin/nologin
11 root
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
root
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
root
[root@whb ~]
root
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
adm:x:3:4:adm:/var/adm:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
root
[root@whb ~]
root:x:0:0:root:/root:/bin/bash
adm:x:3:4:adm:/var/adm:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
root
[root@whb ~]
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
[root@whb ~]
/bin/bash
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/bin/sync
/sbin/shutdown
/sbin/halt
/sbin/nologin
/sbin/nologin
[root@whb ~]
/bin/bash
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/bin/sync
/sbin/shutdown
/sbin/halt
/sbin/nologin
/sbin/nologin
[root@whb ~]
/bin/bash
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/bin/sync
/sbin/shutdown
/sbin/halt
/sbin/nologin
/sbin/nologin
[root@whb ~]
/bin/bash
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
/bin/sync
/sbin/shutdown
/sbin/halt
/sbin/nologin
/sbin/nologin
root
[root@whb ~]
[root@whb ~]
oldgirl
[root@whb ~]
123 oldgirl
[root@whb ~]
123
[root@whb ~]
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.100 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::c653:602a:38c6:e45 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:ae:0b:8a txqueuelen 1000 (Ethernet)
RX packets 3515748 bytes 5009905896 (4.6 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 382062 bytes 54939915 (52.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@whb ~]
inet 10.0.0.100 netmask 255.255.255.0 broadcast 10.0.0.255
[root@whb ~]
10.0.0.100
[root@whb ~]# ifconfig eth0 |awk 'NR==2{print $2}'
10.0.0.100
#取出ip地址
[root@whb ~]# ip a s eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ae:0b:8a brd ff:ff:ff:ff:ff:ff
inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::c653:602a:38c6:e45/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@whb ~]
inet
[root@whb ~]
10.0.0.100
[root@whb ~]
10.0.0.100
[root@whb ~]
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
root
oldboy:123 oldgirl
[root@whb ~]
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
oldboy:123 oldgirl
[root@whb ~]
[root@whb ~]
/bin/bash
root
[root@whb ~]
root x
root
[root@whb ~]
0 root
root
51. column
-t
[root@whb ~]
root /bin/bash
bin /sbin/nologin
daemon /sbin/nologin
adm /sbin/nologin
dbus /sbin/nologin
polkitd /sbin/nologin
sshd /sbin/nologin
postfix /sbin/nologin
www /sbin/nologin
nginx /sbin/nologin
apache /sbin/nologin
mysql /sbin/nologin
test /bin/bash
ntp /sbin/nologin
[root@whb ~]
root /bin/bash
bin /sbin/nologin
daemon /sbin/nologin
adm /sbin/nologin
sshd /sbin/nologin
postfix /sbin/nologin
www /sbin/nologin
nginx /sbin/nologin
apache /sbin/nologin
mysql /sbin/nologin
test /bin/bash
ntp /sbin/nologin
52. ln
选项:
-s
软连接
[root@whb ~]
[root@whb ~]
total 0
-rw-r--r--. 1 root root 0 Dec 5 19:58 test.log
[root@whb ~]
[root@whb ~]
total 0
lrwxrwxrwx. 1 root root 8 Dec 5 19:58 test -> test.log
-rw-r--r--. 1 root root 0 Dec 5 19:58 test.log
[root@whb ~]
[root@whb ~]
total 0
lrwxrwxrwx. 1 root root 8 Dec 5 19:58 test -> test.log
-rw-r--r--. 1 root root 0 Dec 5 19:58 test.log
lrwxrwxrwx. 1 root root 14 Dec 5 19:59 test.txt -> /root/test.log
[root@whb ~]
[root@whb ~]
total 4481024
-rw-r--r--. 1 root root 4588568576 Dec 3 20:08 CentOS-7-x86_64-DVD-1810.iso
lrwxrwxrwx. 1 root root 14 Dec 5 19:59 test.txt -> /root/test.log
[root@whb ~]
[root@whb ~]
total 4481024
-rw-r--r--. 1 root root 4588568576 Dec 3 20:08 CentOS-7-x86_64-DVD-1810.iso
lrwxrwxrwx. 1 root root 8 Dec 5 19:58 test -> test.log
lrwxrwxrwx. 1 root root 14 Dec 5 19:59 test.txt -> /root/test.log
[root@whb ~]
[root@whb ~]
total 4481024
-rw-r--r--. 1 root root 4588568576 Dec 3 20:08 CentOS-7-x86_64-DVD-1810.iso
lrwxrwxrwx. 1 root root 11 Dec 5 20:05 data -> /root/data/
lrwxrwxrwx. 1 root root 8 Dec 5 19:58 test -> test.log
lrwxrwxrwx. 1 root root 14 Dec 5 19:59 test.txt -> /root/test.log
[root@whb ~]
硬链接
[root@whb ~]
[root@whb ~]
[root@whb ~]
123
456
[root@whb ~]
[root@whb ~]
123
456
53. vi/vim
选项:
-r
+n
-o
-O
命令模式
光标跳转
h
l
j
k
^
$
shift + w
shift + e
gg
G
ngg/nG
Ctrl键 + f
Ctrl键 + b
回车键
空格键
删除键
dd
ndd
dG
p
P
u
Ctrl键+r
D
de
dw
yy
nyy
ZZ
r
R
x/delete
X
编辑模式
Esc键
i
a
I
A
ce
cw
C
o
O
s
S
cc
末行模式
:q
:wq
:q!
:wq!
:w
:x
:n
:nd
:n,md
/root
n
N
/root\c
?root
:%s
:%s
:s
:1s
:1,10s
:%s
:w /path
:r /path
:1r /path
:$r /path
:0r /path
:1 copy 10
:1,3 copy 10
:1 move 10
:sh
视图模式
可视行
先将光标移动到要操作的行
shift+v
光标选中你要操作的所有行
y
d/x
可视块
将光标移动到要操作的行,并且是要操作的字符上面
Ctrl+v
使用方向键进行选中要操作的行
shift + i
编辑内容 按esc退出
将光标移动到要操作的行,并且是要操作的字符上面
Ctrl+v
使用方向键进行选中要操作的行或者字符,块
d/x
54. diff
[root@whb ~]
1c1
< rhgiutgroot:x:0:0:root:/root:/bin/bash
---
> root:x:0:0:root:/root:/bin/bash
3c3
< rgutrhnoifjgbosfiddddddvbjklndaemon:x:2:2:daemon:/sbin:/sbin/nologin
---
> daemon:x:2:2:daemon:/sbin:/sbin/nologin
25d24
< ROOT
[root@whb ~]
55. md5sum
[root@whb ~]
3fae271737b5fba20b893cedf92afa39 passwd
[root@whb ~]
3fae271737b5fba20b893cedf92afa39 passwd
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
3fae271737b5fba20b893cedf92afa39 passwd
[root@whb ~]
passwd: OK
[root@whb ~]
[root@whb ~]
passwd: FAILED
md5sum: WARNING: 1 computed checksum did NOT match
56. id
[root@whb ~]
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@whb ~]
uid=3(adm) gid=4(adm) groups=4(adm)
57. w
#显示系统状态,显示当前登录的用户信息
[root@whb ~]# w
11:45:24 up 1:22, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 10:23 1:22m 0.03s 0.03s -bash
root pts/0 10.0.0.1 10:27 4.00s 0.03s 0.00s w
58. who
[root@whb ~]
root tty1 2019-12-14 10:23
root pts/0 2019-12-14 10:27 (10.0.0.1)
59. whoami
[root@whb ~]
root
60. uptime
#显示系统状态及用户的登录终端的数量
[oot@whb ~]# uptime
11:50:52 up 1:28, 2 users, load average: 0.02, 0.04, 0.05
61. useradd
选项:
-u
-g
-G
-c
-r
-M
-d
-s
[root@whb ~]
uid=1001(user01) gid=1001(user01) groups=1001(user01)
[root@whb ~]
user01:x:1001:1001::/home/user01:/bin/bash
[root@whb ~]
[root@whb ~]
uid=888(user02) gid=1002(user02) groups=1002(user02)
[root@whb ~]
user02:x:888:1002:测试用户:/opt/user02:/bin/bash
[root@whb ~]
drwx------. 2 user02 user02 62 Dec 12 18:36 user02
[root@whb ~]
[root@whb ~]
user04:x:664:663::/home/user04:/sbin/nologin
[root@whb ~]
total 0
drwx------. 2 test test 62 Nov 27 19:57 test
drwx------. 2 user01 user01 62 Dec 12 18:29 user01
[root@whb ~]
[root@whb ~]
total 0
drwx------. 2 test test 62 Nov 27 19:57 test
drwx------. 2 user01 user01 62 Dec 12 18:29 user01
[root@whb ~]
user05:x:2000:2000::/home/user05:/sbin/nologin
62. usermod
usermod
选项:
-u
-g
-a
-G
-aG
-m
-d
-c
-s
-l
-L
-U
[root@whb ~]
[root@whb ~]
user05:x:1010:2000:test:/home/user05:/bin/bash
[root@whb ~]
[root@whb ~]
total 0
drwx------. 2 test test 62 Nov 27 19:57 test
drwx------. 2 user01 user01 62 Dec 12 18:29 user01
drwx------. 2 user02 user02 62 Dec 12 18:36 user02
[root@whb ~]
[root@whb ~]
id: user05: no such user
[root@whb ~]
uid=1010(oldboy) gid=2000(user05) groups=2000(user05)
[root@whb ~]
oldboy:x:1010:2000:test:/home/user05:/bin/bash
[root@whb ~]
[root@whb ~]
63. userdel
userdel
选项:
-r
[root@whb ~]
[root@whb ~]
[root@whb ~]
id: user02: no such user
[root@whb ~]
total 0
drwx------. 2 test test 62 Nov 27 19:57 test
drwx------. 2 user01 user01 62 Dec 12 18:29 user01
drwx------. 2 888 1002 62 Dec 12 18:36 user02
[root@whb ~]
[root@whb ~]
total 0
drwx------. 2 test test 62 Nov 27 19:57 test
drwx------. 2 888 1002 62 Dec 12 18:36 user02
64. passwd
[root@whb ~]
Changing password for user root.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
[root@whb ~]
Changing password for user user06.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
[user06@whb ~]$ passwd
Changing password for user user06.
Changing password for user06.
(current) UNIX password:
New password:
Retype new password:
Sorry, passwords do not match.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
将密码信息显示出来 通过管道交给后面的命令 标准输出 --stdin 用户名
[root@whb ~]
Changing password for user user06.
passwd: all authentication tokens updated successfully.
[root@whb ~]
Changing password for user user06.
passwd: all authentication tokens updated successfully.
[root@whb ~]
c5b795e212
$RANDOM
65. tee
tee
-a
[root@whb ~]
Changing password for user user06.
passwd: all authentication tokens updated successfully.
[root@whb ~]
c5b795e212
f136b51b96
66. mkpasswd
[root@whb ~]
[root@whb ~]
w)ztysepy5bqyioresmDLe1b
[root@whb ~]
1}z3UNM1IT5x&r@~/;pGj60z
-l
-c
-C
-d
-s
[root@whb ~]
Changing password for user user06.
passwd: all authentication tokens updated successfully.
67. groupadd
-g
-r
[root@whb ~]
[root@whb ~]
user01:x:2016:
[root@whb ~]
[root@whb ~]
user02:x:2018:
[root@whb ~]
[root@whb ~]
user04:x:663:
68. groupmod
-g
-n
[root@whb ~]
[root@whb ~]
user01:x:2019:
[root@whb ~]
[root@whb ~]
[root@whb ~]
user10:x:2019:
69. groupdel
可以删除没有用户作为主组的组,如果只是附加组,删除不会提示
[root@whb ~]
[root@whb ~]
[root@whb ~]
oldboy1:x:2002:web
web:x:2015:
[root@whb ~]
groupdel: cannot remove the primary group of user 'web'
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
uid=2014(yw1) gid=2019(yw) groups=2019(yw)
[root@whb ~]
uid=2015(yw2) gid=2019(yw) groups=2019(yw)
70. su
su username
su - username
[root@whb ~]
/etc/bashrc
/etc/profile.d/test.sh
[test@whb root]$ pwd
/root
[test@whb root]$ exit
[root@whb ~]
Last login: Mon Dec 16 17:40:28 CST 2019 on pts/0
/etc/profile
/etc/profile.d/test.sh
/etc/bashrc
[test@whb ~]$ pwd
/home/test
71. sudo
-l
visudo
sudo设置组
两种设置方法
第一种:visudo认可的组,不是真实系统组
User_Alias DEV = dev01,dev02
Cmnd_Alias READ = /bin/cat
DEV ALL=(ALL) NOPASSWD: READ
[root@whb ~]
Last login: Mon Dec 16 18:49:15 CST 2019 on pts/0
[dev01@whb ~]$ sudo -l
Matching Defaults entries for dev01 on whb
User dev01 may run the following commands on whb:
(ALL) NOPASSWD: /bin/cat
[dev01@whb ~]$ logout
[root@whb ~]
Last login: Mon Dec 16 18:51:27 CST 2019 on pts/0
[dev02@whb ~]$ sudo -l
Matching Defaults entries for dev02 on whb
User dev02 may run the following commands on whb:
(ALL) NOPASSWD: /bin/cat
第二种:真实的组
[root@whb ~]
[root@whb ~]
[root@whb ~]
%dev ALL=(ALL) NOPASSWD: READ,SOFTWARE
[root@whb ~]
Last login: Mon Dec 16 19:02:20 CST 2019 on pts/0
[dev01@whb ~]$ sudo -l
Matching Defaults entries for dev01 on whb:
User dev01 may run the following commands on whb:
(ALL) NOPASSWD: /bin/cat, /bin/rpm, /usr/bin/up2date, /usr/bin/yum
72. chmod
-R
第一种设置权限
根据字母设置权限
u 属主的权限
g 属组的权限
o 其它的人的权限
a 所有人的权限
+ 添加权限
- 移除权限
= 覆盖权限
r 读的权限
w 写的权限
x 执行的权限
- 没有权限
[root@whb ~]
[root@whb ~]
total 0
-rwxr--r--. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rwxrw-r--. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rwxrw-r-x. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rwxrw-r--. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rwxrwxr-x. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rw-rw-r--. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-r--r--r--. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rwxr--r--. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rwx--xr--. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rwx--x---. 1 root root 0 Dec 17 17:21 test.txt
第二种
根据数字进行设置权限
[root@whb ~]
total 0
-rwx--x---. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rw-r--r--. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
----------. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rwxrwxrwx. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
total 0
-rwx------. 1 root root 0 Dec 17 17:21 test.txt
[root@whb ~]
[root@whb ~]
drwx------. 2 root root 71 Dec 17 17:42 test
73. chown
#修改属主属组
-R 递归设置
chgrp 只能修改属组
只有root权限才可以任意修改属主属组
普通用户只能修改自己的,普通用户不能使用这个命令
[root@whb /opt]# chown test.test 123
[root@whb /opt]# ll
total 12
-rw-rw--w-. 1 test test 10 Dec 17 18:36 123
-rw-r---w-. 1 test test 9 Dec 17 18:41 passwd
drwxr-x-wx. 2 root root 70 Dec 17 19:04 test
-rw-r---w-. 1 root root 9 Dec 17 18:33 test.txt
[root@whb /opt]# chown yuwei passwd
[root@whb /opt]# ll
total 12
-rw-rw--w-. 1 test test 10 Dec 17 18:36 123
-rw-r---w-. 1 yuwei test 9 Dec 17 18:41 passwd
drwxr-x-wx. 2 root root 70 Dec 17 19:04 test
-rw-r---w-. 1 root root 9 Dec 17 18:33 test.txt
[root@whb /opt]# chown .yuwei 123
[root@whb /opt]# ll
total 12
-rw-rw--w-. 1 test yuwei 10 Dec 17 18:36 123
-rw-r---w-. 1 yuwei test 9 Dec 17 18:41 passwd
drwxr-x-wx. 2 root root 70 Dec 17 19:04 test
-rw-r---w-. 1 root root 9 Dec 17 18:33 test.txt
[root@whb /opt]# chown root:root 123
[root@whb /opt]# ll
total 12
-rw-rw--w-. 1 root root 10 Dec 17 18:36 123
-rw-r---w-. 1 yuwei test 9 Dec 17 18:41 passwd
drwxr-x-wx. 2 root root 70 Dec 17 19:04 test
-rw-r---w-. 1 root root 9 Dec 17 18:33 test.txt
[root@whb /opt]# chown -R test.test test #递归设置
[root@whb /opt]# ll
total 12
-rw-rw--w-. 1 root test 10 Dec 17 18:36 123
-rw-r---w-. 1 yuwei test 9 Dec 17 18:41 passwd
drwxr-x-wx. 2 test test 70 Dec 17 19:04 test
-rw-r---w-. 1 root root 9 Dec 17 18:33 test.txt
[root@whb /opt]# ll test
total 0
-rw-rw-r--. 1 test test 0 Dec 17 19:03 new1.txt
-rw-r--r--. 1 test test 0 Dec 17 18:50 old3.txt
-rw-r--r--. 1 test test 0 Dec 17 18:50 old4.txt
-rw-r--r--. 1 test test 0 Dec 17 18:50 old5.txt
74. chgrp
#修改属组
[root@whb /opt]# chgrp test 123
[root@whb /opt]# ll
total 12
-rw-rw--w-. 1 root test 10 Dec 17 18:36 123
-rw-r---w-. 1 yuwei test 9 Dec 17 18:41 passwd
drwxr-x-wx. 2 root root 70 Dec 17 19:04 test
-rw-r---w-. 1 root root 9 Dec 17 18:33 test.txt
75. umask
系统中,root用户默认的umask值为022,普通用户的umask值为002
umask的计算:
umask是个权限控制的命令,默认的值是022,系统默认创建目录的权限是怎么计算来的,由目录的最大权限777,减去 umask的默认权限,得到的结果就是新创建目录的权限。系统默认创建文件的权限是怎么计算的,由文件的最大权限666, 减去umask的默认权限,得到的结果就是新创建文件的权限。当文件的权限为出现奇数时,会在奇数位上面+1.
[root@whb ~]
[root@whb ~]
[root@whb ~]
total 0
drwxr-xr-x. 2 root root 6 Dec 18 16:58 test
-rw-r--r--. 1 root root 0 Dec 18 16:58 test.log
[root@whb ~]
0022
[root@whb ~]
[root@whb ~]
0033
[root@whb ~]
[root@whb ~]
total 0
drwxr--r--. 2 root root 6 Dec 18 17:06 data
drwxr-xr-x. 2 root root 6 Dec 18 16:58 test
-rw-r--r--. 1 root root 0 Dec 18 16:58 test.log
[root@whb ~]
[root@whb ~]
total 0
drwxr--r--. 2 root root 6 Dec 18 17:06 data
drwxr-xr-x. 2 root root 6 Dec 18 16:58 test
-rw-r--r--. 1 root root 0 Dec 18 16:58 test.log
-rw-r--r--. 1 root root 0 Dec 18 17:06 test.txt
76. setuid、setgid、sticky三种特殊权限,a、i两种特殊属性
setuid
对应的权限数字是 4
[root@whb ~]
-rwxr-xr-x. 1 root root 62952 Oct 31 2018 /usr/bin/rm
[root@whb ~]
[root@whb ~]
-rwsr-xr-x. 1 root root 62952 Oct 31 2018 /usr/bin/rm
[root@whb ~]
File: ‘/usr/bin/rm’
Size: 62952 Blocks: 128 IO Block: 4096 regular file
Device: 803h/2051d Inode: 100686169 Links: 1
Access: (4755/-rwsr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:bin_t:s0
Access: 2019-12-18 03:41:02.098907636 +0800
Modify: 2018-10-31 03:16:01.000000000 +0800
Change: 2019-12-18 17:43:52.450121986 +0800
[test@whb ~]$ rm -rf /opt/
rm: cannot remove ‘/opt/’: Permission denied
[root@whb ~]
total 0
drwxr--r--. 2 root root 6 Dec 18 17:06 data
drwxr-xr-x. 2 root root 6 Dec 18 16:58 test
-rw-r--r--. 1 root root 0 Dec 18 16:58 test.log
-rw-r--r--. 1 root root 0 Dec 18 17:06 test.txt
[root@whb ~]
[root@whb ~]
total 0
drwxr--r--. 2 root root 6 Dec 18 17:06 data
drwxr-xr-x. 2 root root 6 Dec 18 16:58 test
-rwSr--r--. 1 root root 0 Dec 18 16:58 test.log
-rw-r--r--. 1 root root 0 Dec 18 17:06 test.txt
[test@whb ~]$ ll
total 4
-rwSrw-r--. 1 test test 4 Dec 18 17:53 123.txt
[test@whb ~]$ ./123.txt
-bash: ./123.txt: Permission denied
[test@whb ~]$ ll
total 4
-rwxrw-r--. 1 test test 4 Dec 18 17:53 123.txt
[test@whb ~]$ ./123.txt
/home/test
[root@whb ~]
[root@whb ~]
-rwSr--r--. 1 root root 62952 Oct 31 2018 /usr/bin/rm
[root@whb ~]
[root@whb ~]
-bash: /bin/rm: Permission denied
setgid
让一个目录下的所有新创建的目录或者文件的默认组都是该目录的组,而不是创建用户的组
让一个成为共享目录
主要作用于属组的x位
创建2个用户,创建一个目录,让其属主及属组有任何权限,其它人没有权限
[root@whb ~]
[root@whb ~]
[root@whb ~]
Changing password for user test01.
passwd: all authentication tokens updated successfully.
[root@whb ~]
Changing password for user test02.
passwd: all authentication tokens updated successfully.
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
total 0
drwxr-xr-x. 2 root gongxiang 6 Dec 18 18:17 gongxiang
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[test01@whb /opt]$ stat gongxiang/
File: ‘gongxiang/’
Size: 86 Blocks: 0 IO Block: 4096 directory
Device: 803h/2051d Inode: 67753409 Links: 4
Access: (2770/drwxrws---) Uid: ( 0/ root) Gid: ( 2026/gongxiang)
Context: unconfined_u:object_r:usr_t:s0
Access: 2019-12-18 18:48:13.316985658 +0800
Modify: 2019-12-18 18:48:11.411985725 +0800
Change: 2019-12-18 18:48:11.411985725 +0800
Birth: -
[test01@whb /opt/gongxiang]$ touch test01.txt
[test01@whb /opt/gongxiang]$ ll
total 0
-rw-rw-r--. 1 test01 gongxiang 0 Dec 18 18:43 test01.txt
[test01@whb /opt/gongxiang]$ mkdir test01
[test01@whb /opt/gongxiang]$ ll
total 0
drwxrwsr-x. 2 test01 gongxiang 6 Dec 18 18:43 test01
-rw-rw-r--. 1 test01 gongxiang 0 Dec 18 18:43 test01.txt
[test01@whb /opt/gongxiang]$ ll test02
total 0
-rw-rw-r--. 1 test02 gongxiang 0 Dec 18 18:45 test02.log
[test01@whb /opt/gongxiang]$ rm -f test02/test02.log
[test01@whb /opt/gongxiang]$ ll test02
total 0
[test02@whb /opt/gongxiang]$ touch test02.txt
[test02@whb /opt/gongxiang]$ mkdir test02
[test02@whb /opt/gongxiang]$ ll
total 0
drwxrwsr-x. 2 test01 gongxiang 6 Dec 18 18:43 test01
-rw-rw-r--. 1 test01 gongxiang 0 Dec 18 18:43 test01.txt
drwxrwsr-x. 2 test02 gongxiang 6 Dec 18 18:44 test02
-rw-rw-r--. 1 test02 gongxiang 0 Dec 18 18:43 test02.txt
[test02@whb /opt/gongxiang]$ touch test02/test02.log
[test02@whb /opt/gongxiang]$ ll test02
total 0
-rw-rw-r--. 1 test02 gongxiang 0 Dec 18 18:45 test02.log
sticky
主要作用在其他人的x位,t表示
[root@whb ~]
[root@whb ~]
drwxrwxrwx. 2 root root 6 Dec 18 18:58 /test
[root@whb ~]
[root@whb ~]
drwxrwxrwt. 2 root root 6 Dec 18 19:00 /test
[root@whb ~]
File: ‘/test’
Size: 6 Blocks: 0 IO Block: 4096 directory
Device: 803h/2051d Inode: 1083835 Links: 2
Access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2019-12-18 19:00:13.822960217 +0800
Modify: 2019-12-18 19:00:33.146959534 +0800
Change: 2019-12-18 19:01:09.490958251 +0800
Birth: -
[test01@whb ~]$ touch /test/test01.txt
[test01@whb ~]$ ll /test/
total 0
-rw-rw-r--. 1 test01 test01 0 Dec 18 19:01 test01.txt
-rw-rw-r--. 1 test02 test02 0 Dec 18 19:01 test02.txt
[test01@whb ~]$ rm -f /test/test02.txt
rm: cannot remove ‘/test/test02.txt’: Operation not permitted
[test02@whb ~]$ touch /test/test02.txt
[test02@whb ~]$ ll /test/
total 0
-rw-rw-r--. 1 test01 test01 0 Dec 18 19:01 test01.txt
-rw-rw-r--. 1 test02 test02 0 Dec 18 19:01 test02.txt
[test02@whb ~]$ rm -f /test/test01.txt
rm: cannot remove ‘/test/test01.txt’: Operation not permitted
[test02@whb ~]$ rm -f /test/test02.txt
特殊属性不受权限的控制
a
i
[root@whb ~]
-----a---------- test.txt
[root@whb ~]
hostname
[root@whb ~]
whb
[root@whb ~]
[root@whb ~]
rm: cannot remove ‘test.txt’: Operation not permitted
[root@whb ~]
mv: cannot move ‘test.txt’ to ‘/opt/test.txt’: Operation not permitted
[root@whb ~]
[root@whb ~]
[root@whb ~]
hostname
pwd
[root@whb ~]
-bash: test.txt: Operation not permitted
[root@whb ~]
-----a---------- test.txt
[root@whb ~]
[root@whb ~]
---------------- test.txt
[root@whb ~]
[root@whb ~]
hostname
pwd
[root@whb ~]
whb
/root
[root@whb ~]
[root@whb ~]
mv: overwrite ‘/mnt/test.txt’? y
mv: cannot move ‘./test.txt’ to ‘/mnt/test.txt’: Operation not permitted
[root@whb ~]
rm: cannot remove ‘test.txt’: Operation not permitted
[root@whb ~]
-bash: test.txt: Permission denied
[root@whb ~]
-bash: test.txt: Permission denied
77. dd
#生成一个大文件
if #从哪里读取数据
of #输出到哪里
bs #一次输出多少
count #输出的次数
[root@whb ~]# dd if=/dev/zero of=/root/test.log bs=10M count=100
100+0 records in
100+0 records out
1048576000 bytes (1.0 GB) copied, 27.5536 s, 38.1 MB/s
[root@whb ~]# ll -h
total 1001M
-rw-r--r--. 1 root root 143 Dec 19 17:34 file10.txt
-rw-r--r--. 1 root root 51 Dec 19 17:12 file1.txt
-rw-r--r--. 1 root root 2.2K Dec 19 17:05 file2.txt
-rw-r--r--. 1 root root 6 Dec 19 17:05 file3.txt
-rw-r--r--. 1 root root 21 Dec 19 17:07 file4.txt
-rw-r--r--. 1 root root 153 Dec 19 17:16 file5.txt
-rw-r--r--. 1 root root 160 Dec 19 17:25 file6.txt
-rw-r--r--. 1 root root 9 Dec 19 17:30 file7.txt
-rw-r--r--. 1 root root 102 Dec 19 17:30 file8.txt
-rw-r--r--. 1 root root 174 Dec 19 17:33 file9.txt
-rw-r--r--. 1 root root 1000M Dec 19 18:27 test.log
-rwxr-xr-x. 1 root root 143 Dec 19 17:38 test.sh
[root@whb ~]# dd </dev/zero >/root/test.txt bs=10M count=10
10+0 records in
10+0 records out
104857600 bytes (105 MB) copied, 11.6617 s, 9.0 MB/s
[root@whb ~]# ll -h
total 1.1G
-rw-r--r--. 1 root root 143 Dec 19 17:34 file10.txt
-rw-r--r--. 1 root root 51 Dec 19 17:12 file1.txt
-rw-r--r--. 1 root root 2.2K Dec 19 17:05 file2.txt
-rw-r--r--. 1 root root 6 Dec 19 17:05 file3.txt
-rw-r--r--. 1 root root 21 Dec 19 17:07 file4.txt
-rw-r--r--. 1 root root 153 Dec 19 17:16 file5.txt
-rw-r--r--. 1 root root 160 Dec 19 17:25 file6.txt
-rw-r--r--. 1 root root 9 Dec 19 17:30 file7.txt
-rw-r--r--. 1 root root 102 Dec 19 17:30 file8.txt
-rw-r--r--. 1 root root 174 Dec 19 17:33 file9.txt
-rw-r--r--. 1 root root 1000M Dec 19 18:27 test.log
-rwxr-xr-x. 1 root root 143 Dec 19 17:38 test.sh
-rw-r--r--. 1 root root 100M Dec 19 18:28 test.txt
78. xargs
[root@whb ~]
[root@whb ~]
[root@whb ~]
oldgirl
oldgirl
oldgirl
oldgirl
79. find
find命令可以根据不同的条件来进行查找文件,例如:文件名称、文件大小、文件修改时间、属主属组、权限、等等方式。
Find 命令的基本语法如下:
命令 路径 选项 表达式 动作
find [path...] [options] [expression] [action]
查找 地区 妹纸 18-25岁 约?
Find命令的实例
1.根据名称查找
-name
-iname
[root@whb ~]
/etc/sysconfig/network-scripts/ifcfg-eth0
[root@whb ~]
/etc/sysconfig/network-scripts/ifcfg-eth0
[root@whb ~]
/etc/sysconfig/network-scripts/ifcfg-lo
/etc/sysconfig/network-scripts/ifcfg-eth0
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
/root/oldboy
/root/OLDBOY
[root@whb ~]
/root/oldboyp
/root/oldboyr
/root/oldboyt
/root/oldboyv
[root@whb ~]
/root/oldboya
/root/oldboyb
/root/oldboyc
[root@whb ~]
/root/oldboya
/root/oldboye
/root/oldboyf
[root@whb ~]
/root/oldboya
/root/oldboyb
/root/oldboyc
/root/oldboyd
/root/oldboye
[root@whb ~]
/root/oldboyp
/root/oldboyr
/root/oldboyt
[root@whb ~]
2.根据文件类型查找
-type
f
d
l
b
c
s
p
[root@whb ~]
34367466 4 -rw-r--r-- 1 test test 9 Dec 18 19:16 /tmp/test.txt
67753454 0 -rw-r--r-- 1 root root 0 Dec 17 18:50 /tmp/old2.txt
34367457 0 -rw-rw-r-- 1 test01 test01 0 Dec 18 18:56 /tmp/test01.txt
[root@whb ~]
33554504 4 drwxrwxrwt 16 root root 4096 Dec 20 03:24 /tmp
67323676 0 drwxrwxrwt 2 root root 6 Nov 26 20:23 /tmp/.X11-unix
[root@whb ~]
67831367 0 lrwxrwxrwx 1 root root 6 Dec 20 17:20 /root/old -> oldboy
[root@whb ~]
18135 0 brw-rw---- 1 root disk 8, 3 Nov 28 18:49 /dev/sda3
18134 0 brw-rw---- 1 root disk 8, 2 Nov 28 18:49 /dev/sda2
18133 0 brw-rw---- 1 root disk 8, 1 Nov 28 18:49 /dev/sda1
18073 0 brw-rw---- 1 root cdrom 11, 0 Nov 28 18:49 /dev/sr0
17960 0 brw-rw---- 1 root disk 8, 0 Nov 28 18:49 /dev/sda
[root@whb ~]
34439 0 crw------- 1 root root 10, 56 Nov 28 18:49 /dev/vsock
34275 0 crw-rw---- 1 root tty 7, 134 Nov 28 18:49 /dev/vcsa6
34272 0 crw-rw---- 1 root tty 7, 6 Nov 28 18:49 /dev/vcs6
34269 0 crw-rw---- 1 root tty 7, 133 Nov 28 18:49 /dev/vcsa5
34266 0 crw-rw---- 1 root tty 7, 5 Nov 28 18:49 /dev/vcs5
[root@whb ~]
8942 0 srw-rw-rw- 1 root root 0 Nov 28 18:49 /dev/log
[root@whb ~]
2238497 0 prw------- 1 root root 0 Dec 18 19:23 /run/systemd/ask-password-block/136:1
57568 0 prw------- 1 root root 0 Nov 28 23:26 /run/systemd/ask-password-block/136:0
2308173 0 prw------- 1 root root 0 Dec 19 11:14 /run/systemd/inhibit/2.ref
2330900 0 prw------- 1 root root 0 Dec 19 16:20 /run/systemd/sessions/540.ref
21279 0 prw------- 1 root root 0 Nov 28 18:49 /run/systemd/initctl/fifo
3.
-maxdepth
-mindepth
[root@whb ~]
/etc/chkconfig.d
/etc/pm/config.d
/etc/sysconfig
/etc/sysconfig/ip6tables-config
/etc/sysconfig/iptables-config
/etc/sysconfig/ebtables-config
/etc/sysconfig/authconfig
/etc/pam.d/config-util
/etc/ssh/ssh_config
/etc/ssh/sshd_config
/etc/selinux/config
[root@whb ~]
/etc/fstab
/etc/crypttab
/etc/resolv.conf
/etc/shells
/etc/libaudit.conf
4.根据属主属组查找
-user
-group
-nouser
-nogroup
[root@whb ~]
33932521 0 drwx------ 2 tom tom 62 Dec 20 01:43 /home/tom
33934918 4 -rw-r--r-- 1 tom tom 18 Oct 31 2018 /home/tom/.bash_logout
33934919 4 -rw-r--r-- 1 tom tom 193 Oct 31 2018 /home/tom/.bash_profile
33934920 4 -rw-r--r-- 1 tom tom 231 Oct 31 2018 /home/tom/.bashrc
[root@whb ~]
1083832 0 drwx------ 2 tomcat apps 62 Dec 20 01:29 /home/tomcat
1083834 4 -rw-r--r-- 1 tomcat apps 18 Oct 31 2018 /home/tomcat/.bash_logout
1083863 4 -rw-r--r-- 1 tomcat apps 193 Oct 31 2018 /home/tomcat/.bash_profile
1083864 4 -rw-r--r-- 1 tomcat apps 231 Oct 31 2018 /home/tomcat/.bashrc
[root@whb ~]
34350047 0 drwx------ 2 yw1 yw 62 Dec 16 17:02 /home/yw1
34350048 4 -rw-r--r-- 1 yw1 yw 18 Oct 31 2018 /home/yw1/.bash_logout
34350055 4 -rw-r--r-- 1 yw1 yw 193 Oct 31 2018 /home/yw1/.bash_profile
34350059 4 -rw-r--r-- 1 yw1 yw 231 Oct 31 2018 /home/yw1/.bashrc
[root@whb ~]
34350047 0 drwx------ 2 yw1 yw 62 Dec 16 17:02 /home/yw1
34350048 4 -rw-r--r-- 1 yw1 yw 18 Oct 31 2018 /home/yw1/.bash_logout
34350055 4 -rw-r--r-- 1 yw1 yw 193 Oct 31 2018 /home/yw1/.bash_profile
34350059 4 -rw-r--r-- 1 yw1 yw 231 Oct 31 2018 /home/yw1/.bashrc
[root@whb ~]
34350047 0 drwx------ 2 yw1 yw 62 Dec 16 17:02 /home/yw1
34350048 4 -rw-r--r-- 1 yw1 yw 18 Oct 31 2018 /home/yw1/.bash_logout
34350055 4 -rw-r--r-- 1 yw1 yw 193 Oct 31 2018 /home/yw1/.bash_profile
34350059 4 -rw-r--r-- 1 yw1 yw 231 Oct 31 2018 /home/yw1/.bashrc
67753412 0 drwx------ 2 yw1 apps 62 Dec 16 17:02 /home/yw2
67753414 4 -rw-r--r-- 1 yw1 apps 18 Oct 31 2018 /home/yw2/.bash_logout
67753415 4 -rw-r--r-- 1 yw1 apps 193 Oct 31 2018 /home/yw2/.bash_profile
67753416 4 -rw-r--r-- 1 yw1 apps 231 Oct 31 2018 /home/yw2/.bashrc
1083832 0 drwx------ 2 tomcat apps 62 Dec 20 01:29 /home/tomcat
1083834 4 -rw-r--r-- 1 tomcat apps 18 Oct 31 2018 /home/tomcat/.bash_logout
1083863 4 -rw-r--r-- 1 tomcat apps 193 Oct 31 2018 /home/tomcat/.bash_profile
1083864 4 -rw-r--r-- 1 tomcat apps 231 Oct 31 2018 /home/tomcat/.bashrc
[root@whb ~]
34350047 0 drwx------ 2 2014 yw 62 Dec 16 17:02 /home/yw1
34350048 4 -rw-r--r-- 1 2014 yw 18 Oct 31 2018 /home/yw1/.bash_logout
34350055 4 -rw-r--r-- 1 2014 yw 193 Oct 31 2018 /home/yw1/.bash_profile
34350059 4 -rw-r--r-- 1 2014 yw 231 Oct 31 2018 /home/yw1/.bashrc
67753412 0 drwx------ 2 2014 2029 62 Dec 16 17:02 /home/yw2
67753414 4 -rw-r--r-- 1 2014 2029 18 Oct 31 2018 /home/yw2/.bash_logout
67753415 4 -rw-r--r-- 1 2014 2029 193 Oct 31 2018 /home/yw2/.bash_profile
67753416 4 -rw-r--r-- 1 2014 2029 231 Oct 31 2018 /home/yw2/.bashrc
1083832 0 drwx------ 2 2025 2029 62 Dec 20 01:29 /home/tomcat
1083834 4 -rw-r--r-- 1 2025 2029 18 Oct 31 2018 /home/tomcat/.bash_logout
1083863 4 -rw-r--r-- 1 2025 2029 193 Oct 31 2018 /home/tomcat/.bash_profile
1083864 4 -rw-r--r-- 1 2025 2029 231 Oct 31 2018 /home/tomcat/.bashrc
33934918 4 -rw-r--r-- 1 2030 2034 18 Oct 31 2018 /home/tom/.bash_logout
33934919 4 -rw-r--r-- 1 2030 2034 193 Oct 31 2018 /home/tom/.bash_profile
33934920 4 -rw-r--r-- 1 2030 2034 231 Oct 31 2018 /home/tom/.bashrc
[root@whb ~]
67753412 0 drwx------ 2 2014 2029 62 Dec 16 17:02 /home/yw2
67753414 4 -rw-r--r-- 1 2014 2029 18 Oct 31 2018 /home/yw2/.bash_logout
67753415 4 -rw-r--r-- 1 2014 2029 193 Oct 31 2018 /home/yw2/.bash_profile
67753416 4 -rw-r--r-- 1 2014 2029 231 Oct 31 2018 /home/yw2/.bashrc
1083832 0 drwx------ 2 2025 2029 62 Dec 20 01:29 /home/tomcat
1083834 4 -rw-r--r-- 1 2025 2029 18 Oct 31 2018 /home/tomcat/.bash_logout
1083863 4 -rw-r--r-- 1 2025 2029 193 Oct 31 2018 /home/tomcat/.bash_profile
1083864 4 -rw-r--r-- 1 2025 2029 231 Oct 31 2018 /home/tomcat/.bashrc
33932521 0 drwx------ 2 root 2034 62 Dec 20 01:43 /home/tom
33934918 4 -rw-r--r-- 1 2030 2034 18 Oct 31 2018 /home/tom/.bash_logout
33934919 4 -rw-r--r-- 1 2030 2034 193 Oct 31 2018 /home/tom/.bash_profile
33934920 4 -rw-r--r-- 1 2030 2034 231 Oct 31 2018 /home/tom/.bashrc
[root@whb ~]
67753412 0 drwx------ 2 2014 2029 62 Dec 16 17:02 /home/yw2
67753414 4 -rw-r--r-- 1 2014 2029 18 Oct 31 2018 /home/yw2/.bash_logout
67753415 4 -rw-r--r-- 1 2014 2029 193 Oct 31 2018 /home/yw2/.bash_profile
67753416 4 -rw-r--r-- 1 2014 2029 231 Oct 31 2018 /home/yw2/.bashrc
1083832 0 drwx------ 2 2025 2029 62 Dec 20 01:29 /home/tomcat
1083834 4 -rw-r--r-- 1 2025 2029 18 Oct 31 2018 /home/tomcat/.bash_logout
1083863 4 -rw-r--r-- 1 2025 2029 193 Oct 31 2018 /home/tomcat/.bash_profile
1083864 4 -rw-r--r-- 1 2025 2029 231 Oct 31 2018 /home/tomcat/.bashrc
33934918 4 -rw-r--r-- 1 2030 2034 18 Oct 31 2018 /home/tom/.bash_logout
33934919 4 -rw-r--r-- 1 2030 2034 193 Oct 31 2018 /home/tom/.bash_profile
33934920 4 -rw-r--r-- 1 2030 2034 231 Oct 31 2018 /home/tom/.bashrc
[root@whb ~]
33932521 0 drwx------ 2 root 2034 62 Dec 20 01:43 /home/tom
[root@whb ~]
34350047 0 drwx------ 2 2014 yw 62 Dec 16 17:02 /home/yw1
34350048 4 -rw-r--r-- 1 2014 yw 18 Oct 31 2018 /home/yw1/.bash_logout
34350055 4 -rw-r--r-- 1 2014 yw 193 Oct 31 2018 /home/yw1/.bash_profile
34350059 4 -rw-r--r-- 1 2014 yw 231 Oct 31 2018 /home/yw1/.bashrc
67753412 0 drwx------ 2 2014 2029 62 Dec 16 17:02 /home/yw2
67753414 4 -rw-r--r-- 1 2014 2029 18 Oct 31 2018 /home/yw2/.bash_logout
67753415 4 -rw-r--r-- 1 2014 2029 193 Oct 31 2018 /home/yw2/.bash_profile
67753416 4 -rw-r--r-- 1 2014 2029 231 Oct 31 2018 /home/yw2/.bashrc
1083832 0 drwx------ 2 2025 2029 62 Dec 20 01:29 /home/tomcat
1083834 4 -rw-r--r-- 1 2025 2029 18 Oct 31 2018 /home/tomcat/.bash_logout
1083863 4 -rw-r--r-- 1 2025 2029 193 Oct 31 2018 /home/tomcat/.bash_profile
1083864 4 -rw-r--r-- 1 2025 2029 231 Oct 31 2018 /home/tomcat/.bashrc
33932521 0 drwx------ 2 root 2034 62 Dec 20 01:43 /home/tom
33934918 4 -rw-r--r-- 1 2030 2034 18 Oct 31 2018 /home/tom/.bash_logout
33934919 4 -rw-r--r-- 1 2030 2034 193 Oct 31 2018 /home/tom/.bash_profile
33934920 4 -rw-r--r-- 1 2030 2034 231 Oct 31 2018 /home/tom/.bashrc
5.根据文件大小查找
-size
[root@whb ~]
33602690 0 -rw------- 1 root root 0 Nov 26 20:22 /var/log/tallylog
33989594 0 -rw------- 1 root root 0 Nov 26 20:28 /var/log/anaconda/ks-script-7paxdQ.log
33718871 0 -rw------- 1 root root 0 Nov 29 03:15 /var/log/boot.log
33989610 0 -rw-r--r-- 1 root root 0 Nov 26 20:30 /var/log/firewalld
33705523 0 -rw-r----- 1 mysql mysql 0 Nov 26 22:23 /var/log/mariadb/mariadb.log
[root@whb ~]
-rw-------. 1 root root 27K Nov 26 20:28 /var/log/anaconda/anaconda.log
-rw-------. 1 root root 4.0K Nov 26 20:28 /var/log/anaconda/ifcfg.log
[root@whb ~]
-rw-------. 1 root root 22K Nov 26 20:28 /var/log/anaconda/X.log
[root@whb ~]
-rw-r--r--. 1 root root 1.3M Dec 20 18:23 /var/log/123.log
-rw-r--r--. 1 root root 3.2M Dec 20 18:23 /var/log/456.log
-rw-------. 1 root root 1.5M Nov 26 20:28 /var/log/anaconda/journal.log
-rw-------. 1 root root 2.2M Dec 20 18:04 /var/log/audit/audit.log
-rw-r--r--. 1 root root 581K Dec 20 01:53 /var/log/lastlog
-rw-------. 1 root root 644K Dec 1 03:12 /var/log/messages-20191201
-rw-r--r--. 1 root root 9.8M Dec 20 18:22 /var/log/test.log
[root@whb ~]
-rw-r--r--. 1 root root 3.2M Dec 20 18:23 /var/log/456.log
-rw-------. 1 root root 2.2M Dec 20 18:04 /var/log/audit/audit.log
-rw-r--r--. 1 root root 9.8M Dec 20 18:22 /var/log/test.log
[root@whb ~]
dr-xr-x---. 4 root root 4.0K Dec 20 18:35 ./
drwxr-xr-x. 2 root root 6 Dec 8 00:54 ./.123
-rw-r--r--. 1 root root 1.3M Dec 20 18:35 ./123.log
-rw-------. 1 root root 22K Dec 19 12:55 ./.bash_history
-rw-r--r--. 1 root root 18 Dec 29 2013 ./.bash_logout
-rw-r--r--. 1 root root 212 Dec 16 17:31 ./.bash_profile
-rw-r--r--. 1 root root 192 Dec 16 17:31 ./.bashrc
-rw-r--r--. 1 root root 100 Dec 29 2013 ./.cshrc
-rw-------. 1 root root 1.5M Dec 20 18:35 ./journal.log
-rw-r--r--. 1 root root 581K Dec 20 18:35 ./lastlog
-rw-------. 1 root root 40 Dec 2 19:52 ./.lesshst
-rw-------. 1 root root 644K Dec 20 18:35 ./messages-20191201
drwxr-----. 3 root root 19 Nov 26 21:51 ./.pki
drwxr-----. 2 root root 6 Nov 26 21:51 ./.pki/nssdb
-rw-r--r--. 1 root root 129 Dec 29 2013 ./.tcshrc
-rw-------. 1 root root 5.5K Dec 19 18:35 ./.viminfo
[root@whb ~]
-rw-r--r--. 1 root root 1.3M Dec 20 18:35 ./123.log
-rw-------. 1 root root 1.5M Dec 20 18:35 ./journal.log
[root@whb ~]
-rw-------. 1 root root 109K Nov 26 20:28 /var/log/anaconda/packaging.log
-rw-------. 1 root root 122K Nov 26 20:28 /var/log/anaconda/storage.log
-rw-------. 1 root root 274K Nov 26 20:28 /var/log/anaconda/syslog
-rw-r--r--. 1 root root 121K Nov 28 18:49 /var/log/dmesg
-rw-r--r--. 1 root root 121K Nov 28 18:48 /var/log/dmesg.old
[root@whb ~]
-rw-------. 1 root root 109K Nov 26 20:28 /var/log/anaconda/packaging.log
-rw-------. 1 root root 122K Nov 26 20:28 /var/log/anaconda/storage.log
-rw-------. 1 root root 274K Nov 26 20:28 /var/log/anaconda/syslog
-rw-r--r--. 1 root root 121K Nov 28 18:49 /var/log/dmesg
-rw-r--r--. 1 root root 121K Nov 28 18:48 /var/log/dmesg.old
[root@whb ~]
-rw-r--r--. 1 root root 1.3M Dec 20 18:23 /var/log/123.log
-rw-r--r--. 1 root root 3.2M Dec 20 18:23 /var/log/456.log
-rw-------. 1 root root 1.5M Nov 26 20:28 /var/log/anaconda/journal.log
-rw-------. 1 root root 0 Nov 26 20:28 /var/log/anaconda/ks-script-7paxdQ.log
-rw-------. 1 root root 2.2M Dec 20 18:04 /var/log/audit/audit.log
-rw-------. 1 root root 0 Nov 29 03:15 /var/log/boot.log
-rw-r--r--. 1 root root 0 Nov 26 20:30 /var/log/firewalld
-rw-------. 1 root root 0 Dec 15 03:26 /var/log/maillog
-rw-------. 1 root root 0 Dec 1 03:12 /var/log/maillog-20191208
-rw-------. 1 root root 0 Dec 8 03:47 /var/log/maillog-20191215
-rw-r-----. 1 mysql mysql 0 Nov 26 22:23 /var/log/mariadb/mariadb.log
-rw-------. 1 root root 0 Dec 15 03:26 /var/log/spooler
-rw-------. 1 root root 0 Nov 26 20:24 /var/log/spooler-20191201
-rw-------. 1 root root 0 Dec 1 03:12 /var/log/spooler-20191208
-rw-------. 1 root root 0 Dec 8 03:47 /var/log/spooler-20191215
-rw-------. 1 root root 0 Nov 26 20:22 /var/log/tallylog
-rw-r--r--. 1 root root 9.8M Dec 20 18:22 /var/log/test.log
[root@whb ~]
drwxr-xr-x. 2 root root 176 Nov 26 20:28 /var/log/anaconda
-rw-------. 1 root root 0 Nov 26 20:28 /var/log/anaconda/ks-script-7paxdQ.log
drwx------. 2 root root 23 Nov 26 20:30 /var/log/audit
-rw-------. 1 root root 0 Nov 29 03:15 /var/log/boot.log
-rw-------. 1 root utmp 384 Nov 27 19:51 /var/log/btmp-20191201
-rw-r--r--. 1 root root 2 Dec 20 18:25 /var/log/file.log
-rw-r--r--. 1 root root 0 Nov 26 20:30 /var/log/firewalld
-rw-r--r--. 1 root root 193 Nov 26 20:22 /var/log/grubby_prune_debug
6.根据文件的权限搜索
-perm
[root@whb ~]
67514410 4 -rw-r--r-- 1 root root 18 Dec 29 2013 ./.bash_logout
67514413 4 -rw-r--r-- 1 root root 100 Dec 29 2013 ./.cshrc
67514414 4 -rw-r--r-- 1 root root 129 Dec 29 2013 ./.tcshrc
67753426 4 -rw-r--r-- 1 root root 192 Dec 16 17:31 ./.bashrc
67753430 4 -rw-r--r-- 1 root root 212 Dec 16 17:31 ./.bash_profile
67831363 3220 -rw-r--r-- 1 root root 3295805 Dec 20 18:35 ./456.log
67157603 84 -rw-r--r-- 1 root root 594512 Dec 20 18:35 ./lastlog
67831361 10000 -rw-r--r-- 1 root root 10240000 Dec 20 18:35 ./test.log
67831362 1288 -rw-r--r-- 1 root root 1318322 Dec 20 18:35 ./123.log
[root@whb ~]
67514410 4 -rw-r--r-- 1 root root 18 Dec 29 2013 ./.bash_logout
67514413 4 -rw-r--r-- 1 root root 100 Dec 29 2013 ./.cshrc
67514414 4 -rw-r--r-- 1 root root 129 Dec 29 2013 ./.tcshrc
101325675 0 drwxr-xr-x 2 root root 6 Dec 8 00:54 ./.123
67753426 4 -rw-r--r-- 1 root root 192 Dec 16 17:31 ./.bashrc
67753430 4 -rw-r--r-- 1 root root 212 Dec 16 17:31 ./.bash_profile
67831363 3220 -rw-r--r-- 1 root root 3295805 Dec 20 18:35 ./456.log
67157603 84 -rw-r--r-- 1 root root 594512 Dec 20 18:35 ./lastlog
67831361 10000 -rw-r--r-- 1 root root 10240000 Dec 20 18:35 ./test.log
67831362 1288 -rw-r--r-- 1 root root 1318322 Dec 20 18:35 ./123.log
[root@whb ~]
[root@whb ~]
67514410 4 -rw-r--r-- 1 root root 18 Dec 29 2013 ./.bash_logout
67514413 4 -rw-r--r-- 1 root root 100 Dec 29 2013 ./.cshrc
67514414 4 -rw-r--r-- 1 root root 129 Dec 29 2013 ./.tcshrc
67305630 24 -rw------- 1 root root 21553 Dec 19 12:55 ./.bash_history
67305662 4 -rw------- 1 root root 40 Dec 2 19:52 ./.lesshst
67753426 4 -rw-r--r-- 1 root root 192 Dec 16 17:31 ./.bashrc
67753430 4 -rw-r--r-- 1 root root 212 Dec 16 17:31 ./.bash_profile
67831363 3220 -rw-r--r-- 1 root root 3295805 Dec 20 18:35 ./456.log
[root@whb ~]
100790550 24 -rws--x--x 1 root root 24048 Oct 31 2018 /usr/bin/chfn
100790553 24 -rws--x--x 1 root root 23960 Oct 31 2018 /usr/bin/chsh
100738359 32 -rwsr-xr-x 1 root root 32096 Oct 31 2018 /usr/bin/fusermount
100741593 80 -rwsr-xr-x 1 root root 78272 Oct 31 2018 /usr/bin/gpasswd
100741595 44 -rwsr-xr-x 1 root root 41872 Oct 31 2018 /usr/bin/newgrp
[root@whb ~]
9195 0 drwxr-sr-x 3 root systemd-journal 60 Nov 28 18:49 /run/log/journal
100686869 16 -r-xr-sr-x 1 root tty 15344 Jun 10 2014 /usr/bin/wall
100808435 20 -rwxr-sr-x 1 root tty 19624 Oct 31 2018 /usr/bin/write
100960081 376 ---x--s--x 1 root nobody 382240 Apr 11 2018 /usr/bin/ssh-agent
[root@whb ~]
8425 0 drwxrwxrwt 2 root root 40 Nov 28 18:49 /dev/mqueue
8648 0 drwxrwxrwt 2 root root 40 Nov 28 18:49 /dev/shm
69 0 drwxrwxrwt 6 root root 277 Dec 17 18:41 /var/tmp
34102535 0 drwxrwxrwt 2 root root 6 Nov 26 23:10 /var/tmp/systemd-private-
7.根据文件的最后的修改时间查找
-mtime
[root@whb ~]
[root@whb ~]
[root@whb ~]
67514410 4 -rw-r--r-- 1 root root 18 Dec 29 2013 ./.bash_logout
67514413 4 -rw-r--r-- 1 root root 100 Dec 29 2013 ./.cshrc
67514414 4 -rw-r--r-- 1 root root 129 Dec 29 2013 ./.tcshrc
33557678 0 drwxr----- 3 root root 19 Nov 26 21:51 ./.pki
67157653 0 drwxr----- 2 root root 6 Nov 26 21:51 ./.pki/nssdb
67305662 4 -rw------- 1 root root 40 Dec 2 19:52 ./.lesshst
101325675 0 drwxr-xr-x 2 root root 6 Dec 8 00:54 ./.123
67560146 0 -rw-r--r-- 1 root root 0 Dec 1 00:00 ./file-01.txt
67560147 0 -rw-r--r-- 1 root root 0 Dec 2 00:00 ./file-02.txt
67831365 0 -rw-r--r-- 1 root root 0 Dec 3 00:00 ./file-03.txt
67831367 0 -rw-r--r-- 1 root root 0 Dec 4 00:00 ./file-04.txt
67831369 0 -rw-r--r-- 1 root root 0 Dec 5 00:00 ./file-05.txt
67831370 0 -rw-r--r-- 1 root root 0 Dec 6 00:00 ./file-06.txt
67831371 0 -rw-r--r-- 1 root root 0 Dec 7 00:00 ./file-07.txt
67299630 0 -rw-r--r-- 1 root root 0 Dec 8 00:00 ./file-08.txt
67831372 0 -rw-r--r-- 1 root root 0 Dec 9 00:00 ./file-09.txt
67831373 0 -rw-r--r-- 1 root root 0 Dec 10 00:00 ./file-10.txt
67831374 0 -rw-r--r-- 1 root root 0 Dec 11 00:00 ./file-11.txt
67831375 0 -rw-r--r-- 1 root root 0 Dec 12 00:00 ./file-12.txt
[root@whb ~]
67831364 0 -rw-r--r-- 1 root root 0 Dec 13 00:00 ./file-13.txt
[root@whb ~]
67157601 4 dr-xr-x--- 4 root root 4096 Dec 20 00:00 ./
67305630 24 -rw------- 1 root root 21553 Dec 19 12:55 ./.bash_history
67753426 4 -rw-r--r-- 1 root root 192 Dec 16 17:31 ./.bashrc
67753430 4 -rw-r--r-- 1 root root 212 Dec 16 17:31 ./.bash_profile
67831363 3220 -rw-r--r-- 1 root root 3295805 Dec 20 2019 ./456.log
67831377 0 -rw-r--r-- 1 root root 0 Dec 14 00:00 ./file-14.txt
67831378 0 -rw-r--r-- 1 root root 0 Dec 15 00:00 ./file-15.txt
67831379 0 -rw-r--r-- 1 root root 0 Dec 16 00:00 ./file-16.txt
67831380 0 -rw-r--r-- 1 root root 0 Dec 17 00:00 ./file-17.txt
67831381 0 -rw-r--r-- 1 root root 0 Dec 18 00:00 ./file-18.txt
67831382 0 -rw-r--r-- 1 root root 0 Dec 19 00:00 ./file-19.txt
67831383 0 -rw-r--r-- 1 root root 0 Dec 20 00:00 ./file-20.txt
67815503 8 -rw------- 1 root root 5632 Dec 19 18:35 ./.viminfo
67157603 84 -rw-r--r-- 1 root root 594512 Dec 20 2019 ./lastlog
67157611 2156 -rw------- 1 root root 2206893 Dec 20 2019 ./audit.log
67157612 1520 -rw------- 1 root root 1552850 Dec 20 2019 ./journal.log
67831360 644 -rw------- 1 root root 659161 Dec 20 2019 ./messages-20191201
67831361 10000 -rw-r--r-- 1 root root 10240000 Dec 20 2019 ./test.log
67831362 1288 -rw-r--r-- 1 root root 1318322 Dec 20 2019 ./123.log
[root@whb ~]
67831377 0 -rw-r--r-- 1 root root 0 Dec 14 00:00 ./file-14.txt
67831378 0 -rw-r--r-- 1 root root 0 Dec 15 00:00 ./file-15.txt
67831379 0 -rw-r--r-- 1 root root 0 Dec 16 00:00 ./file-16.txt
Find命令的动作
-print
-ls
-delete
-ok
-exec
;是shell命令的分隔符,\取消其特殊含义
[root@whb ~]
[root@whb ~]
total 18912
-rw-r--r--. 1 root root 1318322 Dec 20 2019 123.log
-rw-r--r--. 1 root root 3295805 Dec 20 2019 456.log
-rw-------. 1 root root 2206893 Dec 20 2019 audit.log
[root@whb ~]
find: cannot delete ‘./test01’: Directory not empty
-ok
[root@whb ~]
< ls ... ./456.log > ? y
-rw-r--r--. 1 root root 3.2M Dec 20 2019 ./456.log
< ls ... ./audit.log > ? y
-rw-------. 1 root root 2.2M Dec 20 2019 ./audit.log
< ls ... ./journal.log > ? y
-rw-------. 1 root root 1.5M Dec 20 2019 ./journal.log
< ls ... ./test.log > ? y
-rw-r--r--. 1 root root 9.8M Dec 20 2019 ./test.log
< ls ... ./123.log > ? y
-rw-r--r--. 1 root root 1.3M Dec 20 2019 ./123.log
-exec
;是shell命令的分隔符,\取消其特殊含义
[root@whb ~]
-rw-r--r--. 1 root root 3.2M Dec 20 2019 ./456.log
-rw-------. 1 root root 2.2M Dec 20 2019 ./audit.log
-rw-------. 1 root root 1.5M Dec 20 2019 ./journal.log
-rw-r--r--. 1 root root 9.8M Dec 20 2019 ./test.log
-rw-r--r--. 1 root root 1.3M Dec 20 2019 ./123.log
Find命令跟xargs的配合使用
[root@whb ~]
-rw-r--r--. 1 root root 1.3M Dec 20 2019 ./123.log
-rw-r--r--. 1 root root 3.2M Dec 20 2019 ./456.log
-rw-------. 1 root root 2.2M Dec 20 2019 ./audit.log
-rw-------. 1 root root 22K Dec 19 12:55 ./.bash_history
-rw-r--r--. 1 root root 212 Dec 16 17:31 ./.bash_profile
-rw-r--r--. 1 root root 192 Dec 16 17:31 ./.bashrc
[root@whb ~]
[root@whb ~]
-I 将find命令查找出来的文件进行统一赋值给{},后续的命令进行调用该{}.
[root@whb ~]
[root@whb ~]
20M /root
644K /root/test01
[root@whb ~]
20M /root
80. zip/unzip
zip
-r
-q
unzip
-d
-l
-p
81. gzip
-d
-r
-rd
82. zcat
83. tar
c
z
j
J
f
v
cjf
cJf
t
tf
x
xf
P
h
-C
X
--exclude=
--exclude-from=
实例1:打包软连接文件
[root@whb ~]
tar: Removing leading `/' from member names
实例2:排除文件
方法一:
#排除单个文件
[root@whb ~]# tar czf etc-2.tar.gz --exclude=/etc/services /etc
tar: Removing leading `/' from member names
[root@whb ~]
tar: Removing leading `/' from member names
#排除两个不同路径的文件
[root@whb ~]# tar czf etc-4.tar.gz --exclude=/etc/services -- exclude=/etc/firewalld/services /etc
tar: Removing leading `/' from member names
[root@whb ~]
/etc/services
/etc/passwd
/etc/sysconfig/network-scripts
/etc/hosts
[root@whb ~]
tar: Removing leading `/' from member names
方法二:压缩包名要跟f选项对应 X要跟排除列表文件对应
[root@whb ~]# tar czfX etc-6.tar.gz paichu.list /etc
tar: Removing leading `/' from member names
84. date
[root@whb ~]
Tue Dec 24 20:16:20 CST 2019
[root@whb ~]
2019-12-24
[root@whb ~]
20:17:52
[root@whb ~]
2019-12-24
[root@whb ~]
19-12-24
[root@whb ~]
20:20:18
[root@whb ~]
1577190037
[root@whb ~]
2
[root@whb ~]
51
[root@whb ~]
358
-d
[root@whb ~]
2019-12-24
[root@whb ~]
2019-12-25
[root@whb ~]
2019-12-24
[root@whb ~]
2019-12-23
[root@whb ~]
2018-12-24
[root@whb ~]
2019-11-24
-s
[root@whb ~]
Tue Oct 1 00:00:00 CST 2019
[root@whb ~]
2019-10-01
[root@whb ~]
Sun Dec 1 00:00:00 CST 2019
[root@whb ~]
2019-12-01
[root@whb ~]
Sun Dec 1 12:26:00 CST 2019
[root@whb ~]
Tue Dec 24 12:27:00 CST 2019
[root@whb ~]
2019-12-24
[root@whb ~]
Tue Dec 24 12:27:10 CST 2019
85. rpm
#基于本地的rpm包进行管理
-i 安装rpm包
-v 显示安装过程
-h 显示安装的进度
-R 显示依赖环境
-e 卸载rpm包
-U 升级rpm包
-q 查询软件包是否安装
-qa 查询所有的已安装的软件包
-ql 查看软件包中的列表信息
-qc 查看软件包的相关配置文件
-qi 显示软件包的本身信息
-qf 查看命令属于哪个软件包
-qR 依赖查看软件包的所有
86. yum
选项:
repolist
enabled
disabled
all
install
-y
--downloadonly
--downloaddir
list
installed
updates
check-update
update
info
provides
search
remove
erase
clean
packages
all
plugins
makecache
reinstall
localinstall
history
list
all
info id
undo id
groups
install
remove
yum-config-manage
--disable 仓库名称
--enable 仓库名称
[root@whb ~]
Loaded plugins: fastestmirror
ID | Command line | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
26 | history undo 22 | 2019-12-25 12:30 | Erase | 1
25 | groups remove -y Python | 2019-12-25 12:27 | Erase | 10
24 | groups install -y Python | 2019-12-25 12:26 | I, U | 34
23 | localinstall -y /opt/gpm | 2019-12-25 12:25 | Install | 4
87. fdisk
选项:
-l
fdisk -l [-u] [device...]
[root@whb ~]
内置命令:
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition 注:这是删除一个分区的动作;
l list known partition types 注:l是列出分区类型,以供我们设置相应分区的类型;
m print this menu 注:m 是列出帮助信息;
n add a new partition 注:添加一个分区;
o create a new empty DOS partition table
p print the partition table 注:p列出分区表;
q quit without saving changes 注:不保存退出;
s create a new empty Sun disklabel
t change a partition's system id 注:t 改变分区类型;
u change display/entry units
v verify the partition table
w write table to disk and exit 注:把分区表写入硬盘并退出;
x extra functionality (experts only) 注:扩展应用,专家功能;
88. gdisk
需要安装软件包
yum install gdisk -y
[root@whb ~]
内置命令:
b back up GPT data to a file
c change a partition's name
d delete a partition 注:这是删除一个分区的动作;
i show detailed information on a partition
l list known partition types 注:l是列出分区类型,以供我们设置相应分区的类型;
n add a new partition 注:添加一个分区;
o create a new empty GUID partition table (GPT)
p print the partition table 注:p列出分区表;
q quit without saving changes 注:不保存退出;
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code 注:t 改变分区类型;
v verify disk
w write table to disk and exit 注:把分区表写入硬盘并退出;
x extra functionality (experts only) 注:扩展应用,专家功能;
? print this menu 注:? 是列出帮助信息;
89. lsblk
选项:
-d :仅列出磁盘本身,并不会列出该磁盘的分区数据
-f :同时列出该磁盘内的文件系统名称
-i :使用 ASCII 的线段输出,不要使用复杂的编码 (再某些环境下很有用)
-m :同时输出该设备在 /dev 下面的权限数据 (rwx 的数据)
-p :列出该设备的完整文件名!而不是仅列出最后的名字而已。
-t :列出该磁盘设备的详细数据,包括磁盘伫列机制、预读写的数据量大小等
90. df
选项:
-a 显示所有文件系统信息,包括系统特有的 /proc、/sysfs 等文件系统;
-m 以 MB 为单位显示容量;
-k 以 KB 为单位显示容量,默认以 KB 为单位;
-h 使用人们习惯的 KB、MB 或 GB 等单位自行显示容量;
-T 显示该分区的文件系统名称;
-i 不用硬盘容量显示,而是以含有 inode 的数量来显示。
91. partprobe
92. mount/umount
mount
语法: 命令 + 选项 + 设备 + 挂点
选项:
-a
-o
-t
umount
-l
93. blkid
[root@whb ~]
/dev/sr0: UUID="2018-11-25-23-54-16-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/sda1: UUID="896d3614-9743-4709-99fa-977a20abf0e2" TYPE="xfs"
/dev/sda2: UUID="93217f0f-86ad-40a5-bc6e-2ccced2cd67e" TYPE="swap"
/dev/sda3: UUID="00b4a22f-777b-40d6-9ddb-19aa801935b7" TYPE="xfs"
/dev/sdb1: UUID="9hvCgN-vtv8-jN1f-2bIl-38HZ-3Mu0-IkpKkp" TYPE="LVM2_member"
/dev/mapper/storage-datastore: UUID="fb201310-1e5b-4610-8f77-f7de5599c515" TYPE="xfs"
94. free
选项:
-m
-h
-k
-g
-b
-t
-s
free -c N:表示重复打印内存信息N次
95. swapon/swapoff
swapon
选项:
-a 将/etc/fstab文件中所有设置为swap的设备,启动为交换区;
-p<优先顺序>:指定交换区的优先顺序;
-s 显示交换区的使用状况;
语法:
swapon (选项)(参数)
实例:
swapoff
选项:
-a 关闭配置文件“/etc/fstab”中所有的交换空间。
语法:
swapoff (选项) (参数)
实例:关闭交换分区
swapoff /dev/sda2
96. crontab
语法:
crontab [ -u user ] file
crontab [ -u user ] { -l | -r | -e }
选项:
-e
-l
-r
97. uname
语法:
uname (选项)
选项:
-a或--all:显示全部的信息;
-m或--machine:显示电脑类型;
-n或-nodename:显示在网络上的主机名称;
-r或--release:显示操作系统的发行编号;
-s或--sysname:显示操作系统名称;
-v:显示操作系统的版本;
-p或--processor:输出处理器类型或"unknown";
-i或--hardware-platform:输出硬件平台或"unknown";
-o或--operating-system:输出操作系统名称;
--help:显示帮助;
--version:显示版本信息;
98. ps
选项:
a 显示所有进程
u 显示用户等信息
x 显示没有控制终端地进程
o 显示指定的进程信息,例如:user,pid,nice,command等
-e 显示所有进程,环境变量
-f 显示更多信息
---------------------------------------------------------------------------
[root@whb ~]
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.4 128144 4844 ? Ss 2019 1:27 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root 2 0.0 0.0 0 0 ? S 2019 0:00 [kthreadd]
---------------------------------------------------------------------------
USER
PID
%CPU
%MEM
VSZ
RSS
TTY
?
tty1
pts/0
pts/1
STAT
S
s
R
D
T
Z
l
<
N
+
START
TIME
COMMAND
有[]
无[]
99. top
选项:
-d
-u
-p
内部命令:
q
h
z
b
s
M
P
1
top - 15:59:24 up 1:27, 2 users, load average: 0.00, 0.01, 0.05
Tasks: 107 total, 1 running, 106 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.3 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 995896 total, 773060 free, 95312 used, 127524 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 749820 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6053 root 20 0 300720 6328 4976 S 0.7 0.6 0:04.84 vmtoolsd
1 root 20 0 125432 3784 2572 S 0.0 0.4 0:01.77 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
---------------------------------------------------------------------------
top - 11:30:21 up 5 days, 23:38, 3 users, load average: 0.00, 0.01, 0.05
11:30:21
up 5 days, 23:38,
3 users,
load average: 0.00, 0.01, 0.05
---------------------------------------------------------------------------
Tasks: 107 total, 1 running, 106 sleeping, 0 stopped, 0 zombie
Tasks
126 total,
2 running,
123 sleeping,
1 stopped,
0 zombie
---------------------------------------------------------------------------
%Cpu(s): 0.3 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu(s):
0.3 us,
0.0 sy,
0.0 ni,
99.7 id,
0.0 wa,
0.0 hi,
0.0 si,
0.0 st
---------------------------------------------------------------------------
KiB Mem : 995896 total, 121784 free, 134100 used, 740012 buff/cache
物理内存: 总的内存空间 空闲的内存空间 已使用的内存空间 缓冲和缓存所占用的内存空间
---------------------------------------------------------------------------
KiB Swap: 3121144 total, 3060984 free, 60160 used. 595240 avail Mem
虚拟内存 总的内存空间 空闲的内存空间 已使用的内存空间 可使用的内存空间
---------------------------------------------------------------------------
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
PID
USER
PR
NI
VIRT
RES
SHR
S
%CPU
%MEM
TIME+
COMMAND
100. htop
101. kill、killall、pkill
kill
信号:
1) SIGHUP
2) SIGINT
9) SIGKILL
15) SIGTERM
20) SIGTSTP
实例:
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
[root@whb ~]
killall
实例:
[root@whb ~]
[root@whb ~]
[root@whb ~]
top: no process found
pkill
102. bg、fg、jobs
jobs
bg %ID
fg %ID
实例:
[root@whb ~]
[1]+ Stopped vim test.txt
[root@whb ~]
[1]+ vim test.txt &
[root@whb ~]
[1]+ Stopped vim test.txt
[root@whb ~]
vim test.txt
[1]+ Stopped vim test.txt
[root@whb ~]
[2]+ tar czPf etc2.tar.gz /etc/ /var/ &
[root@whb ~]
[1]+ Stopped vim test.txt
[2]- Running tar czPf etc2.tar.gz /etc/ /var/ &
103. nohup
nohup
&
104. screen
ctrl键+a+d
exit
选项:
-r
-S
-x
-ls或-list
实例:
[root@whb ~]
There is a screen on:
8431.pts-0.whb (Detached)
1 Socket in /var/run/screen/S-root.
[root@whb ~]
[screen is terminating]
[root@whb ~]
[root@whb ~]
No Sockets found in /var/run/screen/S-root.
[root@whb ~]
[root@whb ~]
There is a screen on:
8770.tar (Detached)
1 Socket in /var/run/screen/S-root.
[root@whb ~]
[root@whb ~]
105. nice/renice
nice
[root@whb ~]
renice
[root@whb ~]
4361 (process ID) old priority -20, new priority 0