Home Linux中查看进程的端口号,查看哪个进程占用了该端口
Post
Cancel

Linux中查看进程的端口号,查看哪个进程占用了该端口

知道进程,查看进程的端口号

1
2
3
4
5
6
7
[root@localhost ~]# ps -ef|grep ssh
961 ?         00:00:00 sshd
...

[root@localhost ~]# netstat -anp|grep 961
tcp   0   0 0.0.0.0:22   0.0.0.0:*   LISTEN   961/sshd         
...          

查看哪个进程占用了某个端口

1
2
3
4
5
6
7
8
[root@localhost ~]# netstat -anp|grep 22
tcp   0   0 0.0.0.0:22   0.0.0.0:*   LISTEN   961/sshd            
...

[root@localhost ~]# ps -ef|grep sshd
961 ?        00:00:00 sshd
1154 ?        00:00:00 sshd
1156 ?        00:00:00 sshd
This post is licensed under CC BY 4.0 by the author.