How to find out list of all open ports in Ubuntu/Arch Linux

network_port.png

In computer networking a port is a logical entity which acts as a endpoint of communication to identify a given application or process on an Linux operating system. It is a 16-bit number (0 to 65535) which differentiates one application from another on end systems.

Below are the different categories of ports:

  • 0 - 1023 – the Well Known Ports, also referred to as System Ports.
  • 1024 - 49151 – the Registered Ports, also known as User Ports.
  • 49152 - 65535 – the Dynamic Ports, also referred to as the Private Ports.

You can view a list of different applications and port/protocol combination in /etc/services file in Ubuntu/Arch Linux using cat command:

cat /etc/services 

The two most popular Internet transport protocols are Transmission Control Protocol (TCP) and User Datagram Protocol (UDP).

To list all open ports or currently running ports including TCP and UDP in Ubuntu/Arch Linux, we will use netstat, is a powerful tool for monitoring network connections and statistics.

netstat -lntu

Where,

  • -l – prints only listening sockets
  • -n – shows port number
  • -t – enables listing of tcp ports
  • -u – enables listing of udp ports

You can also use ss command, a well known useful utility for examining sockets in a Ubuntu/Arch Linux system. Run the command below to list all your open TCP and UCP ports:

ss -lntu
comments powered by Disqus