Linux 下查询端口号由哪个程序执行
发布网友
发布时间:2022-04-25 09:08
我来回答
共1个回答
热心网友
时间:2023-11-12 00:35
使用netstat命令
tcp:
$ sudo netstat -atp
udp:
$ sudo netstat -aup
注:因-p参数需要root权限,因此在命令前必须加入sudo或直接使用root用户执行上述命令。
输出结果如下所示
$ sudo netstat -atp
[sudo] password for user1:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:sunrpc 0.0.0.0:* LISTEN 695/rpcbind
tcp 0 0 0.0.0.0:x11 0.0.0.0:* LISTEN 1053/Xorg
tcp 0 0 vm-centos-lp:domain 0.0.0.0:* LISTEN 1339/dnsmasq
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 997/sshd
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN 1102/master
tcp 0 64 vm-centos-lp:ssh 192.168.56.1:spc ESTABLISHED 1554/sshd: lipeng [
tcp6 0 0 [::]:sunrpc [::]:* LISTEN 695/rpcbind
tcp6 0 0 [::]:x11 [::]:* LISTEN 1053/Xorg
tcp6 0 0 [::]:ftp [::]:* LISTEN 1008/vsftpd
tcp6 0 0 [::]:ssh [::]:* LISTEN 997/sshd
tcp6 0 0 localhost:smtp [::]:* LISTEN 1102/master
[lipeng@vm-centos-lp ~]$ sudo netstat -aup
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 vm-centos-lp:domain 0.0.0.0:* 1339/dnsmasq
udp 0 0 0.0.0.0:bootps 0.0.0.0:* 1339/dnsmasq
udp 0 0 0.0.0.0:bootpc 0.0.0.0:* 786/dhclient
udp 0 0 0.0.0.0:sunrpc 0.0.0.0:* 695/rpcbind
udp 0 0 0.0.0.0:xdmcp 0.0.0.0:* 1016/gdm
udp 0 0 localhost:323 0.0.0.0:* 685/chronyd
udp 0 0 0.0.0.0:23133 0.0.0.0:* 786/dhclient
udp 0 0 0.0.0.0:859 0.0.0.0:* 695/rpcbind
udp 0 0 0.0.0.0:33731 0.0.0.0:* 682/avahi-daemon: r
udp 0 0 0.0.0.0:mdns 0.0.0.0:* 682/avahi-daemon: r
udp6 0 0 [::]:sunrpc [::]:* 695/rpcbind
udp6 0 0 [::]:51388 [::]:* 786/dhclient
udp6 0 0 localhost:323 [::]:* 685/chronyd
udp6 0 0 [::]:859 [::]:* 695/rpcbind
热心网友
时间:2023-11-12 00:35
使用netstat命令
tcp:
$ sudo netstat -atp
udp:
$ sudo netstat -aup
注:因-p参数需要root权限,因此在命令前必须加入sudo或直接使用root用户执行上述命令。
输出结果如下所示
$ sudo netstat -atp
[sudo] password for user1:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:sunrpc 0.0.0.0:* LISTEN 695/rpcbind
tcp 0 0 0.0.0.0:x11 0.0.0.0:* LISTEN 1053/Xorg
tcp 0 0 vm-centos-lp:domain 0.0.0.0:* LISTEN 1339/dnsmasq
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 997/sshd
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN 1102/master
tcp 0 64 vm-centos-lp:ssh 192.168.56.1:spc ESTABLISHED 1554/sshd: lipeng [
tcp6 0 0 [::]:sunrpc [::]:* LISTEN 695/rpcbind
tcp6 0 0 [::]:x11 [::]:* LISTEN 1053/Xorg
tcp6 0 0 [::]:ftp [::]:* LISTEN 1008/vsftpd
tcp6 0 0 [::]:ssh [::]:* LISTEN 997/sshd
tcp6 0 0 localhost:smtp [::]:* LISTEN 1102/master
[lipeng@vm-centos-lp ~]$ sudo netstat -aup
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 vm-centos-lp:domain 0.0.0.0:* 1339/dnsmasq
udp 0 0 0.0.0.0:bootps 0.0.0.0:* 1339/dnsmasq
udp 0 0 0.0.0.0:bootpc 0.0.0.0:* 786/dhclient
udp 0 0 0.0.0.0:sunrpc 0.0.0.0:* 695/rpcbind
udp 0 0 0.0.0.0:xdmcp 0.0.0.0:* 1016/gdm
udp 0 0 localhost:323 0.0.0.0:* 685/chronyd
udp 0 0 0.0.0.0:23133 0.0.0.0:* 786/dhclient
udp 0 0 0.0.0.0:859 0.0.0.0:* 695/rpcbind
udp 0 0 0.0.0.0:33731 0.0.0.0:* 682/avahi-daemon: r
udp 0 0 0.0.0.0:mdns 0.0.0.0:* 682/avahi-daemon: r
udp6 0 0 [::]:sunrpc [::]:* 695/rpcbind
udp6 0 0 [::]:51388 [::]:* 786/dhclient
udp6 0 0 localhost:323 [::]:* 685/chronyd
udp6 0 0 [::]:859 [::]:* 695/rpcbind
热心网友
时间:2023-11-12 00:35
使用netstat命令
tcp:
$ sudo netstat -atp
udp:
$ sudo netstat -aup
注:因-p参数需要root权限,因此在命令前必须加入sudo或直接使用root用户执行上述命令。
输出结果如下所示
$ sudo netstat -atp
[sudo] password for user1:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:sunrpc 0.0.0.0:* LISTEN 695/rpcbind
tcp 0 0 0.0.0.0:x11 0.0.0.0:* LISTEN 1053/Xorg
tcp 0 0 vm-centos-lp:domain 0.0.0.0:* LISTEN 1339/dnsmasq
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 997/sshd
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN 1102/master
tcp 0 64 vm-centos-lp:ssh 192.168.56.1:spc ESTABLISHED 1554/sshd: lipeng [
tcp6 0 0 [::]:sunrpc [::]:* LISTEN 695/rpcbind
tcp6 0 0 [::]:x11 [::]:* LISTEN 1053/Xorg
tcp6 0 0 [::]:ftp [::]:* LISTEN 1008/vsftpd
tcp6 0 0 [::]:ssh [::]:* LISTEN 997/sshd
tcp6 0 0 localhost:smtp [::]:* LISTEN 1102/master
[lipeng@vm-centos-lp ~]$ sudo netstat -aup
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 vm-centos-lp:domain 0.0.0.0:* 1339/dnsmasq
udp 0 0 0.0.0.0:bootps 0.0.0.0:* 1339/dnsmasq
udp 0 0 0.0.0.0:bootpc 0.0.0.0:* 786/dhclient
udp 0 0 0.0.0.0:sunrpc 0.0.0.0:* 695/rpcbind
udp 0 0 0.0.0.0:xdmcp 0.0.0.0:* 1016/gdm
udp 0 0 localhost:323 0.0.0.0:* 685/chronyd
udp 0 0 0.0.0.0:23133 0.0.0.0:* 786/dhclient
udp 0 0 0.0.0.0:859 0.0.0.0:* 695/rpcbind
udp 0 0 0.0.0.0:33731 0.0.0.0:* 682/avahi-daemon: r
udp 0 0 0.0.0.0:mdns 0.0.0.0:* 682/avahi-daemon: r
udp6 0 0 [::]:sunrpc [::]:* 695/rpcbind
udp6 0 0 [::]:51388 [::]:* 786/dhclient
udp6 0 0 localhost:323 [::]:* 685/chronyd
udp6 0 0 [::]:859 [::]:* 695/rpcbind