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?
will show all tcp and udp ports in use. The output will look something like this:
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
If it said
Additionally, if you add the
Anything not shown as being in use is free, however users (unprivileged accounts) can only open ports above 1023.
I compiled a small list myself.
Some of my favorites are:
If the port is free you will get an error. If the port is in use telnet will connect.
A good and reliable way to check for ports opened is using
And in a script, using grep, we can test if the output contains the port we requested. Example with port 80 in use (see above):
Example with port 81 not in use (see above)