Lsof of Linux commands

Source: Internet
Author: User

Brief introduction:

Lsof (list open files) is a tool that lists open files for the current system. In the Linux environment, everything is in the form of files, and files are not only accessible to regular data, but also access to network connectivity and hardware (source Baidu encyclopedia).


Lsof the files or PID numbers that are used by the lookup process are very important in terms of those files, especially after the Linux system is hacked, it can be called a heavyweight command.


Detailed format:

[[Email protected] ~]# lsof -c httpd | head -5command  pid    USER   FD   TYPE  DEVICE SIZE/OFF     NODE NAMEhttpd   6083   root  cwd     DIR     8,2     4096        2 /httpd   6083   root  rtd     dir     8,2     4096        2 /httpd   6083   root  txt    reg      8,3   355232  136356 /usr/sbin/httpdhttpd    6083   root  mem    REG      8,3    83088&nBsp; 667789 /usr/lib64/php/modules/zip.so 


The meaning of the lsof output column information is as follows:

COMMAND: Name of the process PID: Process identifier User: Process owner FD: File descriptor, the application recognizes the file through a file descriptor. such as CWD, TXT, etc. type: file type, such as Dir, Reg, and other device: Specify the name of the disk size: size of File Node: Index node (identity of file on disk) name: The exact name of the open file


Common parameters:

name       lsof - list open filessynopsis        lsof [ -?abchlnnoprtuvvx ] [ -a a ] [  -c c ] [ +c c ] [ +|-d d ] [ +|-d d  ] [ +|-E S ] [ +|-F [CFGGN] ] [ -F [F] ]  [ -g [s] ] [ -i [i]       ] [  -K K ] [ +|-L [L] ] [ +|-M M ] [ +|-M ]  [ -O [O] ] [ -P S ] [ +|-R [T[M<FMT>]] ]  [ -s [p:s] ] [ -S [t] ] [ -T [t] ] [   -u  s  ]  [       +|-w ] [  -x [fl] ] [&nbsP;-z [z] ] [ -z [z] ] [ -- ] [names] 



Lsof dirname//See which users have opened this directory

Lsof-u username//View what files the user opened

Lsof-g GID//View the process of attribution to GID

lsof-i:22//See which processes originate from Port 22

Lsof-c httpd//See what files are open by the httpd process

Lsof-p 22166 //See which files are open for process number 22166 processes



Lsof of Linux commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.