1、查看端口是否被占用

[guosong@alice48 main]$ netstat -nlp|grep 6184
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:6184 0.0.0.0:* LISTEN 32429/python26

  

man netstat
--numeric , -n
Show numerical addresses instead of trying to determine symbolic host, port or user names.
-l, --listening
Show only listening sockets. (These are omitted by default.) -p, --program
Show the PID and name of the program to which each socket belongs.

加了-p参数,可以看到PID

或者通过lsof查看对应的PID

[guosong@alice48 main]$ lsof -i tcp:6184
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
python26 32429 guosong 39u IPv4 2261894200 TCP *:6184 (LISTEN)
       -i [i]   This option selects the listing of files any of whose Internet address matches the address specified  in  i.   If  no address is specified, this option selects the listing of all Internet and
x.25 (HP-UX) network files.
[46][protocol][@hostname|hostaddr][:service|port] where:
46 specifies the IP version, IPv4 or IPv6
that applies to the following address.
’6’ may be be specified only if the UNIX
dialect supports IPv6. If neither ’4’ nor
’6’ is specified, the following address
applies to all IP versions.
protocol is a protocol name - TCP or UDP.

2、查看命令路径

获取到PID后,通过ps查看进程命令

[guosong@alice48 main]$ ps aux |grep 32429
guosong 3737 0.0 0.0 61160 744 pts/31 S+ 16:22 0:00 grep 32429
guosong 32429 0.6 0.1 234940 20860 pts/31 S 16:14 0:03 python26 api_main.py
[guosong@alice48 ~]$ readlink /proc/32429/exe
/usr/bin/python26

通过readlink也只是知道这是个python26的脚本,至于后面api_main.py的绝对路径应该怎么找呢??

[guosong@alice48 32429]$ readlink /proc/32429/cwd
/usr/home/guosong/mysqlapi/main

http://www.blogjava.net/kxx129/archive/2013/05/13/399206.html

 

linux如何查看端口被谁占用的更多相关文章

  1. linux如何查看端口是否被占用?

    转自:https://www.cnblogs.com/hindy/p/7249234.html LINUX中如何查看某个端口是否被占用 之前查询端口是否被占用一直搞不明白,问了好多人,终于搞懂了,现在 ...

  2. linux下查看端口是否被占用以及查看所有端口

    1.查看服务器端口是否被占用 >lsof  -i:8081 2.查看服务器所有端口 >netstat -ntlp 3.查看服务器是否开放某端口 tcp端口:>netstat -ntp ...

  3. Linux 如何查看端口与进程占用情况

    1 lsof -i:port  查看端口使用情况 lsof -i 如果出现 command not found,直接yum install lsof即可. (1) lsof -i lsof -i 用以 ...

  4. linux如何查看端口被哪个进程占用的方法

    linux如何查看端口被哪个进程占用的方法: 1.lsof -i:端口号2.netstat -tunlp|grep 端口号 都可以查看指定端口被哪个进程占用的情况[步骤一]lsof -ilsof -i ...

  5. Linux如何查看端口占用情况

    Linux如何查看端口 1.lsof -i:端口号 用于查看某一端口的占用情况,比如查看8000端口使用情况,lsof -i:8000 # lsof -i:8000 COMMAND PID USER ...

  6. Linux下查看端口占用进程号,程序名的方法

    Linux下查看端口占用进程号,程序名的方法,方便我们查找什么进程导致系统变慢等需要.linux下查看端口占用情况: 1. 查看哪个进程占用了819端口: case9-sghfofo:/usr/loc ...

  7. linux 查看端口是否被占用

    查看端口是否被占用: netstat -anp | grep port lsof -i:port 查看端口被那个进程占用: netstat -anp | grep port 或使用 lsof -i:p ...

  8. CentOS查看端口是否被占用

    CentOS查看端口是否被占用 本文介绍了linux中查看某一端口是否被占用的方法,有关netstat命令的使用技巧,感兴趣的朋友可以参考下. 使用命令: netstat -tunlp 会显示所有端口 ...

  9. Linux如何查看端口

    Linux如何查看端口 1.lsof -i:端口号 用于查看某一端口的占用情况,比如查看8000端口使用情况,lsof -i:8000 # lsof -i:8000 COMMAND PID USER ...

随机推荐

  1. HDU1068 二分匹配 独立集

    前边和后边性别不同!!!不然NP了 Girls and Boys Problem Description the second year of the university somebody star ...

  2. 如何获取url上面的参数

    例如 :网页.html?id=0 //获取url中"?"符后的字串 gofunction getRequest() { var url = window.location.sear ...

  3. C#对图片进行马赛克处理,可控制模糊程度

    using System.Drawing; using System.Drawing.Imaging; using System.Web.Mvc; namespace MVC2017_Sample.C ...

  4. 关于Android SDK Manager无法获取更新列表的正确设置

    1.以"管理员身份运行"SDK Manager. 2.Android SDK Manager"=>"Tools"=>"Optio ...

  5. python 解析xml

    在工作中很多时候都要用到xml,使用这个时候难免会设计到解析他,然后就研究了一下python解析xml问题,看了很多东西,python有很多解析xml的包,但是也折腾我好一段时间,最后选择了这个方法. ...

  6. 反射型 DDoS 攻击的原理和防范措施

    随着僵尸网络的兴起,同时由于攻击方法简单.影响较大.难以追查等特点,分布式拒绝服务攻击(DDoS,Distributed Denial of Service)得到快速壮大和日益泛滥. 成千上万主机组成 ...

  7. spring容器启动原理分析1

    在项目的web.xml中配置 <listener> <listener-class>org.springframework.web.context.ContextLoaderL ...

  8. python抓取zabbix图形,并发送邮件

    最近十九大非常烦,作为政府网站维护人员,简直是夜不能寐.各种局子看着你,内保局,公安部,360,天融信,华胜天成,中央工委,政治委员会... 360人员很傻X,作为安全公司,竟然不能抓到XX网站流量, ...

  9. win10 uwp 打开文件管理器选择文件

    本文:让文件管理器选择文件,不是从文件管理器获得文件. 假如已经获得一些文件,那么如何从文件管理器选择这些文件? 使用方法很简单. 从网上拿图来说 打开文件夹自动选择所有文件 首先需要获得文件夹,因为 ...

  10. crontab的使用方法

    cron是一个linux下的定时执行工具,可以在无需人工干预的情况下运行作业. /sbin/service crond start //启动服务 /sbin/service crond stop // ...