×

Find Out Which Processes are Listening on a Particular Port in Ubuntu 20.04

This article covers methods to find out the processes that are listening to particular ports on your Linux system. A port is nothing but an endpoint of communication used in computer networks.

You have physical or wireless connections at the hardware level. At software or operating system level a port act as a logical construct that acts as communication port of network service such as SSH, HTTPD and more.

TCP and UDP are the most common port. TCP is an acronym for Transmission Control Protocol. UDP is an acronym for User Datagram Protocol.


How to Find Out Which Process Is Listening Upon a Port in Linux ?

1. netstat command or ss command – a command-line tool that displays network connections, routing tables, and a number of network interface statistics.

2. fuser command – a command line tool to identify processes using files or sockets.

3. lsof command – a command line tool to list open files under Linux / UNIX to report a list of all open files and the processes that opened them.

4. /proc/$pid/ file system – Under Linux /proc includes a directory for each running process (including kernel processes) at /proc/PID, containing information about that process, notably including the processes name that opened port.


Check Open Ports on Ubuntu 20.04 Linux - How to do it ?

This article covers some common tools that can be used to check the open ports on a Linux system. It is important you verify which ports are listening on the server's network interfaces. You need to pay attention to open ports to detect an intrusion. 

Apart from an intrusion, for troubleshooting purposes, it may be necessary to check if a port is already in use by a different application on your servers. 

For example, you may install Apache and Nginx server on the same system. So it is necessary to know if Apache or Nginx is using TCP port # 80/443.


To check the listening ports and applications on Ubuntu Linux:

1. Open a terminal application i.e. shell prompt.

2. Run any one of the following command on Linux to see open ports:

$ sudo lsof -i -P -n | grep LISTEN
$ sudo netstat -tulpn | grep LISTEN
$ sudo ss -tulpn | grep LISTEN
$ sudo lsof -i:22 ## see a specific port such as 22 ##
$ sudo nmap -sTU -O IP-address-Here

For the latest version of Linux use the ss command. For example, ss -tulw


What is the netstat command ?

You can check the listening ports and applications with netstat as follows.

Run netstat command along with grep command to filter out port in LISTEN state:

$ netstat -tulpn | grep LISTEN

The netstat command deprecated for some time on Linux. Therefore, you need to use the ss command as follows:

$ sudo ss -tulw
$ sudo ss -tulwn
$ sudo ss -tulwn | grep LISTEN



More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com






Keep In Touch