How to Fix bash: nethogs: command not found in Minimal Linux

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.

  1. On Ubuntu, Debian, Linux Mint, and derivatives:
    sudo apt update && sudo apt install -y nethogs
  2. On CentOS, Rocky Linux, AlmaLinux, RHEL, and Fedora:
    sudo dnf install -y epel-release && sudo dnf install -y nethogs
  3. On Alpine Linux:
    apk update && apk add nethogs
  4. 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. eth0 or enp3s0) 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.

  1. Use ss -ti to inspect active TCP socket throughput and process ownership.
  2. Use lsof -i to correlate active network connections with running system processes.
  3. Use iftop or bmon if already present in your base image to render real-time ASCII bandwidth graphs.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.