linux常用查看进程查找方法
psaux|grepapache查看进程对应的端口号
root@objweb:~# ps aux | grep apache www-data 8290 0.0 1.6 375776 17148 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 8291 0.0 1.5 375024 16128 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 8293 0.0 1.5 375024 16128 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 8294 0.0 1.5 375024 16128 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 8296 0.0 1.5 375024 16128 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 8318 0.0 0.9 374676 9728 ? S 06:27 0:00 /usr/sbin/apache2 -k start root 8525 0.0 0.2 11752 2248 pts/2 S+ 08:01 0:00 grep --color=auto apache root 26771 0.0 2.8 374644 28896 ? Ss 2017 10:45 /usr/sbin/apache2 -k start
lsof-i:端口号查看端口对应的进程号
root@cdc:~# lsof -i:80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME apache2 8290 www-data 3u IPv4 4696118 0t0 TCP *:http (LISTEN) apache2 8291 www-data 3u IPv4 4696118 0t0 TCP *:http (LISTEN) apache2 8293 www-data 3u IPv4 4696118 0t0 TCP *:http (LISTEN) apache2 8294 www-data 3u IPv4 4696118 0t0 TCP *:http (LISTEN) apache2 8296 www-data 3u IPv4 4696118 0t0 TCP *:http (LISTEN) apache2 8318 www-data 3u IPv4 4696118 0t0 TCP *:http (LISTEN) AliYunDun 22244 root 18u IPv4 1170984 0t0 TCP 120.25.147.105:38700->106.11.68.13:http (CLOSE_WAIT) AliYunDun 22244 root 20u IPv4 1699628 0t0 TCP 120.25.147.105:39748->106.11.68.13:http (CLOSE_WAIT) AliYunDun 22244 root 21u IPv4 2264476 0t0 TCP 120.25.147.105:40780->106.11.68.13:http (CLOSE_WAIT)
psaux|grep8290查看端口对应的程序
root@cdc:~# ps aux | grep 8290 www-data 8290 0.0 1.6 375776 17148 ? S 06:25 0:00 /usr/sbin/apache2 -k start
netstat-anop|grep8290查看进程对应的端口号
root@cdc:~# netstat -anop | grep 8290 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8290/apache2 off (0.00/0/0)