How to Install netstat on Debian

Install netstat on Debian 11, 12, or 13 with apt install net-tools, fix netstat command not found on minimal images, compare listening ports and routes with ss from iproute2, and remove net-tools cleanly.

Published

Updated

Read time 5 min read

Reviewed byDeepak Prasad

How to Install netstat on Debian

netstat prints open sockets, routing tables, and interface statistics—the classic view of “what is listening on this host?” On Debian, it is not its own package: you install net-tools with apt. Minimal images usually ship ss from iproute2 instead, so netstat: command not found is normal until you install net-tools or use ss (Super User, linuxconfig.org).

This guide covers install netstat on Debian for Debian 11 (Bullseye), 12 (Bookworm), and 13 (Trixie): fix command not found, install net-tools, verify listeners and routes, compare with ss, and uninstall. I ran these steps on Debian 13 and kept real terminal output below. For interface addresses, see install ifconfig on Debian—the same package provides both tools.

Tested on: Debian 13 (trixie); kernel 6.12.94+deb13-amd64; amd64; net-tools 2.10-1.3; iproute2 6.15.0 (ss pre-installed).

NOTE
Debian does not ship a package named netstat. packages.debian.org contents search points at net-tools. apt install netstat returns Unable to locate package netstat.

Choose an approach

Approach Best for On test host
apt install net-tools Legacy scripts, exams, tutorials that call netstat netstat at /usr/bin/netstat
ss from iproute2 New work, automation, default on minimal Debian ss -tuln works without net-tools
Both Transition while updating old playbooks Common on desktop images

Prefer ss for new automation. Install net-tools when something explicitly runs netstat.


Check whether netstat is installed

bash
. /etc/os-release && echo "$PRETTY_NAME"
command -v netstat || echo "netstat: not in PATH"
command -v ss && ss --version | head -1
dpkg -l net-tools 2>/dev/null | grep ^ii
apt-cache policy net-tools | head -8

Before installing on the test host:

text
Debian GNU/Linux 13 (trixie)
netstat: not in PATH
/usr/bin/ss
ss utility, iproute2-6.15.0

ss was already available; net-tools was not:

text
net-tools:
  Installed: (none)
  Candidate: 2.10-1.3

Prerequisites

  • Debian 11, 12, or 13 with network access for apt.
  • sudo for package install.
  • iproute2 (ss) is usually already installed.

Install netstat with net-tools

Install the NET-3 networking toolkit (Ultahost, Tecmint):

bash
sudo apt update
sudo apt install -y net-tools
text
Fetched 245 kB in 1s (282 kB/s)
Selecting previously unselected package net-tools.
Unpacking net-tools (2.10-1.3) ...
Setting up net-tools (2.10-1.3) ...

Verify:

bash
netstat --version | head -1
which netstat
dpkg -S "$(which netstat)"
text
net-tools 2.10
/usr/bin/netstat
net-tools: /usr/bin/netstat

Other binaries in net-tools

One install also provides legacy tools (install ifconfig on Debian):

bash
dpkg -L net-tools | grep -E '^/usr/(s)?bin/' | grep -E 'ifconfig|netstat|route|arp'
text
/usr/bin/netstat
/usr/sbin/ifconfig
/usr/sbin/route
/usr/sbin/arp

Common netstat commands

Listening TCP and UDP ports

bash
netstat -tuln
text
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
Flag Meaning
-t TCP sockets
-u UDP sockets
-l Listening only
-n Numeric addresses (no DNS)

Processes owning sockets

bash
sudo netstat -tulnp | head -10
text
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      807/sshd: /usr/sbin
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      789/cupsd

Routing table

bash
netstat -r
text
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         _gateway        0.0.0.0         UG        0 0          0 enp0s3
10.0.2.0        0.0.0.0         255.255.255.0   U         0 0          0 enp0s3

For modern route management, see ip route command.

Interface statistics

bash
netstat -i
text
Kernel Interface table
Iface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
enp0s3           1500  9194805      0      0 0        691876      0      0      0 BMRU
lo              65536   552758      0      0 0        552758      0      0      0 LRU

