nstat

nstat shows network statistics and counters.

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 systemPackage nameInstallation
AlmaLinuxiproute
dnf install iproute
Arch Linuxiproute2
pacman -S iproute2
Debianiproute2
apt install iproute2
Fedoraiproute
dnf install iproute
Red Hat Enterprise Linuxiproute
dnf install iproute
Rocky Linuxiproute
dnf install iproute
Ubuntuiproute2
apt install iproute2

Your Linux distribution using a different package? Share your feedback.

Usage

Available options

Short optionLong optionDescription
-a--ignoreShow absolute values instead of incremented values
-d--scan <INTERVAL>Daemon mode and collect statistics with specified interval
-j--jsonJSON output
-h--helpDisplay help
-n--nooutputNo output, but do update the history
-p--prettyMake output easier to read. To be used with --json
-r--resetReset history, allows showing totals
-s--noupdateDon't update history, include counters during next run
-t--interval <INTERVAL>Disk activity summary
-z--zerosAlso show counters with a value of zero

Missing an option in this overview? Share your feedback.

Relevant articles using the nstat command

The following articles include an example on how to use nstat and might be worth further exploring.