Fix "bash: netstat: command not found" Error in Ubuntu Linux

Getting the "bash: netstat: command not found" error in Ubuntu Linux? Don't worry! This easy-to-follow guide with images will show you how to fix it in minutes.

Ubuntu Linux - bash: netstat: command not found - Solved

If you are trying to run the netstat command on Ubuntu Linux and you are getting the error message bash: netstat: command not found, it means that the netstat command is not installed on your system.

To install the netstat command, you can use the following command:

sudo apt install net-tools

This will install the net-tools package, which includes the netstat command.

Once the net-tools package is installed, you can verify that the netstat command is installed by running the following command:

netstat --version

You should see output similar to the following:

netstat (net-tools 3.15)

If you are still getting the error message bash: netstat: command not found after installing the net-tools package, it is possible that the netstat command is not in your PATH environment variable.

To add the netstat command to your PATH environment variable, you can open your .bashrc file and add the following line to the end of the file:

export PATH=$PATH:/usr/sbin

This will add the /usr/sbin directory to your PATH environment variable, which is where the netstat command is located.

Once you have added the netstat command to your PATH environment variable, you need to reload your .bashrc file by running the following command:

source ~/.bashrc

Now, you should be able to run the netstat command without any errors.

Additional Notes

  • If you are using a different version of Ubuntu, the steps above may vary slightly.
  • You can also install the netstat command using a Snap package. To do this, open a terminal window and type the following command:
sudo snap install netstat
  • To uninstall the netstat command, type the following command in a terminal window:
sudo apt remove net-tools

Conclusion

If you are getting the error message bash: netstat: command not found on Ubuntu Linux, it means that the netstat command is not installed on your system. To install the netstat command, you can use the sudo apt install net-tools command.

#ubuntu #linux 

Fix "bash: netstat: command not found" Error in Ubuntu Linux
1.05 GEEK