Quick Connection Info with ‘netstat’ (Linux)

There are things in this world that will likely always be a mystery to me. For example, why are feminine hygiene products and toothpaste both stored in similar looking tubes? As both of these products are often found in bathrooms around the world it stands to reason that some poor guy (likely living in a home where the residents are primarily female) is going to get them mixed up one morning and it’s going to traumatize him for life…oh yeah right like I’m the ONLY ONE that’s done this!

Another mystery is why I have to wear out Google to figure out how to do even some of the simplest tasks in SOME operating systems that shall remain nameless…cough…Linux…cough…

Ok, I know, and believe me I’m a huge proponent of RTFM but I also don’t want to spend my ENTIRE life R(ing)TFM(s).

So without further ado, if you want to know what network connections are currently established to a Linux system, what programs are listening on what ports on a Linux system, or both at the same time give this a shot:

# List All Connections with Program ID / Program Name

sudo netstat -punt

# List All Listening Ports with Program ID / Program Name

sudo netstat -puntl

# List ALL Connections AND Listening Ports with Program ID / Program Name

sudo netstat -punta

I should note here that this may not work exactly the same (or at all) on EVERY different “flavor” of Linux out there (probably because our lives just aren’t complicated enough). For now this should work on Ubuntu 16.04 and alike.