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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM