linux 中当我们知道一个服务的名称,需要查看端口,或者知道端口需要查看服务名称时,我们应该怎么做了?
- 知道服务看端口
[[email protected] ~]# netstat -lntup |grep httpd tcp 0 0 :::80 :::* LISTEN 1695/httpd tcp 0 0 :::443 :::* LISTEN 1695/httpd
2.知道端口看服务名称
[[email protected] ~]# lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME httpd 1695 root 4u IPv6 20189 0t0 TCP *:http (LISTEN) httpd 1698 apache 4u IPv6 20189 0t0 TCP *:http (LISTEN) httpd 1699 apache 4u IPv6 20189 0t0 TCP *:http (LISTEN) httpd 1700 apache 4u IPv6 20189 0t0 TCP *:http (LISTEN) httpd 1701 apache 4u IPv6 20189 0t0 TCP *:http (LISTEN)
3.知道服务名称查看服务进程
[[email protected] ~]# ps -ef|grep httpd root 1695 1 0 21:01 ? 00:00:00 /usr/sbin/httpd apache 1698 1695 0 21:01 ? 00:00:00 /usr/sbin/httpd apache 1699 1695 0 21:01 ? 00:00:00 /usr/sbin/httpd apache 1705 1695 0 21:01 ? 00:00:00 /usr/sbin/httpd root 3759 1150 0 22:25 pts/0 00:00:00 grep httpd [[email protected] ~]# ps aux |grep httpd root 1695 0.0 0.5 208712 5828 ? Ss 21:01 0:00 /usr/sbin/httpd apache 1698 0.0 0.5 210364 5984 ? S 21:01 0:00 /usr/sbin/httpd apache 1699 0.0 0.5 210364 6000 ? S 21:01 0:00 /usr/sbin/httpd apache 1700 0.0 0.5 210364 5988 ? S 21:01 0:00 /usr/sbin/httpd apache 1701 0.0 0.5 210364 5984 ? S 21:01 0:00 /usr/sbin/httpd
时间: 2024-10-10 19:45:50