How to Install netstat on Debian 12?
Netstat is a valuable tool for monitoring network connections as well as troubleshooting network concerns. It is a command-line tool that enlists routing tables, network connections, multicast memberships, and interface statistics.
Netstat is not installed by default on Debian 12, which uses the “iproute2” package instead. However, some users may prefer to use “netstat” for its familiarity and compatibility with other Linux distributions. It can help users troubleshoot network issues, secure as well as optimize the system performance.
By considering its importance, this guide will explain how to install “netstat” on Debian 12 (the latest stable release of the popular Linux distribution) and its basic “netstat” commands to display network information.
How to Install netstat on Debian 12?
On Linux systems, netstat tool monitors network connections and statistics. It displays information about network interfaces, routing tables, TCP and UDP connections, and more. To install netstat on Debian 12, use the below methods:
- Method 1: Using the net-tools Package
- Method 2: Using inetutils-tools Package
- Method 3: Using ss Command
Method 1: Install netstat Using the net-tools Package
The “net-tools” package is a collection of networking utilities that includes “netstat”, “ifconfig”, “route”, “arp”, and others. It is found in the Debian repositories (official) and users can be installed from it. To install “netstat” from the “net-tools” package, follow the below-mentioned steps:
Step 1: Update Package Lists
First, use the “update” utility with the “apt” command to reload the system repository:
sudo apt update
It updates the package lists.
Step 2: Install net-tools Package
To install the net-tools package on Debian 12, specify the package name which is “net-tools” with the “install” utility. It installs the required dependent packages:
sudo apt install net-tools
Step 3: Verify netstat
To verify that netstat is installed, enter the “which” command with the “netstat” as below:
which netstat
It displays the output of the netstat path “/usr/bin/netstat”.
To confirms its installation, use the same path as in below command:
/usr/bin/netstat
Monitor Network Connections/Statistics
Now use the “netstat” command to monitor the network connections along with statistics:
Available Options and Usage of netstat
After installing the package, run “netstat” with the -help option to see the available flags and parameters:
netstat --help
This method has installed netstat tool/utility on Debian using the “net-tools” package.
Method 2: Install netstat Using inetutils-tools Package
The “inetutils-tools” package is another collection of networking utilities that includes “netstat”, “ping”, “telnet”, “ftp”, and others. It is also found in the official Debian repositories, and users can be installed easily. The netstat is part of the “inetutils-tools” package. To install “netstat” from the inetutils-tools package, consider these steps:
Step 1: Update Package Lists
It is the recommended practice to update the package lists before any package installation:
sudo apt update
Step 2: Install inetutils-tools Package
To install the “inetutils-tools” package, specify the “inetutils-tools” package name with the “install” utility:
sudo apt install inetutils-tools
Step 3: Verify netstat Installation
To verify that netstat is installed or not, execute the “version” utility with the “netstat” command:
netstat --version
It visualizes the output showing the netstat version “2.10” and the “inetutils-tools” package name.
After installing the package, you can run netstat with the “-h” or “–help” option to see the available flags and parameters:
netstat --help
It authenticates that netstat has been installed on Debian 12.
Method 3: Install netstat Using ss Command
The ss command is an alternative/replacement for “netstat” that can visualize more information (statistics) and faster performance. It is part of the “iproute2” package (by default installed on Debian 12). Users can use the “ss” command with various options to show network statistics and connections.
Note: netstat has been deprecated and replaced by the ss command, which is faster, more human-readable, and can display more information about sockets.
Install ss Command
To install the ss command, users need to install the “iproute2” package, which contains various utilities for network administration. Based on Linux distribution, follow one of the below commands to install iproute2:
sudo apt install iproute2 # For Debian/Ubuntu sudo dnf install iproute2 # For Fedora/CentOS sudo pacman -S iproute2 # For Arch Linux
After installing “iproute2”, use the “ss” command to display information about sockets. Some of the common options for ss are:
Options
Description/Usage
-a
Show all sockets (listening as well as non-listening)
-l
Show only listening sockets
-t
Displays TCP sockets
-u
Enlists UDP sockets
-n
Show numeric addresses and ports (don't resolve names)
-p
Show process ID and name for each socket
-s
Show summary statistics for each socket type
-e
Show extended information for each socket
For more information and examples, check the man page of ss by executing the below command:
man ss
How to Use netstat Commands on Debian 12?
Netstat is a command-line tool that enlists routing tables, network connections, multicast memberships and interface statistics. It assists users in troubleshooting network issues, and secure/optimize the system. It has various options that can modify its output as below:
Options
Description
-a
Displays all sockets.
-n
Shows numerical addresses instead of resolving hostnames.
-p
Enlists process ID, program name that owns each socket.
-r
Displays the information regarding the kernel routing table.
-s
Displays stats data/info regarding protocol.
-t
Displays TCP connections.
-u
Displays UDP connections.
-v
Prints verbose output, including errors and warnings.
To use netstat commands on Debian 12 with all possible examples and detailed explanations, follow the use cases below:
- Display All Sockets Information
To use netstat, users need to execute the “netstat” command along with the above options. For instance, display all sockets using the “a” option/utility:
netstat -a
It shows the local, foreign addresses as well as each connection (state).
- Show Addresses (Numerical)
Users can also use the “-n” option to show numerical addresses instead of hostnames, which can speed up the output:
netstat -n
- Display Process ID and Program Name
To display the process ID as well as the program name of every socket, use the “-p” option. It identifies the number of applications that are using network resources:
netstat -p
- Display Kernel Routing Table
To display the kernel routing table, use the -r option. It displays how packets are routed to different destinations:
netstat -r
- Display Statistics Each Protocol
To display stats for individual protocols, use the “-s” option. It shows users how many packets have been sent and received, how many errors have occurred, and other useful information:
netstat -s
- Verbose Output
To display more information about each socket or connection, use the “-v” option. It prints verbose output, including errors and warnings:
netstat -v
These are some of the basic examples of how to use netstat commands on Debian 12.
Users can also combine different options to modify/customize the output/results. For details, navigate the man page of “netstat” by typing “man” as below:
man netstat
That is all from the installation and usage of netstat on Debian 12.
Conclusion
netstat tool monitors network connections as well as statistics on Debian 12. To install netstat on Debian 12, use the APT package manager and install the “net-tools” or “inetutils-tools” packages. Alternatively, use the “ss” command, which is part of the “iproute2” package and provides similar functionality as “netstat”. Users can also use other tools like “nmap”, “lsof”, or “tcpdump” to complement netstat and get more information about the network.
This article has explained how to install netstat on Debian 12 and use it effectively.


















