Search code examples
linuxtcpportnetstat

How to find a free TCP port


How do I find a completely free TCP port on a server? I have tried the command line;

netstat -an

but I am told the ones with a status of LISTENING are already being used.

I also tried a tool called TCPView but again it only showed which TCP ports were being used. I know how to telnet to a port to check its open but I need to find one that is free.


Solution

  • netstat -lntu

    This will solve your purpose.