Here we are going to see how to Check the port used by any process in unix?
Check the port used by any process in unix?
Here is how you can check port used by any process in unix terminal.
While developing any webservice or web server you might end up using existing port number and will face issue while starting the server
Before such thing happens, better to check the port is being used by any process already to avoid such conflicts. Its saves us more time.
We have discussed below listed commands
- netstat – network utility used for checking the connection of TCP/UDP
- ss – Socket statistics, similar to netstat but faster.
- sudo – Run any command with root or super user level/mode.
netstat command
aryanz_co_in@pop-os:~/dev/folder1$ sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN 5314/mysqld
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 5314/mysqld
udp 0 0 127.0.0.53:53 0.0.0.0:* 4434/systemd-resolv
ss command
aryanz_co_in@pop-os:~/dev/folder1$ sudo ss -tulpn
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
udp UNCONN 0 0 127.0.0.53%lo:53 0.0.0.0:* users:(("systemd-resolve",pid=4434,fd=12))
tcp LISTEN 0 70 127.0.0.1:33060 0.0.0.0:* users:(("mysqld",pid=5314,fd=32))
tcp LISTEN 0 151 127.0.0.1:3306 0.0.0.0:* users:(("mysqld",pid=5314,fd=34))
