roman-v1
roman-v1

Reputation: 778

How to find which port is listening certain process on linux?

My java program need to know, which port is using certain process to send there http queries, how can I find port of process in linux by process name of pid?

Upvotes: 1

Views: 1762

Answers (2)

jcbermu
jcbermu

Reputation: 571

This will show only the port:

netstat -plantu | grep <pid> | awk '{print $4}' | awk -F ":" '{print $2}'

Upvotes: 3

0xDen
0xDen

Reputation: 92

It's actually quite simple from command line, but you need superuser privileges to do so. Run `netstat --inet -apn | grep PID or process name'.

Upvotes: 0

Related Questions