When unexpected bandwidth spikes consume cloud network allocations, the nethogs command-line utility provides real-time per-process network traffic monitoring. Unlike standard utilities that break down bandwidth per protocol or subnet, nethogs groups bandwidth by process ID (PID) and executable name, instantly revealing which daemon is saturating your connection. In stripped cloud virtual machines and lightweight Docker base images, running the command outputs bash: nethogs: command not found.
Install nethogs via Distribution Package Managers
Installing nethogs is supported across all major Linux package distributions.
- On Ubuntu, Debian, Linux Mint, and derivatives:
sudo apt update && sudo apt install -y nethogs - On CentOS, Rocky Linux, AlmaLinux, RHEL, and Fedora:
sudo dnf install -y epel-release && sudo dnf install -y nethogs - On Alpine Linux:
apk update && apk add nethogs - On Arch Linux:
sudo pacman -Sy nethogs
Grant Raw Packet Capture Permissions to Non-Root Users
Because nethogs reconstructs network packet headers using libpcap, non-root users require explicit packet capture capabilities.
- Execute nethogs with root privileges:
sudo nethogs eth0. - Alternatively, assign raw packet capture capabilities:
sudo setcap 'cap_net_raw,cap_net_admin+ep' $(which nethogs) - Specify your active network interface (e.g.
eth0orenp3s0) as an argument to monitor the appropriate interface.
Alternative Real-Time Network Bandwidth Telemetry Tools
If operating inside strict immutable containers where installing nethogs is restricted, native utilities provide bandwidth telemetry.
- Use
ss -tito inspect active TCP socket throughput and process ownership. - Use
lsof -ito correlate active network connections with running system processes. - Use
iftoporbmonif already present in your base image to render real-time ASCII bandwidth graphs.