爲了讓linux主機少一些隱患,咱們要儘量把一些不須要的服務取消或者刪掉。
咱們能夠先來看看目前有哪些端口是開着的
mysql
[root@localhost linsc]# nmap 127.0.0.1
Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2007-12-05 21:28 CST
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1652 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
25/tcp open smtp
80/tcp open http
766/tcp open unknown
3306/tcp open mysql
8009/tcp open ajp13
8080/tcp open http-proxy
Nmap run completed -- 1 IP address (1 host up) scanned in 0.194 seconds
能夠看到 766 端口是打開着的,一個 unknown 的服務正在運行,這是什麼服務?這個時候我也不知道。
linux
[root@localhost linsc]# netstat -lp
能夠看到有下面一條內容,
sql
tcp 0 0 *:766 *:* LISTEN 3128/
rpc.statd
說明是 rpc.statd 正在運行。
就看766是什麼命令執行的監聽端口的另一個辦法
dom
[root@localhost linsc]# lsof -i:766
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
rpc.statd 3128
rpcuser 8u IPv4 6467 TCP *:766 (LISTEN)
查看rpc.statd這個命令是那個安裝包的文檔
ssh
[root@localhost linsc]# rpm -qf /sbin/
rpc.statd
nfs-utils-1.0.6-80.EL4
查看nfs開頭有那些東東
tcp
[root@localhost linsc]# ls /etc/init.d/nfs*
/etc/init.d/nfs /etc/init.d/nfslock
查看nfslock狀態
ide
[root@localhost linsc]# /etc/init.d/nfslock status
rpc.statd (pid 3128) 正在運行...
[root@localhost linsc]# vi /etc/services
找到裏面的 nfs ,在前面加 # 註釋掉,重啓,
rest
[root@localhost linsc]# nmap 127.0.0.1
Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2007-12-05 21:55 CST
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1653 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
25/tcp open smtp
80/tcp open http
3306/tcp open mysql
8009/tcp open ajp13
8080/tcp open http-proxy
Nmap run completed -- 1 IP address (1 host up) scanned in 0.194 seconds
source:http://wenyou2k.blog.163.com/blog/static/1113063002009476291598/