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. python 的日志logging模块学习

    1.简单的将日志打印到屏幕 import logging logging.debug('This is debug message') logging.info('This is info messa ...

  2. ImageSharp一个专注于NetCore平台图像处理的开源项目

    今天大家分享的是一个专注于NetCore平台图像处理的开源项目,老实说为这篇文章取名字想了5分钟,可能是词穷亦或是想更好的表达出这款开源项目的作用:这个项目在图像处理方面有很多功能,如:缩放,裁剪,绘 ...

  3. HDU 1219 AC Me

    strlen能不用就不用 #include<cstdio> #include<cstdlib> #include<iostream> #include<alg ...

  4. WPF DataGrid自定义样式

    微软的WPF DataGrid中有很多的属性和样式,你可以调整,以寻找合适的(如果你是一名设计师).下面,找到我的小抄造型的网格.它不是100%全面,但它可以让你走得很远,有一些非常有用的技巧和陷阱. ...

  5. canvas图表详解系列(3):动态饼状图(原生Js仿echarts饼状图)

    本章建议学习时间4小时 学习方式:详细阅读,并手动实现相关代码(如果没有canvas基础,需要先学习前面的canvas基础笔记) 学习目标:此教程将教会大家如何使用canvas绘制各种图表,详细分解步 ...

  6. WebApi系列~HttpClient的性能隐患

    回到目录 最近在进行开发过程中,基于都是接口开发,A站接口访问B接口接口来请求数据,而在这个过程中我们使用的是HttpClient这个框架,当然也是微软自己的框架,性能当前没有问题,但如果你直接使用官 ...

  7. 基于nginx搭建简易的基于wcf集群的复杂均衡

    很多情况下基于wcf的复杂均衡都首选zookeeper,这样可以拥有更好的控制粒度,但zk对C# 不大友好,实现起来相对来说比较麻烦,实际情况下,如果 你的负载机制粒度很粗糙的话,优先使用nginx就 ...

  8. Ubuntu下使用网易云音乐

    Ubuntu15真心各种崩溃啊 最后决定还是换成ubuntu14.04LTS了 在win.android平台上网易云音乐好用到爆 ubuntu下没有网易云音乐的客户端怎么能行 https://gith ...

  9. C++基础知识1

    1 初始C++ 1.1 编写一个简单的C++程序 1.1.1 程序结构 每个C++程序都包括一个或多个函数(function),但只有一个主函数main.操作系统通过调用 main来运行C++程序. ...

  10. netbeans 字体发虚

    今天更新了netbeans,重启后蛋疼了,字体发虚,搜索网络后有得到如下方案: 对Archlinux,去/usr/share/netbeans/etc,里面找到netbeans.conf,给下面一行参 ...