iproute2 is the maintained replacement. On the test host, ss worked before net-tools was installed:

bash
ss -tuln | head -8
text
Netid State  Recv-Q Send-Q Local Address:Port  Peer Address:Port
tcp   LISTEN 0      128          0.0.0.0:22         0.0.0.0:*
tcp   LISTEN 0      4096       127.0.0.1:631        0.0.0.0:*
tcp6  LISTEN 0      128             [::]:22            [::]:*
Task netstat ss (iproute2)
Listening TCP/UDP netstat -tuln ss -tuln
With process names sudo netstat -tulnp sudo ss -tulnp
Routing table netstat -r ip route
Interface stats netstat -i ip -s link

See the ss command in Linux and Linux ip command guides for filters and scripting.

HINT
netstat is deprecated upstream in favor of ss, but net-tools remains in Debian main for compatibility. New playbooks should call ss; keep netstat when a vendor script or certification lab requires it.

Read the manual

bash
MANPAGER=cat man netstat 2>/dev/null | head -8
text
NETSTAT(8)            Linux System Administration            NETSTAT(8)

NAME
       netstat - Print network connections, routing tables, interface statis‐
       tics, masquerade connections, and multicast memberships

Update net-tools

bash
sudo apt update
sudo apt install --only-upgrade net-tools
netstat --version | head -1

Check the installed version with list installed packages on Debian:

bash
dpkg -l net-tools | grep ^ii

Uninstall netstat (remove net-tools)

Removing net-tools removes netstat, ifconfig, route, and related binaries together:

bash
sudo apt remove net-tools

Dry-run on the test host:

text
The following packages will be REMOVED:
  net-tools
Remv net-tools [2.10-1.3]

Use ss afterward for socket listing. Scripts that call netstat break until you reinstall net-tools or rewrite them.


Troubleshooting

Symptom Likely cause Fix
netstat: command not found net-tools not installed sudo apt install net-tools
Unable to locate package netstat No such package name Install net-tools, not netstat
Empty PID column Not running as root sudo netstat -tulnp
netstat vs ss output differs Different column layout / filters Use matching flags; see ss command
Works on one host, not another Minimal image without net-tools Install package or use ss
Still missing after install Broken dpkg state dpkg -l net-tools; sudo apt install -f

References


Summary

Install netstat on Debian with sudo apt install net-tools—there is no separate netstat package. Fix command not found on minimal images by installing net-tools, or use ss -tuln from iproute2 for listening ports. Verify with netstat --version and dpkg -S /usr/bin/netstat, use sudo netstat -tulnp when you need PIDs, and remove net-tools when you no longer need legacy NET-3 utilities.


Frequently Asked Questions

1. How do I install netstat on Debian?

Run sudo apt update && sudo apt install -y net-tools. netstat ships in the NET-3 net-tools package at /usr/bin/netstat—not a separate netstat package.

2. Why is netstat command not found on Debian?

Minimal and many server images omit net-tools because ss from iproute2 replaced netstat for socket inspection. Install net-tools when you need netstat, or use ss -tuln instead.

3. What package contains netstat on Debian?

net-tools. Confirm with dpkg -S /usr/bin/netstat after install. apt install netstat fails because no package is named netstat.

4. Should I use netstat or ss on Debian?

ss from iproute2 is the modern default and is usually pre-installed. netstat from net-tools matches legacy tutorials and scripts—install net-tools only when you need it.

5. How do I list listening ports without netstat?

Use ss -tuln for TCP/UDP listeners or ss -tulnp when you need process names (root). See the ss command guide for more filters.

6. Does netstat show process names on Debian?

Run sudo netstat -tulnp or netstat -anp as root. Without root, PID/program columns may be hidden for other users processes.

7. Is net-tools installed by default on Debian?

Not on every image. Full desktops may include it; minimal netinst and cloud images often do not. Run command -v netstat to check.

8. How do I uninstall netstat from Debian?

sudo apt remove net-tools removes netstat, ifconfig, route, and other NET-3 binaries together.
Omer Cakmak

Linux Administrator

Highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on …