Ubuntu Netstat Command – List Opened Port and Services
The Ubuntu netstat command is used to display network-related information such as open connections and socket ports. On Ubuntu 18.04, you’ll need to install the net-tools package to use the netstat command:
apt install net-tools
The Ubuntu netstat command without any command-line arguments, it will display a list of active sockets for each network protocol.
netstat
If you use -t option, it will filter the output to display TCP connections only:
netstat -t
To display both TCP and UDP connections use the -tu option:
netstat -tu

The netstat command most of the time used with -tulnp options to display listening ports (sockets) and services on a Linux system.

the -l flag will limit the results to only listening sockets, the -n flag will display all hosts and ports as numeric values and the -p flag will display the process ID and program name.
Other uses of netstat command include showing routing table (netstat -r) and list network interfaces (netstat -i).