Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any command line command or any other way to find and list out the busy and free port numbers on my Linux machine?

share|improve this question

3 Answers 3

up vote 17 down vote accepted

The command

netstat -antu

will show all tcp and udp ports in use. The output will look something like this:

Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 *               LISTEN

The number after the colon in the Local Address field shows the port in use. If the state is "LISTEN" it means a port that is using for incoming connections. If the IP address in the Local Address field is it means incoming connections will be accepted on any IP address assigned to an interface - so this means from connections originating outside of your machine.

If it said localhost or it would be only accepting connections from your machine.

Additionally, if you add the -p parameter, and run it as root, it will show the process that opened the port:

$ sudo netstat -antup
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 *               LISTEN      860/rpc.statd

Anything not shown as being in use is free, however users (unprivileged accounts) can only open ports above 1023.

share|improve this answer

I compiled a small list myself.

Some of my favorites are:

netstat -tulpn
lsof -i -n -P
share|improve this answer

Another way:

telnet localhost <PORT_NUMBER>

If the port is free you will get an error. If the port is in use telnet will connect.

(found on http://www.unix.com/unix-for-dummies-questions-and-answers/8456-how-know-whether-particular-port-number-free-not.html)

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.