In software terms, especially at the operating system level, a port is a logical construct that identifies a specific process/application or a type of network service and each network service running on a Linux system uses a particular protocol (the most common being the TCP (Transmission Control Protocol) and UDP (User Datagram Protocol)) and a port number for communicating with other processes or services.
In this short article, we will show you how to list and monitor or watch running TCP and UDP ports in real-time with a socket summary on a Linux system.
List All Open Ports in Linux
$ sudo netstat -tulpn OR $ sudo ss -tulpn
From the output of the above command, the State column shows whether a port is in a listening state (LISTEN) or not.
In the above command, the flag:
-t– enables listing of TCP ports.
-u– enables listing of UDP ports.
-l– prints only listening sockets.
-n– shows the port number.
-p– show process/program name.
Watch TCP and UDP Open Ports in Real-Time
$ sudo watch netstat -tulpn OR $ sudo watch ss -tulpn
To exit, press
You will also find the following articles useful:
- 3 Ways to Find Out Which Process Listening on a Particular Port
- How to Check Remote Ports are Reachable Using ‘nc’ Command
- How to List All Running Services Under Systemd in Linux
- 29 Practical Examples of Nmap Commands for Linux System/Network Administrators
That’s all for now! If you have any questions or thoughts to share about this topic, reach us via the comment section below.