`
modabobo
  • 浏览: 509598 次
文章分类
社区版块
存档分类
最新评论

Ubuntu,mac查看端口命令

 
阅读更多
ubuntu查看端口

#查看进程端口号及运行的程序
sudo netstat -antup

#PID为端口号远行进程的号
sudo kill PID(进程码)

# 查看所有打开的端口及服务名(注意这里显示的服务名只是标准端口对应的服务名,可能并不准确)
nmap localhost

# 查看哪些进程打开了指定端口port(对于守护进程必须以root用户执行才能查看到
lsof -i:port

# 查看哪些进程打开了指定端口port,最后一列是进程ID(此方法对于守护进程作用不大)
netstat -nap|grep port

# 查看端口号对应的系统服务名称
cat /etc/services

# 启动|停止|重启系统服务

sudo /etc/init.d/service start|stop|restart

from http://thiger.blog.hexun.com/46497959_d.html


linux + mac

  Lsof命令示例

  你可以输入下面的命令来查看IPv4端口:(最好加 sudo)

  # lsof -Pnl +M -i4

# sudo lsof -Pnl +M -i4

  你可以输入下面的命令来查看IPv6协议下的端口列示:

  # lsof -Pnl +M -i6

  1. #lsof-Pnl+M-i6
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics