Linux系统下如何查看某端口被某进程所占用

本文展示了如何使用ss、netstat和lsof命令检查Linux系统中5432端口的状态,该端口通常被PostgreSQL数据库使用。通过这些命令,我们可以查看端口的监听状态以及与之关联的进程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//使用ss命令
[root@mdw ~]# ss -lptn 'sport = :5432'
State	Recv-Q 	Send-Q	Local Address:Port	Peer Address:Port                                                              
LISTEN	  0		128					*:5432			   *:*		users:(("postgres",pid=6443,fd=3))                                                                                
LISTEN 	  0		128				   :::5432			  :::*		users:(("postgres",pid=6443,fd=4))                                                                     
//使用netstat命令
[root@mdw ~]# netstat -nlp | grep :5432
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      6443/postgres
tcp6       0      0 :::5432                 :::*                    LISTEN      6443/postgres
//使用lsof命令
[root@mdw ~]# lsof -n -i :5432 | grep LISTEN
postgres 6443 gpadmin    3u  IPv4 7899526      0t0  TCP *:postgres (LISTEN)
postgres 6443 gpadmin    4u  IPv6 7899527      0t0  TCP *:postgres (LISTEN)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值