find which process use some tcp/udp port

来源:互联网 发布:淘宝鬼脚七是谁 编辑:程序博客网 时间:2024/06/08 08:25

 windows platform

1. run command

     netstat -a -n -o

     from the output find the pid id for the port

2. open task management

    or run command

    tasklist /svc /FI "pid eq 2404"

 

linux platform

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

nmap localhost

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

lsof -i:port

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

netstat -nap|grep port

# 查看端口号对应的系统服务名称

cat /etc/services

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

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

 

 

原创粉丝点击