linux如何查看某个端口被哪个程序占用了

1. 不好意思,先切换到root

su root 如果不切换到root,看不到进程号

2. 查看端口被哪个占用

[root@localhost test]# netstat -apn | grep 8080
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      17997/unicorn maste 
tcp        0      0 127.0.0.1:8080          127.0.0.1:58802         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:8080          127.0.0.1:58836         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:8080          127.0.0.1:58904         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:8080          127.0.0.1:58870         TIME_WAIT   -         

看到第一行的LISTEN 17997/unicorn maste,17997就是占用的进程号

3.找出真身

[root@localhost test]# ps -ef | grep 17997
git      17997     1 21 22:01 ?        00:00:29 unicorn master -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
git      18108 17997  0 22:02 ?        00:00:00 unicorn worker[0] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
git      18111 17997  0 22:02 ?        00:00:00 unicorn worker[1] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
git      18114 17997  0 22:02 ?        00:00:00 unicorn worker[2] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
root     18301 16812  0 22:03 pts/0    00:00:00 grep --color=auto 17997
  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值