Cart 0
No products in the cart.


How to use lsof command in Linux ?

This article covers using lsof and the different options available. In fact, The lsof command is a powerful and useful tool for analyzing open files, ports, and processes in Linux.

 

How to fix "lsof Command Not Found" Error in Linux ?

If you are a Linux user, you may have encountered the “lsof command not found” error while trying to run the lsof command. The lsof command stands for “list open files”, and it is a useful tool for troubleshooting and monitoring the open files and network connections of a Linux system.

Fortunately, the "lsof command not found" error is easy to fix. Follow the below steps to resolve this issue:

 

1. Install the lsof package: 

The first step is to install the lsof package, which contains the lsof command. If you are using a Debian-based distribution such as Ubuntu, you can install the package using the apt command:

$ sudo apt install lsof

If you are using a Red Hat-based distribution such as CentOS, you can install the package using the yum command:

$ sudo yum install lsof

 

2. Add the lsof command to your path: 

The next step is to add the lsof command to your system path. This will allow you to execute the lsof command without having to specify its full path.

To do this, open the ~/.bashrc file in a text editor and add the following line to the bottom of the file:

$ export PATH=$PATH:/usr/bin/lsof

This will add the path to the lsof command to your system path.

 

3. Source the bashrc file: 

Once you have added the line to your ~/.bashrc file, you need to source the file to make the changes take effect. To do this, run the following command:

$ source ~/.bashrc

After sourcing the file, you should be able to execute the lsof command without any errors.

 

That's it! With these simple steps, you should be able to resolve the "lsof command not found" error and make the lsof command available on your system.

 



icon

Sign up to Newsletter

...and receive a free support ticket.