How to Install lsof Command on CentOS/RHEL 7 Servers
How to Install lsof Command on CentOS/RHEL 7 Servers
root@server [/]# lsof -i :80
-bash: /usr/sbin/lsof: No such file or directory
[root@server1 ~]# lsof -p 8916
-bash: lsof: command not found
Error shows that lsof command is not installed on your server. Do the below steps to install lsof command on your CentOS 7 / Redhat 7 Server.
1. Log into your linux server via SSH as root
2. Install lsof package on the server using yum
3. Enter ‘y’ if yum ask for confirmation while installing lsof.
Resolving Dependencies
–> Running transaction check
—> Package lsof.x86_64 0:4.87-4.el7 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
======================================================================================
Package Arch Version Repository Size
======================================================================================
Installing:
lsof x86_64 4.87-4.el7 base 331 k
Transaction Summary
=====================================================================================
Install 1 Package
Total download size: 331 k
Installed size: 927 k
Is this ok [y/d/N]: y
Downloading packages:
lsof-4.87-4.el7.x86_64.rpm | 331 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : lsof-4.87-4.el7.x86_64 1/1
Verifying : lsof-4.87-4.el7.x86_64 1/1
Installed:
lsof.x86_64 0:4.87-4.el7
Complete!
Now lsof package is installed on your Linux Server.

How to Install lsof command on CentOS RHEL 7 Linux Server
How to download and install lsof rpm on CentOS 7 / RHEL 7 server
1. You must log into your CentOS 7 / RHEL 7 server as root user
2. Download lsof rpm from CentOS website using wget command
# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/lsof-4.87-6.el7.x86_64.rpm
3. You can install the downloaded rpm file using yum or rpm command
# yum install lsof-4.87-6.el7.x86_64.rpm
yum command will lsof package and the required dependencies
# rpm -ivh lsof-4.87-6.el7.x86_64.rpm
You must first install the dependencies, if you are installing using yum command.
lsof command need the below dependencies :
libselinux
glibc
The above dependencies will be installed by default on CentOS7 / RHEL7 server.