How to check which ports are open on Linux

Question: How can I check which ports are currently open on my Linux system?

If a port is open, it means that there is an actively running program (e.g., daemon) which uses the port number to communicate with other programs. If you want to check which ports are open on local Linux system, you can use netstat command. The following will show a list of all active daemons. Under "Local Address" field, you can see the IP address and TCP/UDP ports that each daemon is listening on.

$ netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1539/dnsmasq    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1178/sshd       
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1285/cupsd      
tcp        0      0 0.0.0.0:902             0.0.0.0:*               LISTEN      1832/vmware-authdla
tcp6       0      0 :::22                   :::*                    LISTEN      1178/sshd       
tcp6       0      0 ::1:631                 :::*                    LISTEN      1285/cupsd      
udp        0      0 0.0.0.0:42874           0.0.0.0:*                           1635/dhclient   
udp        0      0 0.0.0.0:40610           0.0.0.0:*                           1223/avahi-daemon: 
udp        0      0 192.168.122.1:53        0.0.0.0:*                           1539/dnsmasq    
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1539/dnsmasq    
udp        0      0 0.0.0.0:68              0.0.0.0:*                           3019/dhclient   
udp        0      0 0.0.0.0:68              0.0.0.0:*                           1635/dhclient   
udp        0      0 0.0.0.0:17446           0.0.0.0:*                           3019/dhclient   
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           1223/avahi-daemon: 
udp6       0      0 :::22228                :::*                                3019/dhclient   
udp6       0      0 :::64460                :::*                                1635/dhclient   
udp6       0      0 :::49459                :::*                                1223/avahi-daemon: 
udp6       0      0 :::5353                 :::*                                1223/avahi-daemon: 
Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

Leave a comment

Your email address will not be published. Required fields are marked *