Random Musings

Sporadic thoughts on tech, economics, business, finance and trading

bash: lsof: command not found

,

The error -bash: lsof: command not found indicates that the lsof command is not installed on your system. To use lsof, you need to install it first.

Steps to Install lsof

  1. For RHEL/CentOS-based systems (including Amazon Linux):

Run the following command to install lsof:

   sudo yum install -y lsof
  1. For Debian/Ubuntu-based systems:

Run:

   sudo apt update
   sudo apt install -y lsof
  1. Verify the Installation:

After installation, verify that lsof is available:

   lsof -v
  1. Re-run the Command:

After lsof is installed, you can run:

   lsof -iTCP | grep LISTEN

If you are unable to install software due to restrictions or package manager issues, you can use netstat (if available) as an alternative:

netstat -antp | grep LISTEN