zhangweimailbox
怎么关闭一个被打开的端口啊
服务器有一个端口被打开了可不知道是什么程序打开的,怎么把这个端口关闭掉啊
briangao
The easy way is to download and install lsof as 风版 and yuhuohu have suggested. If you don't want to install lsof, try the following script:
[code]
#!/bin/sh
for PID in `ps -ef -o pid | tail +2`
do
FOUNDPORT=`pfiles ${PID} 2>&1 | grep "sockname:" | grep "port:" | awk '{ print $NF }'`
if [ X"${FOUNDPORT}" != "X" ]; then
FOUNDPROC=`pfiles ${PID} 2>&1 | grep "^${PID}:"`
echo "${FOUNDPROC}, ${FOUNDPORT}" | tr "/012" " "
echo
fi
done
[/code]