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. vue.js用法和特性详解

      前  言 最近用Vue.js做了一个数据查询平台,还做了一个拼图游戏,突然深深的感到了vue的强大. Vue.js是一套构建用户界面(user interface)的渐进式框架.与其他重量级框架不 ...

  2. ASP.NET/MVC 配置log4net启用写错误日志功能

    <?xml version="1.0" encoding="utf-8"?> <!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访 ...

  3. 我的three.js学习记录(二)

    通过上一篇文章我的three.js学习记录(一)基本上是入门了three.js,但是这不够3D,这次我希望能把之前做的demo弄出来,然后通过例子来分析操作步骤. 1. 示例 上图是之前做的一个dem ...

  4. python爬虫之获取验证码登陆

    #--coding:utf-8#author:wuhao##这里我演示的就是本人所在学校的教务系统#import urllib.requestimport urllib.parseimport rei ...

  5. WPF 只允许打开一个实例

    我们有时候只希望我们的程序只打开一个实例,也就是我们的软件只有一次被打开. 那么我们可以通过一个办法知道,在这个软件打开前是不是打开过一个,还没关闭.也就是是否存在另一个程序在运行. 下面是一个简单方 ...

  6. hdu4821 String

    您也可以在我的个人博客中阅读此文章:跳转 题意 一个字符串S 问其中有几个子串能满足以下条件:1.长度为m*l2.可以被分成m个l长的不同的子串问题就变成了如何快速的判断着m个子串是否存在相同的 思路 ...

  7. PHP开发者必须了解的9个魔术方法

    这些'魔术'方法拥有者特殊的名字,以两个下划线开始,表示这些方法在PHP特定事件下将会被触发.这可能听起来有点自动魔法但是它真的很酷的,我们已经看过一个简单的例子在 last post,即我们使用一个 ...

  8. Linux 快捷键汇总(偏基础)

    自己最近才搭上Linux末班车,有一种想见恨晚的感觉,完全给你一种快速清爽的感觉! 因为需要,所以学习,记录自己在使用Linux系统上的点滴,偏基础! 1. 打开终端: Ctrl+Alt+T 2. 复 ...

  9. Windows系统下Nginx的安装与配置

    Nginx是lgor Sysoev在2004年的时候为俄罗斯访问量第二大的rambler.ru站点设计开发的,发布至今,凭借开源的力量,已经接近成熟与完善.其功能丰富,可作为HTTP服务器,也可作为反 ...

  10. 237. Delete Node in a Linked List(leetcode)

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...