lsof Command Introduction:
Lsof (list open files) is a tool that lists open files for the current system. In a Linux environment, everything is in the form of files, with files that not only access regular data, but also access to network connectivity and hardware. So, Lsof is a powerful feature. The general root user can execute the lsof command, and the normal user will see the/usr/sbin/lsof command, but normal user execution displays "permission denied". It is therefore helpful to see this list through the Lsof tool for system monitoring and troubleshooting.
Enter lsof at the terminal to display the file opened by the system, because lsof needs to access core memory and various files, so it must be run as root to fully perform its functions.
Each row displays an open file, and all files opened by all processes are displayed by default if you do not specify a condition. 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 in which the application recognizes the file through a file descriptor. such as CWD, TXT, etc.
Type: File types, such as Dir, Reg, etc.
DEVICE: Specifies the name of the disk
Size: Sizes of files
Node: Index node (the identity of the file on disk)
Name: Open the exact name of the file
The usage of the LSOF directive is as follows:
Lsof Abc.txt shows the process of opening the file Abc.txt
Lsof Directory name lookup who is using the file directory system
Lsof-i: 22 knows which process is consuming the 22 port
LSOF-C ABC show ABC process now open file
Lsof-g GID shows the process of attribution to GID
Lsof-n do not convert IP to hostname, the default is not to add the-n parameter
Lsof-p 12 See which files are open by process number 12
Lsof-u username See what files users open
Lsof-i @192.168.1.111 View Remote Open network connection (connected to 192.168.1.111)
--------------------------------------
Lsof-i to show condition-eligible processes
Syntax: lsof-i[46] [protocol][@hostname |hostaddr][:service|port]
IPv4 or IPv6
Protocol-TCP or UDP
Hostname Internet Host Name
Location HOSTADDR-IPV4
The service name (can be more than one) in service-/etc/service
Port and port number (can be more than one)
--------------------------------------
Lsof +|-r [T] control lsof repeated execution, default is 15s refresh
-r,lsof will continue to execute forever until an interrupt signal is received.
+r,lsof will continue to execute until no files are displayed
Example: Constantly check the current situation of FTP connection: lsof-i [email protected]: Ftp-r
http://blog.csdn.net/xifeijian/article/details/9088137
The Linux lsof command