LINUX 728 SHELL:grep;sort;diff
shell
grep
grep [选项] ‘关键字’ 文件名
根据关键字进行行过滤
-i
不区分大小写
grep -i root passwd
[root@web tmp]# grep -i root passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
您在 /var/spool/mail/root 中有邮件
-w
按单词搜索
过滤出 含 特定关键词的行
grep -w root passwd
[root@web tmp]# grep -w ftp passwd
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
您在 /var/spool/mail/root 中有邮件
-wo
按单词搜索打印
过滤出特定关键词 打印
[root@web tmp]# grep -wo ftp passwd
ftp
ftp
-n
显示行号
过滤出含有特定关键词 并显示行号
grep -n ftp passwd
[root@web tmp]# grep -n root passwd
1:root:x:0:0:root:/root:/bin/bash
10:operator:x:11:0:operator:/root:/sbin/nologin
-ni
不区分大小写 显示行号
过滤出关键词 不区分关键词大小写,并显示行号
grep -ni root passwd
[root@web tmp]# grep -ni root passwd
1:root:x:0:0:root:/root:/bin/bash
10:operator:x:11:0:operator:/root:/sbin/nologin
-nic
不区分大小写显示行号统计匹配到的行数
过滤关键词 过滤结果:不区分大小写,显示行号,统计含结果行的次数
grep -nic root passwd
[root@web tmp]# grep -nic root passwd
2
忽略大小写统计匹配到关键词的行数
^root
以root关键词开头的行
过滤以root关键词开头的行
-i ^root
过滤出以root关键词开头的行 不区分结果大小写
[root@web tmp]# grep -i ^root passwd
root:x:0:0:root:/root:/bin/bash
bash$
以bash结尾
过滤出 以bash 结尾 的行
grep bash$ passwd
[root@web tmp]# grep bash$ passwd
root:x:0:0:root:/root:/bin/bash
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
cao1:x:1004:1223::/home/cao1:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
cw01:x:1010:1224::/home/cw01:/bin/bash
sc01:x:1011:1226::/home/sc01:/bin/bash
rs01:x:1012:1225::/home/rs01:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
netasha:x:1018:1018::/home/netasha:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
user01:x:1024:1024::/home/user01:/bin/bash
^$
匹配空行
-n ^$
显示行号 匹配空行
grep -n ^$ passwd
-v
不包含指定内容的行
grep -v ^# root passwd
过滤出 不含以root开头 的行
[root@web tmp]# grep ^# /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
# Uncomment this to enable any form of FTP write command.
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
#
# Activate logging of uploads/downloads.
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -v ^# /etc/vsftpd/vsftpd.conf
anonymous_enable=no
local_enable=yes
local_root=/data/kefu2
chroot_local_user=YES
allow_writeable_chroot=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YESpam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
-A 数字
-A 5
关键词及其后五行
grep -A 5 mail passwd
[root@web tmp]# grep -A 5 mail passwd
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
您在 /var/spool/mail/root 中有邮件
-B 数字
-B 数字
过滤含关键词以及前五行
grep -B 5 mail passwd
[root@web tmp]# grep -B 5 mail passwd
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
-C 数字
-C 数字
过滤 含关键词以及前后五行
grep -C 5 mail passwd
[root@web tmp]# grep -C 5 mail passwd
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
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
您在 /var/spool/mail/root 中有邮件
cut
cut 选项 文件名
对文件的列进行截取
-d
以字符为内容 对列进行分割,截取
: -f1
以冒号分割 截取第一列
[root@web tmp]# cut -d: -f1 1.txt
112
12
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
: f1,6,7
以:分割 截取 1,6,7列
[root@web tmp]# cut -d: -f1,6,7 1.txt
112
12:3123
123123213123
2112:!@#!@:#
21312312:#!@:#
12312312123122121312312:!@#@!
213123:@!#213:@!#12
123123:123123:@!3123
213213:!@312:!@#12
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
-c
以字符为单位进行分割,截取
-c4
截取每行第四个字符
cut -c4 1.txt
[root@web tmp]# cut -c4 1.txt
:
3
1
2
1
1
1
1
2
23111
3
1
-c1-4
每行第1-4个字符
cut -c1-4 1.txt
[root@web tmp]# cut -c1-4 1.txt
112:
12:3
1231
2112
2131
1231
2131
1231
2132
1232
2
3213
21
32
312
3
1231
3
12311231
3123
1231
-c4-10
4-10
[root@web tmp]# cut -c4-10 1.txt
:2223:3
3:2:1:3
1232131
2:123:!
12312:S
1231212
123::::
123:!@#
213:123
21331231231231123123212321
312312
123
-c5-
第5个字符开始截取后面字符
[root@web tmp]# cut -c5- 1.xt
cut: 1.xt: 没有那个文件或目录
[root@web tmp]# cut -c5- 1.txt
2223:333213
:2:1:312:3123
23213123:123
:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
2312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
2312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
23::::!@#@!#:@!#213:@!#12
23:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
13:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
131232312312231232132321
12312
23
您在 /var/spool/mail/root 中有邮件
系统运行级别
runlevel
/etc/inittab
[root@web tmp]# runlevel |cut -c3
5
[root@web tmp]# runlevel | cut -d ' ' -f2
5
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -v '^#' /etc/inittab |cut -d: -f2
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep '^id' /etc/inittab |cut -d: -f2
[root@web tmp]# grep "initdefault:$" /etc/inittab |cut -c4
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -v ^# /etc/inittab |cut -c4
[root@web tmp]# grep 'id:' /etc/inittab |cut -d: -f2
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d':' -f2 /etc/inittab |grep -v ^#analogous to runlevel 3analogous to runlevel 5[root@web tmp]# cut -c4 /etc/inittab |tail -1您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d: -f2 /etc/inittab |tail -1
#
[root@web tmp]# cat /etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#
[root@web tmp]# sort -n -t: -k3 1.txt
sort
排序,按ASCLL码升序输出
-K
按第k列
-n
以数字排序,默认按字符排序
[root@web tmp]# sort -n 1.txt2
3
3
12:3:2:1:312:3123
21
32
112:2223:333213
312
2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
123123
123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
123213
213123::::!@#@!#:@!#213:@!#12
213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
3213123
12312321
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
312312312
12312312312
123123123213
123123213123:123
12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
-t
分隔符
-t:
以:为分隔符
-k3
第3列
-n -t: -k3
以:为分割符第三列数字进行升序排序
[root@web tmp]# sort -n -t: -k3 passwd
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
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
mysql:x:1003:1003::/home/mysql:/sbin/nologin
cao1:x:1004:1223::/home/cao1:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
cw01:x:1010:1224::/home/cw01:/bin/bash
sc01:x:1011:1226::/home/sc01:/bin/bash
rs01:x:1012:1225::/home/rs01:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
netasha:x:1018:1018::/home/netasha:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
user01:x:1024:1024::/home/user01:/bin/bash
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
您在 /var/spool/mail/root 中有邮件
-r
降序排列
[root@web tmp]# sort -nr 1.txt
12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
123123213123:123
123123123213
12312312312
312312312
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
12312321
3213123
213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
213123::::!@#@!#:@!#213:@!#12
123213
123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
123123
2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
312
112:2223:333213
32
21
12:3:2:1:312:3123
3
3
2
[root@web tmp]# sort -nru passwd
root:x:0:0:root:/root:/bin/bash
-nr t: -k3
sort -nr t: -k3 passwd
以分割符:为分割第三列的数字降序排列
[root@web tmp]# sort -nr -t: -k3 passwd
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
user01:x:1024:1024::/home/user01:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
netasha:x:1018:1018::/home/netasha:/bin/bash
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
rs01:x:1012:1225::/home/rs01:/bin/bash
sc01:x:1011:1226::/home/sc01:/bin/bash
cw01:x:1010:1224::/home/cw01:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
cao1:x:1004:1223::/home/cao1:/bin/bash
mysql:x:1003:1003::/home/mysql:/sbin/nologin
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
halt:x:7:0:halt:/sbin:/sbin/halt
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
sync:x:5:0:sync:/sbin:/bin/sync
lp:x:4:7:lp:/var/spool/lpd:/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
您在 /var/spool/mail/root 中有邮件
-u
去重
-nu
按数字排序 并去除重复
[root@web tmp]# sort -nu 1.txt2
3
12:3:2:1:312:3123
21
32
112:2223:333213
312
2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
123213
213123::::!@#@!#:@!#213:@!#12
213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
3213123
12312321
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
312312312
12312312312
123123123213
123123213123:123
12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
-o
类似于> 将结果输出到文件中
sort -nu 2.txt -o 3.txt
将2.txt 的数字进行升序排列并将结果输出到3.txt中
[root@web tmp]# sort -n 1.txt -o 2.txt
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat 2.txt2
3
3
12:3:2:1:312:3123
21
32
112:2223:333213
312
2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
123123
123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
123213
213123::::!@#@!#:@!#213:@!#12
213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
3213123
12312321
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
312312312
12312312312
123123123213
123123213123:123
12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
-R
随机排序 每次结果不同
[root@web tmp]# sort -R passwd
adm:x:3:4:adm:/var/adm:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
jack:x:1009:1009::/home/jack:/bin/bash
dbus:x:81:81:System message bus:/:/sbin/nologin
kefu2:x:1023:1023::/home/kefu2:/bin/bash
halt:x:7:0:halt:/sbin:/sbin/halt
netasha:x:1018:1018::/home/netasha:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
cw01:x:1010:1224::/home/cw01:/bin/bash
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
rs01:x:1012:1225::/home/rs01:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
cao2:x:1005:1005::/home/cao2:/bin/bash
mysql:x:1003:1003::/home/mysql:/sbin/nologin
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
user01:x:1024:1024::/home/user01:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
nobody:x:99:99:Nobody:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
sc01:x:1011:1226::/home/sc01:/bin/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
OOO:x:1020:1020::/home/OOO:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
cao1:x:1004:1223::/home/cao1:/bin/bash
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
jerry:x:1021:1229::/home/jerry:/bin/bash
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# sort -u passwd
abrt:x:173:173::/etc/abrt:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
bin:x:1:1:bin:/bin:/sbin/nologin
boss01:x:1013:1004::/home/boss01:/bin/bash
cao1:x:1004:1223::/home/cao1:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
cw01:x:1010:1224::/home/cw01:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
daemon:x:2:2:daemon:/sbin:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
halt:x:7:0:halt:/sbin:/sbin/halt
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
mysql:x:1003:1003::/home/mysql:/sbin/nologin
netasha:x:1018:1018::/home/netasha:/bin/bash
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
OOO:x:1020:1020::/home/OOO:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
rs01:x:1012:1225::/home/rs01:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
sarsh:x:1019:1228::/home/sarsh:/bin/bash
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
sc01:x:1011:1226::/home/sc01:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
tom:x:1008:1008::/home/tom:/bin/bash
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
user01:x:1024:1024::/home/user01:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
diff
逐行比较文件不同
改变第一个文件后与第二个文件匹配
diff [选项] 文件1 文件2
diff file1 file2
[root@web tmp]# vim file1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat file1
aaaa
111
hello world
222
333
bbb
[root@web tmp]# vim file2
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat file2
aaa
hello
111
222
bbb
333
world
[root@web tmp]# diff file1 file2
1c1,2
< aaaa
---
> aaa
> hello
3d3
< hello world
5d4
< 333
6a6,7
> 333
> world
您在 /var/spool/mail/root 中有邮件
-c
上下文格式显示
[root@web tmp]# diff -c file1 file2
*** file1 2025-07-28 21:16:13.339673496 +0800
--- file2 2025-07-28 21:18:14.421741193 +0800
***************
*** 1,6 ****
! aaaa111
- hello world222
- 333bbb
--- 1,7 ----
! aaa
! hello111222bbb
+ 333
+ world
-u
合并格式显示
diff dir1 dir2
比较目录
[root@web tmp]# diff dir1 dir2
只在 dir1 存在:file1
只在 dir2 存在:file2
-q
只比较文件异同 不比较文件内容
diff -q /dir1 /dir2
[root@web tmp]# diff -q dir1 dir2
只在 dir1 存在:file1
只在 dir2 存在:file2
-N
将不存在的文件当作空文件
diff -uN file1 file2 > file.patch
上下文模式 合并显示 比较文件不同 并输出到file.patch 中
[root@web tmp]# diff -uN file1 file2 >file.patch
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat file.patch
--- file1 2025-07-28 21:49:34.727561012 +0800
+++ file2 2025-07-28 21:18:14.421741193 +0800
@@ -1,6 +1,7 @@
-aaaa
+aaa
+hello111
-hello world222
-333bbb
+333
+world
patch
将不同内容打补丁
patch file1 file.patch
[root@web tmp]# patch file1 file.patch
patching file file1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# diff file1 file2
问题
[root@web tmp]# cat 1.txt
1122223333213
123213123123
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
[root@web tmp]# cut -d: -f1 1.txt
1122223333213
123213123123
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# mkdir dir1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# mkdir dir2
[root@web tmp]# mv ~/file1 /dir1
mv: 无法获取"/root/file1" 的文件状态(stat): 没有那个文件或目录
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# mv file1 ~/dir1
[root@web tmp]# ls dir1
[root@web tmp]# find ~/ -n file1
find: 未知的断言“-n”
您在 /var/spool/mail/root 中有邮件
[root@web tmp]#
diff 这块怎么比的再看看
记录
root@192.168.235.20's password:┌────────────────────────────────────────────────────────────────────┐│ • MobaXterm 20.0 • ││ (SSH client, X-server and networking tools) ││ ││ ➤ SSH session to root@192.168.235.20 ││ • SSH compression : ✘ ││ • SSH-browser : ✔ ││ • X11-forwarding : ✔ (remote display is forwarded through SSH) ││ • DISPLAY : ✔ (automatically set on remote server) ││ ││ ➤ For more info, ctrl+click on help or visit our website │└────────────────────────────────────────────────────────────────────┘Last login: Thu Jul 24 19:37:23 2025 from 192.168.235.1
[root@web ~]# alias grep='grep --color=auto'
[root@web ~]# cat /etc/bashrc
# /etc/bashrc# System wide functions and aliases
# Environment stuff goes in /etc/profile# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.# are we an interactive shell?
if [ "$PS1" ]; thenif [ -z "$PROMPT_COMMAND" ]; thencase $TERM inxterm*|vte*)if [ -e /etc/sysconfig/bash-prompt-xterm ]; thenPROMPT_COMMAND=/etc/sysconfig/bash-prompt-xtermelif [ "${VTE_VERSION:-0}" -ge 3405 ]; thenPROMPT_COMMAND="__vte_prompt_command"elsePROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'fi;;screen*)if [ -e /etc/sysconfig/bash-prompt-screen ]; thenPROMPT_COMMAND=/etc/sysconfig/bash-prompt-screenelsePROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'fi;;*)[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default;;esacfi# Turn on parallel historyshopt -s histappendhistory -a# Turn on checkwinsizeshopt -s checkwinsize[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "# You might want to have e.g. tty in prompt (e.g. more virtual machines)# and console windows# If you want to do so, just add e.g.# if [ "$PS1" ]; then# PS1="[\u@\h:\l \W]\\$ "# fi# to your custom modification shell script in /etc/profile.d/ directory
fiif ! shopt -q login_shell ; then # We're not a login shell# Need to redefine pathmunge, it get's undefined at the end of /etc/profilepathmunge () {case ":${PATH}:" in*:"$1":*);;*)if [ "$2" = "after" ] ; thenPATH=$PATH:$1elsePATH=$1:$PATHfiesac}# By default, we want umask to get set. This sets it for non-login shell.# Current threshold for system reserved uid/gids is 200# You could check uidgid reservation validity in# /usr/share/doc/setup-*/uidgid fileif [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; thenumask 002elseumask 022fiSHELL=/bin/bash# Only display echos from profile.d scripts if we are no login shell# and interactive - otherwise just process them to set envvarsfor i in /etc/profile.d/*.sh; doif [ -r "$i" ]; thenif [ "$PS1" ]; then. "$i"else. "$i" >/dev/nullfifidoneunset iunset -f pathmunge
fi
# vim:ts=4:sw=4
[root@web ~]# vim /etc/bashrc
您在 /var/spool/mail/root 中有新邮件
[root@web ~]# vim /etc/bashrc
您在 /var/spool/mail/root 中有邮件
[root@web ~]# vim /etc/bashrc
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat /etc/bashrc
# /etc/bashrc# System wide functions and aliases
# Environment stuff goes in /etc/profile# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.# are we an interactive shell?
if [ "$PS1" ]; thenif [ -z "$PROMPT_COMMAND" ]; thencase $TERM inxterm*|vte*)if [ -e /etc/sysconfig/bash-prompt-xterm ]; thenPROMPT_COMMAND=/etc/sysconfig/bash-prompt-xtermelif [ "${VTE_VERSION:-0}" -ge 3405 ]; thenPROMPT_COMMAND="__vte_prompt_command"elsePROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'fi;;screen*)if [ -e /etc/sysconfig/bash-prompt-screen ]; thenPROMPT_COMMAND=/etc/sysconfig/bash-prompt-screenelsePROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'fi;;*)[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default;;esacfi# Turn on parallel historyshopt -s histappendhistory -a# Turn on checkwinsizeshopt -s checkwinsize[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "# You might want to have e.g. tty in prompt (e.g. more virtual machines)# and console windows# If you want to do so, just add e.g.# if [ "$PS1" ]; then# PS1="[\u@\h:\l \W]\\$ "# fi# to your custom modification shell script in /etc/profile.d/ directory
fiif ! shopt -q login_shell ; then # We're not a login shell# Need to redefine pathmunge, it get's undefined at the end of /etc/profilepathmunge () {case ":${PATH}:" in*:"$1":*);;*)if [ "$2" = "after" ] ; thenPATH=$PATH:$1elsePATH=$1:$PATHfiesac}# By default, we want umask to get set. This sets it for non-login shell.# Current threshold for system reserved uid/gids is 200# You could check uidgid reservation validity in# /usr/share/doc/setup-*/uidgid fileif [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; thenumask 002elseumask 022fiSHELL=/bin/bash# Only display echos from profile.d scripts if we are no login shell# and interactive - otherwise just process them to set envvarsfor i in /etc/profile.d/*.sh; doif [ -r "$i" ]; thenif [ "$PS1" ]; then. "$i"else. "$i" >/dev/nullfifidoneunset iunset -f pathmunge
fi
# vim:ts=4:sw=4
alias grep='grep --color=auto'
[root@web ~]# source /etc/bashrc
[root@web ~]# tail -6 /etc/passwd
sarsh:x:1019:1228::/home/sarsh:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
user01:x:1024:1024::/home/user01:/bin/bash
[root@web ~]# cd /user01
-bash: cd: /user01: 没有那个文件或目录
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cd /home/user01
[root@web user01]# vim ~/.bashrc
您在 /var/spool/mail/root 中有邮件
[root@web user01]# cat ~/.bashrc
# .bashrc# Source global definitions
if [ -f /etc/bashrc ]; then. /etc/bashrc
fi# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=# User specific aliases and functions
alias grep='grep --color=auto'
[root@web user01]# source ~/.bashrc
[root@web user01]# cd /etc/passwd /tmp
-bash: cd: /etc/passwd: 不是目录
您在 /var/spool/mail/root 中有邮件
[root@web user01]# cp /etc/passwd /tmp
[root@web user01]# cd /tmp
[root@web tmp]# find -name passwd
./passwd
[root@web tmp]# cd passwd
-bash: cd: passwd: 不是目录
[root@web tmp]# grep -i root passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -w ftp passwd
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -w hello passwd
[root@web tmp]# grep -w hello passwd
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -wo ftp passwd
ftp
ftp
[root@web tmp]# grep -n root passwd
1:root:x:0:0:root:/root:/bin/bash
10:operator:x:11:0:operator:/root:/sbin/nologin
[root@web tmp]# grep -ni root passwd
1:root:x:0:0:root:/root:/bin/bash
10:operator:x:11:0:operator:/root:/sbin/nologin
[root@web tmp]# grep -nic root passwd
2
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -i ^root passwd
root:x:0:0:root:/root:/bin/bash
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep bash$ passwd
root:x:0:0:root:/root:/bin/bash
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
cao1:x:1004:1223::/home/cao1:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
cw01:x:1010:1224::/home/cw01:/bin/bash
sc01:x:1011:1226::/home/sc01:/bin/bash
rs01:x:1012:1225::/home/rs01:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
netasha:x:1018:1018::/home/netasha:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
user01:x:1024:1024::/home/user01:/bin/bash
[root@web tmp]# grep -n ^$ passwd
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -n ^$ passwd
[root@web tmp]# grep ^# /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
# Uncomment this to enable any form of FTP write command.
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
#
# Activate logging of uploads/downloads.
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -v ^# /etc/vsftpd/vsftpd.conf
anonymous_enable=no
local_enable=yes
local_root=/data/kefu2
chroot_local_user=YES
allow_writeable_chroot=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YESpam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
[root@web tmp]# grep -A 5 mail passwd
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
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -B 5 mail passwd
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
[root@web tmp]# grep -C 5 mail passwd
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
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
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# touch 1.txt
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# vim 1.txt
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat 1.txt
1122223333213
123213123123
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
[root@web tmp]# cut -d: -f1 1.txt
1122223333213
123213123123
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
[root@web tmp]# cut -d: -f1 1.txt
1122223333213
123213123123
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
[root@web tmp]# cut -d: -f1,6,7 1.txt
1122223333213
123213123123
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d: -f1 1/txt
cut: 1/txt: 没有那个文件或目录
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d: -f1 1.txt
1122223333213
123213123123
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d
cut:选项需要一个参数 -- d
Try 'cut --help' for more information.
[root@web tmp]#
[root@web tmp]# cut -d: -f1,6,7 1.txt
1122223333213
123213123123
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
[root@web tmp]# cut -c1- 5 1.txt
cut: 5: 没有那个文件或目录
1122223333213
123213123123
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -c1-5 1.txt
11222
12321
12312
2112
21312
12312
21312
12312
21321
12321
2
32131
21
32
312
3
12312
3
1231212312
31231
12312
[root@web tmp]# cut -c1-2 1.txt
11
12
12
21
21
12
21
12
21
12
2
32
21
32
31
3
12
3
1212
31
12
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# vim 1.txt
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d: -f1 1.txt
112
12
123123213123
2112
21312312
12312312123122121312312
213123
123123
213213
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d: -f1,6,7 1.txt
112
12:3123
123123213123
2112:!@#!@:#
21312312:#!@:#
12312312123122121312312:!@#@!
213123:@!#213:@!#12
123123:123123:@!3123
213213:!@312:!@#12
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
[root@web tmp]# cut -c4 1.txt
:
3
1
2
1
1
1
1
2
23111
3
1
[root@web tmp]# cut -c1-4 1.txt
112:
12:3
1231
2112
2131
1231
2131
1231
2132
1232
2
3213
21
32
312
3
1231
3
12311231
3123
1231
[root@web tmp]# cut -c4-10 1.txt
:2223:3
3:2:1:3
1232131
2:123:!
12312:S
1231212
123::::
123:!@#
213:123
21331231231231123123212321
312312
123
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -c5- 1.xt
cut: 1.xt: 没有那个文件或目录
[root@web tmp]# cut -c5- 1.txt
2223:333213
:2:1:312:3123
23213123:123
:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
2312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
2312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
23::::!@#@!#:@!#213:@!#12
23:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
13:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
131232312312231232132321
12312
23
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# runlevel |cut -c3
5
[root@web tmp]# runlevel | cut -d ' ' -f2
5
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -v '^#' /etc/inittab |cut -d: -f2
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep '^id' /etc/inittab |cut -d: -f2
[root@web tmp]# grep "initdefault:$" /etc/inittab |cut -c4
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# grep -v ^# /etc/inittab |cut -c4
[root@web tmp]# grep 'id:' /etc/inittab |cut -d: -f2
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d':' -f2 /etc/inittab |grep -v ^#analogous to runlevel 3analogous to runlevel 5[root@web tmp]# cut -c4 /etc/inittab |tail -1您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d: -f2 /etc/inittab |tail -1
#
[root@web tmp]# cat /etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#
[root@web tmp]# sort -n -t: -k3 1.txt123123
12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
12312312312
123123123213
12312321
123123213123:123
123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
123213
2
21
2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
213123::::!@#@!#:@!#213:@!#12
213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
3
3
312
312312312
32
3213123
12:3:2:1:312:3123
112:2223:333213
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat -d: -f1 passwd
cat:无效选项 -- d
Try 'cat --help' for more information.
[root@web tmp]# cut -d: -f1 passwd
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
operator
games
ftp
nobody
systemd-network
dbus
polkitd
libstoragemgmt
colord
rpc
saned
gluster
saslauth
abrt
setroubleshoot
rtkit
pulse
radvd
chrony
unbound
qemu
tss
sssd
usbmuxd
geoclue
ntp
gdm
rpcuser
nfsnobody
gnome-initial-setup
sshd
avahi
postfix
tcpdump
caozx26
apache
XOAP
mysql
cao1
cao2
xiaocao
xiao6
tom
jack
cw01
sc01
rs01
boss01
cw02
sc02
rs02
harry
netasha
sarsh
OOO
jerry
kefu
kefu2
user01
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -d: -f1,6,7 1.txt
112
12:3123
123123213123
2112:!@#!@:#
21312312:#!@:#
12312312123122121312312:!@#@!
213123:@!#213:@!#12
123123:123123:@!3123
213213:!@312:!@#12
123213
2
3213123
21
32
312
3
12312312312
3
12312312321312312321
312312312
123123
[root@web tmp]# cut -d: -f1,6,7 passwd
root:/root:/bin/bash
bin:/bin:/sbin/nologin
daemon:/sbin:/sbin/nologin
adm:/var/adm:/sbin/nologin
lp:/var/spool/lpd:/sbin/nologin
sync:/sbin:/bin/sync
shutdown:/sbin:/sbin/shutdown
halt:/sbin:/sbin/halt
mail:/var/spool/mail:/sbin/nologin
operator:/root:/sbin/nologin
games:/usr/games:/sbin/nologin
ftp:/var/ftp:/sbin/nologin
nobody:/:/sbin/nologin
systemd-network:/:/sbin/nologin
dbus:/:/sbin/nologin
polkitd:/:/sbin/nologin
libstoragemgmt:/var/run/lsm:/sbin/nologin
colord:/var/lib/colord:/sbin/nologin
rpc:/var/lib/rpcbind:/sbin/nologin
saned:/usr/share/sane:/sbin/nologin
gluster:/run/gluster:/sbin/nologin
saslauth:/run/saslauthd:/sbin/nologin
abrt:/etc/abrt:/sbin/nologin
setroubleshoot:/var/lib/setroubleshoot:/sbin/nologin
rtkit:/proc:/sbin/nologin
pulse:/var/run/pulse:/sbin/nologin
radvd:/:/sbin/nologin
chrony:/var/lib/chrony:/sbin/nologin
unbound:/etc/unbound:/sbin/nologin
qemu:/:/sbin/nologin
tss:/dev/null:/sbin/nologin
sssd:/:/sbin/nologin
usbmuxd:/:/sbin/nologin
geoclue:/var/lib/geoclue:/sbin/nologin
ntp:/etc/ntp:/sbin/nologin
gdm:/var/lib/gdm:/sbin/nologin
rpcuser:/var/lib/nfs:/sbin/nologin
nfsnobody:/var/lib/nfs:/sbin/nologin
gnome-initial-setup:/run/gnome-initial-setup/:/sbin/nologin
sshd:/var/empty/sshd:/sbin/nologin
avahi:/var/run/avahi-daemon:/sbin/nologin
postfix:/var/spool/postfix:/sbin/nologin
tcpdump:/:/sbin/nologin
caozx26:/home/caozx26:/bin/bash
apache:/usr/share/httpd:/sbin/nologin
XOAP:/rhome/XOAP:/bin/bash
mysql:/home/mysql:/sbin/nologin
cao1:/home/cao1:/bin/bash
cao2:/home/cao2:/bin/bash
xiaocao:/home/xiaocao:/bin/bash
xiao6:/home/xiao6:/bin/bash
tom:/home/tom:/bin/bash
jack:/home/jack:/bin/bash
cw01:/home/cw01:/bin/bash
sc01:/home/sc01:/bin/bash
rs01:/home/rs01:/bin/bash
boss01:/home/boss01:/bin/bash
cw02:/home/cw02:/bin/bash
sc02:/home/sc02:/bin/bash
rs02:/home/rs02:/bin/bash
harry:/home/mahei/redhat/harry:/bin/bash
netasha:/home/netasha:/bin/bash
sarsh:/home/sarsh:/bin/bash
OOO:/home/OOO:/bin/bash
jerry:/home/jerry:/bin/bash
kefu:/home/kefu:/bin/bash
kefu2:/home/kefu2:/bin/bash
user01:/home/user01:/bin/bash
[root@web tmp]# cut -c4 passwd
t
:
m
:
x
c
t
t
l
r
e
:
o
t
s
k
s
o
:
e
s
l
t
r
i
s
v
o
o
u
:
d
m
c
:
:
u
n
m
d
h
t
d
z
c
P
q
1
2
o
o
:
k
1
1
1
s
2
2
2
r
a
s
:
r
u
u
r
[root@web tmp]# cut -c1-4 passwd
root
bin:
daem
adm:
lp:x
sync
shut
halt
mail
oper
game
ftp:
nobo
syst
dbus
polk
libs
colo
rpc:
sane
glus
sasl
abrt
setr
rtki
puls
radv
chro
unbo
qemu
tss:
sssd
usbm
geoc
ntp:
gdm:
rpcu
nfsn
gnom
sshd
avah
post
tcpd
caoz
apac
XOAP
mysq
cao1
cao2
xiao
xiao
tom:
jack
cw01
sc01
rs01
boss
cw02
sc02
rs02
harr
neta
sars
OOO:
jerr
kefu
kefu
user
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cut -c4-10 passwd
t:x:0:0
:x:1:1:
mon:x:2
:x:3:4:
x:4:7:l
c:x:5:0
tdown:x
t:x:7:0
l:x:8:1
rator:x
es:x:12
:x:14:5
ody:x:9
temd-ne
s:x:81:
kitd:x:
storage
ord:x:9
:x:32:3
ed:x:99
ster:x:
lauth:x
t:x:173
roubles
it:x:17
se:x:17
vd:x:75
ony:x:9
ound:x:
u:x:107
:x:59:5
d:x:990
muxd:x:
clue:x:
:x:38:3
:x:42:4
user:x:
nobody:
me-init
d:x:74:
hi:x:70
tfix:x:
dump:x:
zx26:x:
che:x:4
P:x:100
ql:x:10
1:x:100
2:x:100
ocao:x:
o6:x:10
:x:1008
k:x:100
1:x:101
1:x:101
1:x:101
s01:x:1
2:x:101
2:x:101
2:x:101
ry:x:10
asha:x:
sh:x:10
:x:1020
ry:x:10
u:x:102
u2:x:10
r01:x:1
[root@web tmp]# cut -c5- passwd
:x:0:0:root:/root:/bin/bash
x:1:1:bin:/bin:/sbin/nologin
on:x:2:2:daemon:/sbin:/sbin/nologin
x:3:4:adm:/var/adm:/sbin/nologin
:4:7:lp:/var/spool/lpd:/sbin/nologin
:x:5:0:sync:/sbin:/bin/sync
down:x:6:0:shutdown:/sbin:/sbin/shutdown
:x:7:0:halt:/sbin:/sbin/halt
:x:8:12:mail:/var/spool/mail:/sbin/nologin
ator:x:11:0:operator:/root:/sbin/nologin
s:x:12:100:games:/usr/games:/sbin/nologin
x:14:50:FTP User:/var/ftp:/sbin/nologin
dy:x:99:99:Nobody:/:/sbin/nologin
emd-network:x:192:192:systemd Network Management:/:/sbin/nologin
:x:81:81:System message bus:/:/sbin/nologin
itd:x:999:998:User for polkitd:/:/sbin/nologin
toragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
rd:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
d:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
ter:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
auth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
:x:173:173::/etc/abrt:/sbin/nologin
oubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
t:x:172:172:RealtimeKit:/proc:/sbin/nologin
e:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
d:x:75:75:radvd user:/:/sbin/nologin
ny:x:992:987::/var/lib/chrony:/sbin/nologin
und:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
:x:107:107:qemu user:/:/sbin/nologin
x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
:x:990:984:User for sssd:/:/sbin/nologin
uxd:x:113:113:usbmuxd user:/:/sbin/nologin
lue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
x:38:38::/etc/ntp:/sbin/nologin
x:42:42::/var/lib/gdm:/sbin/nologin
ser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
obody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
e-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
i:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
fix:x:89:89::/var/spool/postfix:/sbin/nologin
ump:x:72:72::/:/sbin/nologin
x26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
he:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
:x:1002:1000::/rhome/XOAP:/bin/bash
l:x:1003:1003::/home/mysql:/sbin/nologin
:x:1004:1223::/home/cao1:/bin/bash
:x:1005:1005::/home/cao2:/bin/bash
cao:x:1006:1006::/home/xiaocao:/bin/bash
6:x:1007:1007::/home/xiao6:/bin/bash
x:1008:1008::/home/tom:/bin/bash
:x:1009:1009::/home/jack:/bin/bash
:x:1010:1224::/home/cw01:/bin/bash
:x:1011:1226::/home/sc01:/bin/bash
:x:1012:1225::/home/rs01:/bin/bash
01:x:1013:1004::/home/boss01:/bin/bash
:x:1014:1224::/home/cw02:/bin/bash
:x:1015:1226::/home/sc02:/bin/bash
:x:1016:1225::/home/rs02:/bin/bash
y:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
sha:x:1018:1018::/home/netasha:/bin/bash
h:x:1019:1228::/home/sarsh:/bin/bash
x:1020:1020::/home/OOO:/bin/bash
y:x:1021:1229::/home/jerry:/bin/bash
:x:1022:1022::/home/kefu:/bin/bash
2:x:1023:1023::/home/kefu2:/bin/bash
01:x:1024:1024::/home/user01:/bin/bash
[root@web tmp]# sort -n -t: -k3 passwd
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
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
mysql:x:1003:1003::/home/mysql:/sbin/nologin
cao1:x:1004:1223::/home/cao1:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
cw01:x:1010:1224::/home/cw01:/bin/bash
sc01:x:1011:1226::/home/sc01:/bin/bash
rs01:x:1012:1225::/home/rs01:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
netasha:x:1018:1018::/home/netasha:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
user01:x:1024:1024::/home/user01:/bin/bash
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# sort -nr -t: -k3 passwd
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
user01:x:1024:1024::/home/user01:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
netasha:x:1018:1018::/home/netasha:/bin/bash
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
rs01:x:1012:1225::/home/rs01:/bin/bash
sc01:x:1011:1226::/home/sc01:/bin/bash
cw01:x:1010:1224::/home/cw01:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
cao1:x:1004:1223::/home/cao1:/bin/bash
mysql:x:1003:1003::/home/mysql:/sbin/nologin
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
halt:x:7:0:halt:/sbin:/sbin/halt
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
sync:x:5:0:sync:/sbin:/bin/sync
lp:x:4:7:lp:/var/spool/lpd:/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
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# sort -n 1.txt2
3
3
12:3:2:1:312:3123
21
32
112:2223:333213
312
2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
123123
123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
123213
213123::::!@#@!#:@!#213:@!#12
213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
3213123
12312321
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
312312312
12312312312
123123123213
123123213123:123
12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
[root@web tmp]# sort -nu 2.txt
sort: cannot read: 2.txt: 没有那个文件或目录
[root@web tmp]# sort -nu 1.txt2
3
12:3:2:1:312:3123
21
32
112:2223:333213
312
2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
123213
213123::::!@#@!#:@!#213:@!#12
213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
3213123
12312321
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
312312312
12312312312
123123123213
123123213123:123
12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
[root@web tmp]# sort -nr 1.txt
12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
123123213123:123
123123123213
12312312312
312312312
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
12312321
3213123
213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
213123::::!@#@!#:@!#213:@!#12
123213
123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
123123
2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
312
112:2223:333213
32
21
12:3:2:1:312:3123
3
3
2[root@web tmp]# sort -nru passwd
root:x:0:0:root:/root:/bin/bash
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# sort -n 1.txt -o 2.txt
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat 2.txt2
3
3
12:3:2:1:312:3123
21
32
112:2223:333213
312
2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
123123
123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123
123213
213123::::!@#@!#:@!#213:@!#12
213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
3213123
12312321
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
312312312
12312312312
123123123213
123123213123:123
12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
[root@web tmp]# sort -R passwd
adm:x:3:4:adm:/var/adm:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
jack:x:1009:1009::/home/jack:/bin/bash
dbus:x:81:81:System message bus:/:/sbin/nologin
kefu2:x:1023:1023::/home/kefu2:/bin/bash
halt:x:7:0:halt:/sbin:/sbin/halt
netasha:x:1018:1018::/home/netasha:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
cw01:x:1010:1224::/home/cw01:/bin/bash
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
rs01:x:1012:1225::/home/rs01:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
cao2:x:1005:1005::/home/cao2:/bin/bash
mysql:x:1003:1003::/home/mysql:/sbin/nologin
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
user01:x:1024:1024::/home/user01:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
nobody:x:99:99:Nobody:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
sc01:x:1011:1226::/home/sc01:/bin/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
OOO:x:1020:1020::/home/OOO:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
cao1:x:1004:1223::/home/cao1:/bin/bash
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
jerry:x:1021:1229::/home/jerry:/bin/bash
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# sort -u passwd
abrt:x:173:173::/etc/abrt:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
bin:x:1:1:bin:/bin:/sbin/nologin
boss01:x:1013:1004::/home/boss01:/bin/bash
cao1:x:1004:1223::/home/cao1:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
cw01:x:1010:1224::/home/cw01:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
daemon:x:2:2:daemon:/sbin:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
halt:x:7:0:halt:/sbin:/sbin/halt
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
mysql:x:1003:1003::/home/mysql:/sbin/nologin
netasha:x:1018:1018::/home/netasha:/bin/bash
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
OOO:x:1020:1020::/home/OOO:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
rs01:x:1012:1225::/home/rs01:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
sarsh:x:1019:1228::/home/sarsh:/bin/bash
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
sc01:x:1011:1226::/home/sc01:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
tom:x:1008:1008::/home/tom:/bin/bash
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
user01:x:1024:1024::/home/user01:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
[root@web tmp]# vim file1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat file1
aaaa
111
hello world
222
333
bbb
[root@web tmp]# vim file2
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat file2
aaa
hello
111
222
bbb
333
world
[root@web tmp]# diff file1 file2
1c1,2
< aaaa
---
> aaa
> hello
3d3
< hello world
5d4
< 333
6a6,7
> 333
> world
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# diff -c file1 file2
*** file1 2025-07-28 21:16:13.339673496 +0800
--- file2 2025-07-28 21:18:14.421741193 +0800
***************
*** 1,6 ****
! aaaa111
- hello world222
- 333bbb
--- 1,7 ----
! aaa
! hello111222bbb
+ 333
+ world
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# mkdir dir1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# mkdir dir2
[root@web tmp]# mv ~/file1 /dir1
mv: 无法获取"/root/file1" 的文件状态(stat): 没有那个文件或目录
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# mv file1 ~/dir1
[root@web tmp]# ls dir1
[root@web tmp]# find ~/ -n file1
find: 未知的断言“-n”
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# ls ~/dir1
/root/dir1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# ls dir1
[root@web tmp]# ls ~/dir1
/root/dir1
[root@web tmp]# mv ~/dir1/file1 .
mv: 无法获取"/root/dir1/file1" 的文件状态(stat): 不是目录
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# touch 1.txt
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# vim 1.txt
[root@web tmp]# touch dir1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# touch file1
[root@web tmp]# vim file1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat file1
aaaa
111
hello world
222
333
bbb
[root@web tmp]# cp file1 ./dir1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# ls ./dir1
file1
[root@web tmp]# cat file2
aaa
hello
111
222
bbb
333
world
[root@web tmp]# cp file2 ./dir2
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# ls dir2
file2
[root@web tmp]# diff dir1 dir2
只在 dir1 存在:file1
只在 dir2 存在:file2
[root@web tmp]# dirr -q dir1 dir2
bash: dirr: 未找到命令...
相似命令是: 'dir'
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# diff -q dir1 dir2
只在 dir1 存在:file1
只在 dir2 存在:file2
[root@web tmp]# diff -uN file1 file2 >file.patch
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat file.patch
--- file1 2025-07-28 21:49:34.727561012 +0800
+++ file2 2025-07-28 21:18:14.421741193 +0800
@@ -1,6 +1,7 @@
-aaaa
+aaa
+hello111
-hello world222
-333bbb
+333
+world
[root@web tmp]# patch file1 file.patch
patching file file1
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# diff file1 file2
[root@web tmp]# vim 3.txt
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat 3.txt
cat: 3.txt: 没有那个文件或目录
[root@web tmp]# cp passwd 3.txt
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat 3.txt
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
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
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
mysql:x:1003:1003::/home/mysql:/sbin/nologin
cao1:x:1004:1223::/home/cao1:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
cw01:x:1010:1224::/home/cw01:/bin/bash
sc01:x:1011:1226::/home/sc01:/bin/bash
rs01:x:1012:1225::/home/rs01:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
netasha:x:1018:1018::/home/netasha:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
user01:x:1024:1024::/home/user01:/bin/bash
[root@web tmp]# vim 3.txt
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat 3.txt
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
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
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
aaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbb1111111111222222222333333331cccccccccc
hello world 888
666
777
999
[root@web tmp]#