Check Which Port Number a Process is Listening on

$ sudo ss -ltnp



State        Recv-Q        Send-Q                Local Address:Port                  Peer Address:Port
LISTEN 0 100 127.0.0.1:25 0.0.0.0:* users:(("master",pid=3877,fd=13))
LISTEN 0 128 0.0.0.0:443 0.0.0.0:* users:(("sshd",pid=4544,fd=3))
LISTEN 0 127 0.0.0.0:988 0.0.0.0:*
LISTEN 0 2 0.0.0.0:3389 0.0.0.0:* users:(("xrdp",pid=4060,fd=11))
LISTEN 0 128 127.0.0.1:38591 0.0.0.0:* users:(("containerd",pid=3748,fd=8))
LISTEN 0 128 0.0.0.0:111 0.0.0.0:* users:(("rpcbind",pid=2704,fd=8))
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=4544,fd=5))
LISTEN 0 2 127.0.0.1:3350 0.0.0.0:* users:(("xrdp-sesman",pid=4049,fd=7))
LISTEN 0 50 *:8443 *:* users:(("java",pid=5120,fd=145))
LISTEN 0 128 [::]:443 [::]:* users:(("sshd",pid=4544,fd=4))
LISTEN 0 128 [::]:111 [::]:* users:(("rpcbind",pid=2704,fd=11))
LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=4544,fd=6))
$ sudo lsof -i :443
[ec2-user@ip-172-16-0-86 ~]$ sudo lsof -i :443
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nc 1756 ec2-user 3u IPv4 510594 0t0 TCP ip-172-16-0-86.ca-central-1.compute.internal:49462->ip-192-168-0-48.ca-central-1.compute.internal:https (ESTABLISHED)
nc 1833 ec2-user 3u IPv4 510842 0t0 TCP ip-172-16-0-86.ca-central-1.compute.internal:49536->ip-192-168-0-48.ca-central-1.compute.internal:https (ESTABLISHED)
nc 2466 ec2-user 3u IPv4 514459 0t0 TCP ip-172-16-0-86.ca-central-1.compute.internal:50148->ip-192-168-0-48.ca-central-1.compute.internal:https (ESTABLISHED)
nc 2505 ec2-user 3u IPv4 514590 0t0 TCP ip-172-16-0-86.ca-central-1.compute.internal:50164->ip-192-168-0-48.ca-central-1.compute.internal:https (ESTABLISHED)
[ec2-user@ip-172-16-0-86 ~]$ sudo fuser 443/tcp 
443/tcp: 4544

Comments