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 &NBSP;]&NBSP;[&NBSP;+|-E&NBSP;S&NBSP;]&NBSP;[&NBSP;+|-F&NBSP;[CFGGN]&NBSP;]&NBSP;[&NBSP;-F&NBSP;[F]&NBSP;] [ -g [s] ] [ -i [i] ] [ &NBSP;-K&NBSP;K&NBSP;]&NBSP;[&NBSP;+|-L&NBSP;[L]&NBSP;]&NBSP;[&NBSP;+|-M&NBSP;M&NBSP;]&NBSP;[&NBSP;+|-M&NBSP;] &NBSP;[&NBSP;-O&NBSP;[O]&NBSP;]&NBSP;[&NBSP;-P&NBSP;S&NBSP;]&NBSP;[&NBSP;+|-R&NBSP;[T[M<FMT>]]&NBSP;] [ -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