Check all open network ports
Using lsof
lsof is a command meaning “list open files”, which is used in many Unix-like systems to report a list of all open files and the processes that opened them.
example, listing all open ports:
lsof -i -P | grep -i "listen"
Using netstat
netstat (“network statistics”) is a command-line tool that displays network connections (both incoming and outgoing), routing tables, and a number of network interfaces.
example, listing all open ports:
netstat -atp tcp | grep -i "listen"
Checking if certain port is open
Once again we can use lsof or netstat for filtering specific ports and much more. For example if we want to check that the port “80” is being used, we could use any of these commands:
lsof -i -P | grep -i "listen"| grep :80
netstat -atp tcp | grep -i "listen" | grep 80
More info
About netstat:
– Netstat description.
– Useful examples.
About lsof:
– Lsof description.
– Useful examples.