https://www.cyberciti.biz/faq/ping-test-a-specific-port-of-machine-ip-address-using-linux-unix/

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  
# check for tcp port ##
  
## need bash shell ##
  
echo >/dev/tcp/{host}/{port}

(echo >/dev/tcp/{host}/{port}) &>/dev/null && echo "open" || echo "close"
  
(echo >/dev/udp/{host}/{port}) &>/dev/null && echo "open" || echo "close"
  
(echo >/dev/tcp/www.cyberciti.biz/22) &>/dev/null && echo "Open 22" || echo "Close 22"
  
(echo >/dev/tcp/www.cyberciti.biz/443) &>/dev/null && echo "Open 443" || echo "Close 443"