Reputation: 778
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
Reputation: 571
This will show only the port:
netstat -plantu | grep <pid> | awk '{print $4}' | awk -F ":" '{print $2}'
Upvotes: 3
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