lsof工作中常用几个参数

1、查看指定进程名打开的文件
lsof -c mysqld

COMMAND    PID  USER   FD   TYPE             DEVICE  SIZE/OFF     NODE NAME
mysqld_sa 1397  root  cwd    DIR              253,0       213 34667033 /usr/local/mysql
mysqld_sa 1397  root  rtd    DIR              253,0      4096       64 /
mysqld_sa 1397  root  txt    REG              253,0    964536     1791 /usr/bin/bash
/usr/lib64/ld-2.17.so

2、显示指定的进程号所打开的文件
lsof -p 4059

COMMAND  PID   USER   FD      TYPE   DEVICE  SIZE/OFF     NODE NAME
dnsmasq 4059 nobody  cwd       DIR    253,0      4096       64 /
dnsmasq 4059 nobody  rtd       DIR    253,0      4096       64 /
dnsmasq 4059 nobody  txt       REG    253,0    348968 37500761 /usr/sbin/dnsmasq
dnsmasq 4059 nobody  mem       REG    253,0     61560 33587716 /usr/lib64/libnss_files-2.17.so

3、查看某个端口都有哪些进程
lsof -i:80

COMMAND   PID  USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
nginx   17824 nginx    9u  IPv4 13648071      0t0  TCP *:http (LISTEN)
nginx   32430  root    9u  IPv4 13648071      0t0  TCP *:http (LISTEN)

  

posted @ 2023-05-06 21:50  lucky_tomato  阅读(25)  评论(0编辑  收藏  举报