Script to check the open ports on linux
Script Name: port_check.bash
Run the script as below
bash port_check.bash <port no 1> <port no 2> etc
#!/bin/bash printf "%-10s%-10s%-s\n" PORT LISTENING printf "%-10s%-10s%-s\n" ---- --------- for PNUM in "$@" do netstat -tulpn | grep -w ":${PNUM}" > /dev/null if [ $? -eq 0 ] then PORT_LISN="Yes" else PORT_LISN="No" fi printf "%-10s%-10s%-s\n" $PNUM $PORT_LISN done