Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a Solaris 8 server, how do I find out what process is listening on a given port? The Windows implementation of 'netstat' offers the -o and -b switches, which show the owning process ID and name respectively. Is there an equivalent under Solaris?

share|improve this question
up vote 6 down vote accepted

lsof -i

Doesn't come installed by default, but you can get Solaris version from

share|improve this answer
Which netstat option provides the owning process under Solaris? I can't seem to find one in the man page? – Murali Suriar May 8 '09 at 9:30
You're right, thought it's like Linux netstat. But in Solaris -p has different meaning. – vartec May 8 '09 at 9:43
+1 for lsof, definitely worth the trouble of installing. -i takes arguments of protocol and protocol:port, so you can do something like lsof -i TCP:25 to find out who's listening to 25/tcp (hopefully your mail server!) – jj33 May 8 '09 at 12:18
Great answer, i'm never going to struggle with netstat -anp | grep again – Dave Cheney May 9 '09 at 14:56

If you don't want to or can't install lsof, you can also try the command pfiles. It prints out all the sockets open by a given process. If you had no other choice, you could iterate over all the PIDs and find the one listening to, say, port 25:

for p in $(ps -eo pid)
  OUT=$(pfiles $p)
  if [[ "$OUT" =~ port:\ ${PORT} ]]
    echo $p
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.