How to Know Which Process is Using a Port on Linux

To find out which process is using a specific port on a Linux system, you can use the lsof command, which stands for “list open files.” lsof lists information about files that are opened by processes running on the system.

Here’s an example of how to use lsof to find out which process is using a specific port:

  1. Open a terminal window.
  2. Run the lsof command with the -i option, followed by the port number and protocol you want to check. For example, to find out which process is using port 80 (the default HTTP port) over TCP, you would run the following command:
lsof -i :80
  1. The output of the lsof command will show a list of processes that have open files associated with the specified port. The first column of the output shows the process ID (PID) of each process. The fourth column shows the name of the process.

Here’s an example of the output you might see:

COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   8888 root    4u  IPv4  12345      0t0  TCP *:http (LISTEN)

In this example, the process with PID 8888 is using port 80 over TCP. The name of the process is “httpd,” which is the process name for the Apache HTTP server.

You can also use the netstat command to find out which process is using a specific port. The netstat command displays network connections, routing tables, and a number of network interface statistics. To find out which process is using a specific port with netstat, you can use the -tulpn options, like this:

netstat -tulpn | grep :80

This will show a list of all the listening ports on the system, along with the PID and name of the process that is using each port.

Visited 81 times, 1 visit(s) today

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top