HostOnNet Blog

Terminal Commans to find out which ports are listening / open on your Linux Server

Looking for Linux Server Admin or WordPress Expert? We can help.

You may use netstat command, which print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships etc. Another (and suggested) option is to use lsof command, which list open files, and ports on Linux, FreeBSD, Solaris and other Unixish systems. You must run this by login as root user on your server:

netstat command to find open ports

netstat --listen

To display open ports and established TCP connections, enter:

netstat -vatn

To display only open UDP ports try the following command:

netstat -vaun

To see FQDN (Full DNS Hostname), try removing the -n flag:

netstat -vat

Examples – lsof Command

To display the list of open ports, enter:

lsof -i

To display all open files, use:

lsof

To display all open IPv4 network files in use by the process whose PID is 9255, use:

lsof -i 4 -a -p 9255

For FreeBSD Users:
Use the sockstat command on FreeBSD as follows:

sockstat
sockstat -l
sockstat -4 -l
sockstat -6 -l

 

About Vineesh Mohan

A Technical Support specialist with strong customer service and good communication skills. I live in the city of Cochin, which known as the Queen of Arabian Sea.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.