Get the port number from the process id in UNIX
shell, unix
Solution
You can use `lsof` command to list ports in Mac OS X.
# This will list all the ports
sudo lsof -i -P | grep -i LISTEN
# This will list ports used by PID# <pid>
sudo lsof -i -P | grep -i LISTEN | grep <pid>
Problem
I am trying to get the port number for the running process in UNIX. below command gives me process ID: ``` ps -ef | grep process_name 502 741 389 0 11:02AM ttys000 0:00.00 grep process_name ``` Can someone please help me on how to get the ports used by the process. Thanks!