Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I use netstat -tup, it only shows the processes for some. There are other ports that just have a - for PID, so how would I find out what process is listening on these ports?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

When you display this list, for lines that have no process name, can you check the state of the tcp socket?

If it is a closing socket, the process may have disconnected and the TCP Stack might be just cleaning up the connection.

Secondly, are you running the netstat command with root rights?
If you do not have rights to the process, its name will not be listed.
Actually, if that happens, most netstat versions will show a warning about this before listing the output.

share|improve this answer
    
Running it with root rights shows everything. Thanks Why though can I see the processes with ps aux, but not with netstat? –  Jack May 8 '10 at 9:13
    
@Jack A normal user can see all listening ports and all running processes - but cannot see which process is using which ports. (ps does not need this information.) –  grawity May 8 '10 at 16:01
add comment

What you can also do is use lsof.

Lets say you wanted to know all process that are using port 80, you could type:

lsof -i :80

And get a list of processes that are listening/using port 80. As well as program name and user.

share|improve this answer
    
Ahh, thankyou. I didn't know I could use lsof for that. –  Jack May 11 '10 at 5:02
add comment

Your Answer

 
discard

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.