List all the process running on a given port In the following example we are listing all the open files with PID 1 and 2. command where PID1, PID2 are the PID values. If we want to list all the open files from a set of PIDs then we run the lsof -p PID1,PID2. In the following example we are listing all the process with PID 1. In case the files are not getting listed properly then we can add sudo to the command like sudo lsof -p PID. To list all the open files for a given PID we run the lsof -p PID command. To list all the IPv6 network files that are open we run the following command. To list all the IPv4 network files that are open we run the following command.
In the following example we are listing all the files opened by user yusufshakeel. To know your username run whoami command. To list all the files opened by a user we use lsof -u username command where username is the name of the user. Value for TYPE column can be the following. There are other modes as well like r for read and w write. The FD column stands for file descriptor.įD column can also have values like 1u. Lsof 239 yusufshakeel cwd DIR 1,4 736 2 / $ lsofĬOMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME We run the lsof command to list all the open files. In this tutorial we will learn about lsof command.