This page looks best with JavaScript enabled

How to check which program is using a port on Linux

 ·  ☕ 1 min read  ·  ✍️ anz007

You can detect which process is bound to what port number by using lsof command.

Simply specify the port number you are interested in with “-i:(port-number)” option.

For example, to find out which processes are using port number 631, run the following command.

1
  $ sudo lsof -i:631 -n -P
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
cupsd     776 root   10u  IPv6   9353      0t0  TCP [::1]:631(LISTEN)
cupsd     776 root   11u  IPv4   9354      0t0  TCP 127.0.0.1:631(LISTEN)
cups-brow 953 root    8u  IPv4   9930      0t0  UDP *:631</strong>

In the above, “-n” option prevents automatic conversion of host IP address to host name, and “-P” option prohibits conversion of port number to port name. In this example, cupsd and cups-brow processes are using TCP and UDP port number 631, respectively.

To see a list of all open TCP ports, along with their associated programs/processes, you can run the command below.

1
$ sudo lsof -i -n -P | grep TCP

Output

Share on