With telnet:
1 |
telnet webserver.example.com 80 |
With bash:
1 |
cat < /dev/tcp/webserver.example.com/80 |
Replace tcp with udp, depending on what you want.
With netcat:
1 |
nc webserver.example.com 80 &> /dev/null; echo $? |
If the port is open, you will get an output of 0. If it’s closed, it’s a 1.