43

How could I tell what is listening on which ports on Ubuntu? In other words, how do I get a list of ports that are in use?

1 Answer 1

53

"In use" as in with an active connection, or that programs are listening on? Or both?

Run sudo netstat -lp in your terminal; this will tell you what ports are open to receive connections, and what programs are listening on them. Try sudo netstat -p for the same thing, plus currently-active connections.

5
  • I think both is best ;)
    – Genadinik
    Apr 19, 2011 at 17:57
  • What was a little strange is that I have tomcat and apache servers running and neither port 8080 nor 80 showed up in the list. Would you know why that would happen?
    – Genadinik
    Apr 19, 2011 at 18:02
  • @Genadinik Verify what port they are configured to listen on; for Apache this is the Listen directive in its config file, but I don't know about Tomcat.
    – Kromey
    Apr 19, 2011 at 18:06
  • 11
    fuser -n tcp 8080 will approach it from the other end; showing you which process (if any) is listening on TCP port 8080. Apr 19, 2011 at 18:12
  • If what Kromey suggested didn't cut it, try sudo netstat -tulpn. Jul 14, 2020 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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