Breaking the telnet addiction with netcat

After many years of use it’s become almost second nature to type ‘telnet <HOST> <PORT>’ when I need to see if a system has TCP port <PORT> open. Newer systems no longer install telnet by default:

$ telnet 80
-bash: telnet: command not found

I can’t think of a valid reason to keep telnet around (there are probably valid use cases). Since netcat and tcpdump are a billion times better for debugging TCP issues, I need to apply newer microcode to my brain to perform a ‘s/telnet/nc -v/g’ each time I need to test if a TCP port is open:

$ nc -v 80
Connection to 80 port [tcp/http] succeeded!

Anyone else have a telnet attachment they just can’t break? :)

3 thoughts on “Breaking the telnet addiction with netcat”

  1. Hey… I have subscribed to your RSS and I read all your writep-ups since OpenSolaris times… Just want to say “Thank you!”


  2. As ksh88 user, you may also use the shell-builtin:

    ksh$ for port in 33333 22; do echo >/dev/tcp/localhost/$port && echo “Port $port is open”; done
    -ksh: /dev/tcp/localhost/33333: cannot create [Connection refused]
    Port 22 is open

    This is very useful if you have a system without netcat :)

Leave a Reply

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