nstat

nstat shows network statistics and counters.

Typical usage: diagnosing network issues, network monitoring, system administration, troubleshooting

Introduction 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 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

Long optionShort optionDescription
--ignore-aShow absolute values instead of incremented values
--scan <INTERVAL>-dDaemon mode and collect statistics with specified interval
--json-jJSON output
--help-hDisplay help
--nooutput-nNo output, but do update the history
--pretty-pMake output easier to read. To be used with --json
--reset-rReset history, allows showing totals
--noupdate-sDon't update history, include counters during next run
--interval <INTERVAL>-tDisk activity summary
--zeros-zAlso 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:

Related and similar commands to nstat
CommandCategorySummary
digDNSPerforms DNS requests
fuserfiles and socketsShow processes using a file or socket
iftopnetworkBandwidth usage monitor
ipnetworkingShows network configuration and information
resolvectlnetworkName resolution information from resolve daemon
sssocketsShows information about sockets
tcpdumpnetwork sniffingMonitors 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: