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?

intcreator
  • 123
  • 5
Genadinik
  • 1,083
  • 4
  • 18
  • 38

1 Answers1

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.

Kromey
  • 3,621
  • 4
  • 24
  • 30
  • I think both is best ;) – Genadinik Apr 19 '11 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 '11 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 '11 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. – SmallClanger Apr 19 '11 at 18:12
  • If what Kromey suggested didn't cut it, try `sudo netstat -tulpn`. – Omid Ariyan Jul 14 '20 at 21:36