- shivani singh
- October 3, 2021
Steps to install lsof on ubuntu 20.04 LTS
lsof stand for “List Of Open File”,is a command line utility.It provides a list of open files & gives the information to find out the open files by which process.
There are some steps to install lsof on ubuntu:
Step 1: Update the system.
apt-get update
Step 2: Install Isof on system.
apt install lsof
- Check the Isof version.
lsof -v
- Here is the command output.
Step 3: Isof Syntax & Examples:
- To list all open files.
lsof
- Here is the command output.
- To list all processes with open files under a specified directory.
lsof +D /var/log/
- Here is the command output.
- To list all files in a specified user.
lsof -u user-name
lsof -u ubuntu
- Here is the command output.
- To list all open files by using a specific process ID.
lsof -p 1238
- Here is the command output.
- To run lsof command to repeat the command at the specified time interval.
lsof -p 1238 -r5
- Here is the command output.
- To list Network Connections using lsof.
lsof -i
- Here is the command output.
- To list connections on a specific port.
lsof -i:22
- Here is the command output.
lsof -i -a -c ssh
- Here is the command output.
- To list Connections on a range of ports.
lsof -i:22-25
- Here is the command output.
- To Limit the output to either IPv4 or IPv6.
lsof -i4
- Here is the command output.
lsof -i6
- Here is the command output.