nstat
nstat shows network statistics and counters.
Typical usage: diagnosing network issues, network monitoring, system administration, troubleshootingIntroduction into nstat
Users of the command-line are typically aware of the netstat command. The package that netstat belongs to is getting deprecated and slowly replaced with tools like ip. This is also where nstat comes in, a more modern approach to pulling in data from the kernel. Another benefit is that it can retrieve more information than netstat. This is due to the static list of metrics that netstat looks for, while nstat will parse output files from /proc.
Sources that nstat uses to retrieve its information include the following files.
- /proc/net/netstat
- /proc/net/snmp
- /proc/net/snmp6
- /proc/net/sctp/snmp
- /proc/uptime
Installation
When nstat is not installed by default, it can be added to the system using the relevant software package.
Package information for nstat
Operating system | Package name | Installation |
---|---|---|
AlmaLinux | iproute |
|
Arch Linux | iproute2 |
|
Debian | iproute2 |
|
Fedora | iproute |
|
Red Hat Enterprise Linux | iproute |
|
Rocky Linux | iproute |
|
Ubuntu | iproute2 |
|
Your Linux distribution using a different package? Share your feedback.
Usage
Available options
Long option | Short option | Description |
---|---|---|
--ignore | -a | Show absolute values instead of incremented values |
--scan <INTERVAL> | -d | Daemon mode and collect statistics with specified interval |
--json | -j | JSON output |
--help | -h | Display help |
--nooutput | -n | No output, but do update the history |
--pretty | -p | Make output easier to read. To be used with --json |
--reset | -r | Reset history, allows showing totals |
--noupdate | -s | Don't update history, include counters during next run |
--interval <INTERVAL> | -t | Disk activity summary |
--zeros | -z | Also show counters with a value of zero |
Missing an option in this overview? Share your feedback.
Frequently Asked Questions
What is the nstat command and its purpose?
The command nstat provides network interface statistics on Linux and can be used for monitoring and troubleshooting. Learn about the available nstat options.
Which package provides the nstat command?
The command nstat is provided by the iproute or iproute2 package.
Relevant articles using the nstat command
The following articles include an example on how to use nstat and might be worth further exploring.
Related and similar commands
Linux has a lot of tools and commands available and sometimes you just need that little other tool. Here is a list of commands that are similar or related to nstat:
Command | Category | Summary |
---|---|---|
dig | DNS | Performs DNS requests |
fuser | files and sockets | Show processes using a file or socket |
iftop | network | Bandwidth usage monitor |
ip | networking | Shows network configuration and information |
resolvectl | network | Name resolution information from resolve daemon |
ss | sockets | Shows information about sockets |
tcpdump | network sniffing | Monitors network traffic on specified interface |
Also 💙 the command-line or terminal? Here is a set of cheat sheets for Linux to get more done from within the shell: