Skip to content

Instantly share code, notes, and snippets.

@JoeyBurzynski
Created May 1, 2016 19:38
Show Gist options
  • Save JoeyBurzynski/f3d927b51dffd5e73e6aeb4241892155 to your computer and use it in GitHub Desktop.
Save JoeyBurzynski/f3d927b51dffd5e73e6aeb4241892155 to your computer and use it in GitHub Desktop.
Command Line: Determine If Port Is Open & Listening
netstat -an |grep 445 |grep LISTEN
# From a bash script how can I quickly find out whether a port 445 is open/listening on a server.
#
# I have tried a couple of options, but I want something quick:
# 1. lsof -i :445 (Takes seconds)
# 2. netstat -an |grep 445 |grep LISTEN (Takes seconds)
# 3. telnet (it doesn't return)
# 4. nmap, netcat are not available on the server
#
# It will be nice to know of a way that doesn't enumerate first and greps after that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment