How to Install lsof Command on Ubuntu 21.04 Server

How to Install lsof Command on Ubuntu 21.04 Server

 

lsof means ‘List Open Files’. On Linux servers, Lsof command is used to find all files that are open by a process that is running on the server.

root@ubuntu-server [/]# lsof -i :8080
-bash: /usr/sbin/lsof: No such file or directory

[root@ubuntu-server ~]# lsof -p 3096
-bash: lsof: command not found

Error shows that lsof command is not installed on your Ubuntu server. Do the below steps to install lsof command on Ubuntu 21.04 Server.

1. Log into your Linux server via SSH as root or sudo user

2. Install lsof package on the server using apt

3. Enter ‘y’ if apt ask for confirmation while installing lsof.
 

root@ubuntu-21:/usr/local/src# apt install lsof
Reading package lists… Done
Building dependency tree
Reading state information… Done
Suggested packages:
perl
The following NEW packages will be installed:
lsof
0 upgraded, 1 newly installed, 0 to remove and 84 not upgraded.
Need to get 252 kB of archives.
After this operation, 466 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu hirsute/main amd64 lsof amd64 4.93.2+dfsg-1.1 [252 kB]
Fetched 252 kB in 3s (83.0 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package lsof.
(Reading database … 6125 files and directories currently installed.)
Preparing to unpack …/lsof_4.93.2+dfsg-1.1_amd64.deb …
Unpacking lsof (4.93.2+dfsg-1.1) …
Setting up lsof (4.93.2+dfsg-1.1) …

 
Now lsof package is installed on your Linux Server.
 

How to install Lsof command on Ubuntu 21.04 Server

How to install Lsof command on Ubuntu 21.04 Server


 

Steps to download lsof.deb package on Ubuntu 21.04 Server

1. You must log into your Ubuntu server as root or sudo user

2. Download lsof deb file from ubuntu website using wget command

3. Install the package using apt or dpkg command

4. Run ‘lsof -v’ to verify the installation

apt command will install lsof package and the required dependencies
 

cd /usr/local/src

wget http://archive.ubuntu.com/ubuntu/pool/main/l/lsof/lsof_4.93.2+dfsg-1.1_amd64.deb

apt install ./lsof_4.93.2+dfsg-1.1_amd64.deb

 
lsof -v
lsof version information:
revision: 4.93.2