netstat Linux command is used by system administrators to see information about network connections. Netstat is a powerful utility that can print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. It has been superseded by the ss command in recent years so you may get the “bash: netstat: command not found” error, but is still a viable tool for network diagnostics and troubleshooting.
bash: netstat: command not found will occur on up to date Ubuntu and Debian Linux systems when trying to execute the
netstat command, as it is no longer included by default. In this tutorial, you will learn how to install the
net-tools package on Ubuntu and Debian-based Linux systems, which provides access to the
netstat command, among others.
In this tutorial you will learn:
- How to install
net-toolson Debian and Ubuntu
|Requirements, Conventions or Software Version Used
|Ubuntu and Debian
|Privileged access to your Linux system as root or via the
|# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
bash: netstat: command not found – Debian/Ubuntu Linux
ss command replaced the older
netstat command on Linux. See our tutorial on Using ss command on Linux to see usage examples for the
ss command and learn how it differs from
If you are looking for the netstat command and getting error:
bash: netstat: command not found
This simply means that the relevant package
net-tools which includes
netstat executable is not installed, thus missing. The package
net-tools may not be installed on your system by default so you need to install it manually.
The package also includes aditional utilisties such as
netstat available on your system simply install the
net-tools package using the below command:
$ sudo apt update $ sudo apt install net-tools
Using netstat command on Debian/Ubuntu Linux
netstat is installed on your system, you can use some of the commands below to get started using it.
- First, let’s view the processes that are listening for connections. To do so so enter the following command.
$ sudo netstat -tulpen
- Now let’s take a look at all of the current network connections. To do this enter the following command, which is similar to the previous one except that we use
-ato view all sockets instead of
-lto just view listening sockets.
$ sudo netstat -atupen
- You may find yourself in a situation where you only want to view the
ESTABLISHEDconnections. This is as easy as piping the output of netstat to grep like so.
$ sudo netstat -atupen | grep ESTABLISHED
- The netstat’s
-ioption brings up a table listing all configured network interfaces on the system:
$ sudo netstat -i
In this tutorial, we saw how to install the missing
netstat command on an Ubuntu or other Debian based Linux system. We also learned some basic usage of the
netstat command in order to get started using it. You will also want to look into the
ss command, which supersedes
netstat but has a separate syntax.