2.过滤掉/etc/ssh/sshd_config文件中的注释行和空行,并把过滤出来的内容保存到ssh.txt文件中
[root@xuegod63 ~]# grep -v ^# /etc/ssh/sshd_config|grep -v ^$ >ssh.txt
[root@xuegod63 ~]# cat ssh.txt
Port 22
Port 222
Protocol 2
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding yes
UseDNS no
Subsystem sftp /usr/libexec/openssh/sftp-server
或者也可使用以下命令,效果一样
[root@xuegod63 ~]# grep -Ev "^$|^[#;]" /etc/ssh/sshd_config >ssh.txt
[root@xuegod63 ~]# cat ssh.txt
Port 22
Port 222
Protocol 2
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding yes
UseDNS no
Subsystem sftp /usr/libexec/openssh/sftp-server
1.启动httpd服务后,查找到系统中所有httpd进程,并把查找到的信息保存到httpd.txt中
[root@xuegod63 ~]# service httpd restart|ps aux|grep httpd>httpd.txt
[root@xuegod63 ~]# cat httpd.txt
root 26693 0.0 0.1 106332 1780 pts/10 S+ 23:36 0:00 /bin/sh /sbin/service httpd restart
root 26695 0.0 0.0 103308 876 pts/10 S+ 23:36 0:00 grep httpd
3.查看目录/tmp和/apach下面内容,把正确结果追加到ssh.txt,错误信息输入到黑洞中
1 [root@xuegod63 ~]# ll -R /tmp /apach>>ssh.txt 2>/dev/null
2 [root@xuegod63 ~]# cat ssh.txt
3 Port 22
4 Port 222
5 Protocol 2
6 SyslogFacility AUTHPRIV
7 PasswordAuthentication yes
8 ChallengeResponseAuthentication no
9 GSSAPIAuthentication yes
10 GSSAPICleanupCredentials yes
11 UsePAM yes
12 AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
13 AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
14 AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
15 AcceptEnv XMODIFIERS
16 X11Forwarding yes
17 UseDNS no
18 Subsystem sftp /usr/libexec/openssh/sftp-server
19 /tmp:
20 total 12
21 -rw-r--r-- 1 root root 1803 Apr 3 19:05 1
22 srwx------ 1 mongod mongod 0 Apr 1 13:31 mongodb-27017.sock
23 srwxrwxrwx 1 mysql mysql 0 Apr 5 18:47 mysql.sock
24 -rw-r--r-- 1 root root 1803 Apr 3 19:04 passwd
25 drwxr-xr-x 3 root root 4096 Apr 5 16:39 pear
26
27 /tmp/pear:
28 total 4
29 drwxr-xr-x 2 root root 4096 Apr 5 16:39 temp
30
31 /tmp/pear/temp:
32 total 0