How to Watch TCP and UDP Ports in Real-time in Linux?

LinuxOperating SystemNetwork

In a computer network, the network service runs software in each of the computers that are part of the network. In Linux System this network software uses a protocol called TCP or UDP along with port number. TCP is known as transmission control protocol and UDP is known as user datagram protocol. In this article we will see how to watch the ports are sockets which are running on this protocols on a real time basis.

List of Open Ports

As a first step we look for the open ports that are available in the system. Bye open we mean the ports are available for listening which also means accepting request from other systems. The below command is used to list the open ports.

Example

$ sudo netstat –tulpn
The meaning of various flags is as below.
t - enable listing of TCP ports.
u - enables listing of UDP ports.
l - print only the open sockets.
p - print the program name
n – print the port number

Output

Running the above code gives us the following result −

Open Ports in Real-Time

But in case you want to watch the ports in real time, so that you can monitor the number of bytes, sent and received, then we have to add the watch flag.

Example

$ sudo watch netstat –tulpn

Output

Running the above code gives us the following result −

raja
Published on 14-Feb-2020 10:59:38
Advertisements