Better than netstat: lsof tells us who is listening to what

This post was written by eli on December 1, 2018
Posted Under: Internet,Linux

OK, so we have netstat to tell us which ports are opened for listening:

$ netstat -n -a | grep "LISTEN "

Thanks, that nice, but what process is listening to these ports? For TCP sockets, it’s (as root):

# lsof -n -P -i tcp 2>/dev/null | grep LISTEN

The -P flag disables conversion from port numbers to protocol names. -n prevents conversion of host names.

Add a Comment

required, use real name
required, will not be published
optional, your blog address