Table of Contents

How to check a port? locally and remotely on Linux

About

This page is about Port management on Linux.

When you install a software (process), you need often to verify the available port in order to configure the component installation.

How to find which process uses a port?

with netstat, you can check port.

For example, below, you can see that the port 1521 is used to the program tnslsnr (The -p parameters means program and is mandatory)

netstat -tulpn | grep 1521
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)

Protocol   Recv-Q Send-Q  Local Address     Foreign Address     State
tcp        0      0       :::1521           :::*                LISTEN      4264/tnslsnr

where:

How to check a port remotely?

with Network - netcat (nc, ncat)

nc -zv hostname port
DNS fwd/rev mismatch: hostname  != hostname.lan
hostname  [192.168.135.6] 9000 (?) open

How to see the ports used by well-known services?

To see the port used by services, you can inspect the services file (The services translation file), located at:

/etc/services