sudo: netstat: command not found
A popular tool used by many Sysadmins is the netstat tool. Its name is derived from two words: network and statistics. The popular utility displays network connections for Transmission Control Protocol, routing tables, and a number of network interface and network protocol statistics. One of its most common uses is to inform users which ports and addresses are in use/open (TCP and UDP) and by which process ID or task.
Just recently I got a call from a friend who was trying to set up their own Ubuntu 20.04 virtual machine (VM) for the first time. In the past, I had created VMs for them and installed all of the commonly used tools. Thus, while they were used to using netstat, they did not know it was installed by a package of a slightly different name - net-tools.
The Error
When my friend tried to use netstat -tulpn they got the below error.
sudo: netstat: command not found
What does this error mean?
This essentially just told them that the command was not found because the package was missing. Thankfully, this is a simple fix.
How to fix this error?
To fix the above error, we need to install the net-tools package since it includes netstat. Run the below command to initiate the install.
apt-get install net-tools
After this install is complete you can run the netstat command that originally triggered the error to verify if it works now.
As a warning, the net-tools package will also install the arp, ipconfig, rarp, nameif, and route tools.
Should you have any trouble, send me a message and I'll do my best to help out.