![](https://www.informativetechguide.com/wp-content/uploads/2021/11/Ubuntu-informativetechguide-1.jpg)
The netstat command in Ubuntu displays network-related data like open connections and socket ports. To use the netstat command on Ubuntu 18.04, you’ll need to install the net-tools package:
apt install net-tools
Without any command-line arguments, the Ubuntu netstat command will display a list of active sockets for each network protocol.
netstat
If you use the -t option, the output will be filtered to only show TCP connections:
netstat -t
Use the -tu option to see both TCP and UDP connections:
netstat -tu
![](https://informativetechguide.com/wp-content/uploads/2021/11/image-18.png)
On a Linux system, the netstat command is typically used with the -tulnp option to display listening ports (sockets) and services.
![](https://informativetechguide.com/wp-content/uploads/2021/11/image-19.png)
The -l flag only displays listening sockets, whereas the -n flag displays all hosts and ports as numeric values, and the -p flag displays the process ID and program name.
The netstat command can also be used to display a routing table or a list of network interfaces (netstat -r) (netstat -i).