zoukankan      html  css  js  c++  java
  • Linux 查看 80 端口的占用情况

     lsof -i:端口号

    eg:

        lsof -i:80

        lsof -i:21

    [root@localhost ~]# lsof -i:80
    COMMAND  PID   USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
    httpd   4168   root    3u  IPv4 1917545678      0t0  TCP *:http (LISTEN)
    httpd   4170 nagios    3u  IPv4 1917545678      0t0  TCP *:http (LISTEN)
    httpd   4171 nagios    3u  IPv4 1917545678      0t0  TCP *:http (LISTEN)
    httpd   4172 nagios    3u  IPv4 1917545678      0t0  TCP *:http (LISTEN)
    httpd   4173 nagios    3u  IPv4 1917545678      0t0  TCP *:http (LISTEN)
    httpd   4174 nagios    3u  IPv4 1917545678      0t0  TCP *:http (LISTEN)
    httpd   4175 nagios    3u  IPv4 1917545678      0t0  TCP *:http (LISTEN)
    httpd   4176 nagios    3u  IPv4 1917545678      0t0  TCP *:http (LISTEN)
    httpd   4177 nagios    3u  IPv4 1917545678      0t0  TCP *:http (LISTEN)

    lsof(list open files)是一个列出当前系统打开文件的工具。

    实例2:查看谁正在使用某个文件,也就是说查找某个文件相关的进程

    命令:

    lsof /bin/bash

    输出:

    复制代码
    [root@localhost ~]# lsof /bin/bash
    COMMAND   PID USER  FD   TYPE DEVICE   SIZE    NODE NAME
    bash    24159 root txt    REG    8,2 801528 5368780 /bin/bash
    bash    24909 root txt    REG    8,2 801528 5368780 /bin/bash
    bash    24941 root txt    REG    8,2 801528 5368780 /bin/bash
    [root@localhost ~]# 
    复制代码

     ---------------------------------------------------------------------------------------

    实例6:列出某个程序进程所打开的文件信息

    命令:

    lsof -c mysql

    说明:

     -c 选项将会列出所有以mysql这个进程开头的程序的文件,其实你也可以写成 lsof | grep mysql, 但是第一种方法明显比第二种方法要少打几个字符了

    -----------------------------------------------------------------------------------------

    实例16:列出谁在使用某个端口

    命令:

    lsof -i :3306

    dd

  • 相关阅读:
    Python 迭代器&生成器,装饰器,递归,算法基础:二分查找、二维数组转换,正则表达式,作业:计算器开发
    python--如何在线上环境优雅的修改配置文件?
    Python补充--Python内置函数清单
    python3--open函数
    内置函数--map,filter,reduce
    Python内置函数—bytearray
    python lambda表达式简单用法
    Python浅拷贝copy()与深拷贝deepcopy()区别
    点击复制
    eval(function(p,a,c,k,e,d){e=function(c)加解密
  • 原文地址:https://www.cnblogs.com/hanggegege/p/5929217.html
Copyright © 2011-2022 走看看