Skip to content

Instantly share code, notes, and snippets.

@sandheepg
Last active July 24, 2017 11:23
Show Gist options
  • Select an option

  • Save sandheepg/c6fb6ac0dd0f6852a4f08305356da7dc to your computer and use it in GitHub Desktop.

Select an option

Save sandheepg/c6fb6ac0dd0f6852a4f08305356da7dc to your computer and use it in GitHub Desktop.
Check for listening ports in Linux

As a developer / administrator, its important to know which ports are listening on the server's network interfaces. They are important for a variety of reasons. To name a few,

  • To check if a port is already in use by a different application
  • To troubleshoot any issues
  • To detect any intrusion

To determine if a port is in use under an Unix-like system you can use lsof, netstat, nmap commands.

sudo lsof -i -P -n | grep LISTEN

sudo netstat -tulpn | grep LISTEN
netstat -anp tcp | grep LISTEN # for mac
netstat -anp udp | grep LISTEN # for mac

sudo nmap -sTU -O IP-address-Here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment