Checking if a port is open using /dev directory
An old but useful tip. You don’t need telnet, nc or other related tool to check if a port is open.
Lets assume you want to check if the port 22 is open at host 192.168.0.2, perform it:
# echo > /dev/tcp/192.168.0.2/22
Check the return code of the command above
# echo $?
0
If “0”, port is open, if “1” the port is closed.
That’s all.
; )
what command can use I check all port?
You can put it in a loop, for or while