Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install netstat on Debian 12

netstat shows network connections, ports and routes. On Debian 12 it comes in the net-tools package.

VPS and Cloud Servers1 min read10 screenshots

Check if it is installed

netstat
netstat command not found

If you see "command not found", install the package.

Install netstat

sudo apt install net-tools -y
Installing net-tools

Check the install

netstat
netstat is working

Basic commands

Listening ports

netstat -l
The listening ports

Ports with numbers and program names (needs sudo for the program names)

sudo netstat -plnt
Listening TCP ports with the program names

The options mean: -p program, -l listening, -n numbers, -t TCP.

Statistics

netstat -s
Network statistics

TCP and UDP connections

netstat -t
netstat -u
TCP and UDP connections

The routing table

netstat -r
The routing table

A modern alternative

netstat is old. The newer tool ss is installed by default and shows the same data:

ss -tulpn

Uninstall

sudo apt remove net-tools -y
Removing net-tools

To remove the settings files as well:

sudo apt purge net-tools
Purging net-tools

Quick recap

  • sudo apt install net-tools adds netstat.
  • sudo netstat -plnt shows listening ports and programs.
  • ss -tulpn is the modern replacement.