Linux considers everything it comes across a file and stores them in folders/directories. So, at every point, there will be many files running in Linux, some will be visible and some won't.
LSOF stands for "List of Open Files". The command gives a list of files that are open at a particular moment. Basically, it gives the information to find out the files which are opened by which processes. In one go, it lists all the files open in the output console. It doesn't only list the files, but also directories, block special files, shared libraries, regular pipes, named pipes, etc.
Syntax:
1. lsof: This command lists out all the files opened by any running process.
Syntax:
Example:
2. lsof -u: There are several users in the Linux Operating System with different requirements. To know which users have which files open at a particular moment, the -u option is used.
Syntax:
Example:
3. lsof -c: This option of the lsof command can be used to list all the files open at a particular moment by a particular system process. -c option lists the files based on the process name.
Example 1:
Example 2:
4. lsof -p: This option of the lsof command can be used to list all the files open at a particular moment by a particular system process. -p option lists the files based on the process ID.
Syntax:
Example:
5. lsof -i: The -i option of the lsof command is use to list all the files open currently by the network connections.
Syntax:
Example:
Comments