Skip to content

Instantly share code, notes, and snippets.

@davidlares
Last active January 4, 2020 02:34
Show Gist options
  • Save davidlares/f0f118c5af148f2f0b4a7f9485d7bf98 to your computer and use it in GitHub Desktop.
Save davidlares/f0f118c5af148f2f0b4a7f9485d7bf98 to your computer and use it in GitHub Desktop.
Simple script for checking open ports TCPv4 with Bash
#!/bin/bash
# this script shows the open network ports on a system
# -4 to limit TCP IPv4 ports
if [[ "${1}" = '-4' ]]
then
netstat -nutl ${1} | grep ':' | awk '{print $4}' | awk -F ':' '{print $NF}'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment