How to Watch TCP and UDP Ports in Real-time

How to Watch TCP and UDP Ports in Real-time


Linux Articles / All 149 Views comments

In software program phrases, particularly on the working system degree, a port is a logical assemble that identifies a selected course of/software or a kind of community service and every community service operating on a Linux system makes use of a specific protocol (the most typical being the TCP (Transmission Management Protocol) and UDP (Consumer Datagram Protocol)) and a port quantity for speaking with different processes or providers.

On this brief article, we'll present you the way to record and monitor or watch operating TCP and UDP ports in real-time with a socket abstract on a Linux system.

Record All Open Ports in Linux

To list all open ports on a Linux system, you should use the netstat command or ss utility as follows.

It's also essential to say that netstat command has been deprecated and as an alternative ss command has taken its place in displaying extra detailed community statistics.

$ sudo netstat -tulpn
$ sudo ss -tulpn

List Open Ports in Linux

Listing Open Ports in Linux

From the output of the above command, the State column exhibits whether or not a port is in a listening state (LISTEN) or not.

Within the above command, the flag:

  • -t – allows itemizing of TCP ports.
  • -u – allows itemizing of UDP ports.
  • -l – prints solely listening sockets.
  • -n – exhibits the port quantity.
  • -p – present course of/program identify.

Watch TCP and UDP Open Ports in Actual-Time

Nevertheless, to observe TCP and UDP ports in real-time, you'll be able to run the netstat or ss tool with the watch utility as proven.

$ sudo watch netstat -tulpn
$ sudo watch ss -tulpn

Watch Open Ports in Real Time in Linux

Watch Open Ports in Actual Time in Linux

To exit, press Ctrl+C.

Additionally, you will discover the next articles helpful:

  1. 3 Ways to Find Out Which Process Listening on a Particular Port
  2. How to Check Remote Ports are Reachable Using ‘nc’ Command
  3. How to List All Running Services Under Systemd in Linux
  4. 29 Practical Examples of Nmap Commands for Linux System/Network Administrators

That’s all for now! If in case you have any questions or ideas to share about this matter, attain us by way of the remark part under.