The Linux system abstracts the hardware and software into files, so the files can be traced to a lot of important information, such as the read configuration file, open port and so on.
The following are common uses:
The default test file is named Text.txt
1, shows the process of opening text.txt:
Lsof Text.txt
2, shows the process that occupies a port:
Lsof-i: 80
3, displays a process (process name) Open file:
Lsof-c Process_name
4, display a process number (PID) Open file:
Lsof-p Pid_number
5, displays a file opened by a user:
Lsof-u user_name
The default output field is interpreted as:
[Groot] $lsof-U Groot
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
COMMAND: Process name (only the first 9 characters are taken by default);
pid:process identification number;
User:the user ID number or login name of the user to whom the process belongs;
Fd:file Descriptor number or
CWD Current working directory;
LTX Shared library text (code and data);
Mem memory-mapped file;
Mmap memory-mapped device;
PD parent Directory;
RTD root directory;
TXT program text (Code and data);
Type:is the type of the node associated with the file-e.g, Gdir, GREG, VDIR, VREG, etc.
"Linux" common commands lsof viewing open files