To which port is a process attached in Linux

1.1k views Asked by At

I want to know which port is my Jonas, on which a Java project has been deployed, is attached to in a Linux server. I have the pid of the Jonas and tried netstat -lnp but I found no port attached to that PID. Any idea of how to do this.

2

There are 2 answers

0
dlmeetei On

There are many ways to do, I prefer this

sudo netstat -pan |grep pid

Also, you can use

sudo lsof -Pan -p pid -i

pid should be actual "pid" number that you have

0
Jenish Patel On

Open a terminal application i.e. shell prompt.
Run any one of the following command:

sudo lsof -i -P -n | grep LISTEN   
sudo netstat -tulpn | grep LISTEN  
sudo nmap -sTU -O IP-address-Here  

lsof command

The syntax is:

$ sudo lsof -i -P -n  
$ sudo lsof -i -P -n | grep LISTEN  
$ doas lsof -i -P -n | grep LISTEN ### [OpenBSD] ###