Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

I would like to see what ports are open on my machine, e.g. what ports my machine is listening on. E.g. port 80 if I have installed a web server, and so on.

Is there any command for this?

share|improve this question
up vote 47 down vote accepted

nmap Install nmap

Nmap ("Network Mapper") is a free and open source utility for network exploration or security auditing

nmap internal Pc or nmap external ip address

more information man nmap

share|improve this answer
Thanks, nmap localhost worked great. – Jonas Oct 25 '10 at 13:24
Remember that there is a difference between nmap localhost and nmap (or what ever you machine IP is) – LassePoulsen Oct 25 '10 at 14:47
If you want a nice GUI for nmap, you can try 'zenmap'. – htorque Oct 28 '10 at 11:17
I think netstat is a better answer to this. netstat will list what the system is listening on directly, and without using an additional application or doing unnecessary calls over localhost or thought the network. – Mathieu Trudel-Lapierre Nov 3 '10 at 1:57
@Mathieu: I agree with that. I change my accepted answer. – Jonas May 27 '11 at 14:44

Other good ways to find out what ports are listenting and what your firewall rules are:

  • sudo netstat -tulpn

  • sudo ufw status

share|improve this answer
I change the answer to nmap again, the usability of netstat is crap. – Jonas Mar 23 '14 at 17:28

To list open ports use the netstat command.

For example:

    $ sudo netstat -tulpn | grep LISTEN
    tcp        0      0  *               LISTEN      5452/dnsmasq    
    tcp        0      0 *               LISTEN      1037/cupsd      
    tcp6       0      0 ::1:631                 :::*                    LISTEN      1037/cupsd

In the above example three services are bound to the loopback address.

IPv4 services bound to the loopback address "" are only available on the local machine. The equivalent loopback address for IPv6 is "::1". The IPv4 address "" means "any IP address", which would mean that other machines could potentially connect to any of the locally configured network interfaces on the specific port.

Another method is to use the lsof command:

    $ sudo lsof -nP -i | grep LISTEN
    cupsd     1037   root    9u  IPv6  11276      0t0  TCP [::1]:631 (LISTEN)
    cupsd     1037   root   10u  IPv4  11277      0t0  TCP (LISTEN)
    dnsmasq   5452 nobody    5u  IPv4 212707      0t0  TCP (LISTEN)

For more details see man netstat or man lsof.

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.