- 论坛徽章:
- 0
|
请问如何获得占用某端口的进程名?
You can use lsof, a freeware, to get what you want.
Syntax: lsof -i :service_name|port_number
You could get the service_name from /etc/services.
The followings are examples:
#lsof -i :www
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 3417 root 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3446 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3447 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3448 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3449 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3450 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 13189 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 16197 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 3417 root 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3446 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3447 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3448 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3449 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 3450 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 13189 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN)
httpd 16197 www 16u inet 0x4c0b5940 0t0 TCP *:http (LISTEN) |
|