Terminal GuideTerminal Guide

nethogs

System Monitoring
Linux
C++

Network traffic monitor showing bandwidth per process.

Official Website

Features

Per-process NetworkReal-timeLightweightNo Dependencies

Installation

APT (Debian/Ubuntu)
apt install nethogs
Pacman (Arch)
pacman -S nethogs
DNF (Fedora)
dnf install nethogs

Why Use nethogs?

Per-Process Network Tracking

See exactly which processes are sending and receiving data, including real-time bandwidth usage for each application.

Real-Time Bandwidth Monitoring

Monitor network performance in real-time to identify bandwidth-hungry applications and network anomalies quickly.

Simple and Focused

Specialized tool for network monitoring. Lightweight with minimal dependencies and quick to identify network issues.

Multiple Device Support

Monitor specific network interfaces or all interfaces simultaneously to track network activity across your system.

Installation

installation
# Ubuntu/Debian
sudo apt install nethogs

# Fedora/RHEL
sudo dnf install nethogs

# Arch Linux
sudo pacman -S nethogs

# CentOS
sudo yum install nethogs

# Verify installation
nethogs -V

# Note: nethogs requires root/sudo privileges to run

Basic Usage

basic-usage
# Start nethogs (monitors all interfaces by default)
sudo nethogs

# Monitor specific network interface
sudo nethogs eth0

# Monitor multiple interfaces
sudo nethogs eth0 eth1 wlan0

# Run in batch mode (non-interactive output)
sudo nethogs -b

# Set refresh interval (in seconds)
sudo nethogs -d 2

# Show packets instead of bandwidth
sudo nethogs -p

# Get help
nethogs -h

Key Options & Interactive Commands

Command Line Options

OptionDescription
-b, --batchNon-interactive batch mode for logging
-d SEC, --delay SECRefresh interval in seconds (default: 1)
-p, --packetsShow packets per second instead of bytes/sec
-u, --units B|K|M|GDisplay units (bytes, kilobytes, megabytes, gigabytes)
-s COL, --sort COLSort by column (RECV, SENT, or name)
-tShow on separate terminal via truss
-c NUMRun for NUM refreshes then exit

Interactive Mode Shortcuts

KeyFunction
rReverse sort order
sSort by sent traffic
pSort by process name
mToggle display units
qQuit nethogs

Practical Examples

1. Identify Bandwidth Hogs

example-bandwidth-hogs
# Start interactive monitoring on all interfaces
sudo nethogs

# Key tips:
# - Processes are sorted by total bandwidth by default
# - Red entries indicate the most bandwidth consumption
# - Press 'r' to reverse sort order
# - Press 's' to sort by sent traffic specifically

2. Monitor Specific Interface

example-specific-interface
# Monitor only eth0 interface
sudo nethogs eth0

# Monitor only WiFi interface
sudo nethogs wlan0

# Useful when you have multiple network cards and want to focus on one

3. Batch Mode for Logging

example-batch-logging
# Collect network data for 60 seconds with 5-second intervals
sudo nethogs -b -d 5 -c 12 > network_log.txt

# Background collection with timestamps
nohup bash -c 'while true; do   echo "=== $(date) ===" >> nethogs.log;   sudo nethogs -b -d 1 -c 5 >> nethogs.log;   echo "---" >> nethogs.log;   sleep 60; done' &

# Save ongoing monitoring
sudo nethogs -b -d 2 | tee -a network_traffic.log

4. Monitor Network Activity by Protocol

example-protocols
# View packets instead of bandwidth
sudo nethogs -p

# Monitor with custom refresh rate
sudo nethogs -d 2

# Show in megabytes (easier to read for large transfers)
sudo nethogs -u M

5. Find Network Issues

example-find-issues
# Monitor during suspected network problems
watch -n 1 'sudo nethogs -b -d 1 -c 1'

# Run with packet monitoring to find anomalies
sudo nethogs -p

# Run in background and capture unusual activity
sudo nethogs -b -d 5 | tee -a network_analysis.txt

# Filter output for specific process
sudo nethogs -b -d 2 -c 10 | grep chrome

Understanding the Output

Column Meanings

PID/Name

Process ID and name - identifies which process/application is using network

USER

Username who owns the process

RECV

Bandwidth being received (downloaded) by this process

SENT

Bandwidth being sent (uploaded) by this process

PROTO (optional)

Network protocol being used (TCP, UDP, etc.)

Example Output

example-output
nethogs (v0.8.6) running on ubuntu

Refreshing every 1s
interface: eth0
PID USER    RECV      SENT      PROTO
1234 www-data 5.25 MB/s 2.10 MB/s TCP
5678 root     1.50 MB/s 0.75 MB/s TCP
9012 mysql    0.50 MB/s 0.30 MB/s TCP
3456 chrome   0.15 MB/s 0.08 MB/s TCP
7890 sshd     0.00 MB/s 0.00 MB/s TCP

TOTAL                    7.40 MB/s 3.23 MB/s

Comparison with Similar Tools

vs. iftop

nethogs shows per-process bandwidth, while iftop shows bandwidth by host/connection. nethogs is better for identifying which applications are using the network.

vs. vnstat

nethogs provides real-time monitoring, while vnstat tracks historical network usage. Use nethogs for immediate diagnosis, vnstat for trend analysis.

vs. ss/netstat

nethogs shows real-time bandwidth by process, while ss/netstat show connection details. nethogs is more focused on bandwidth monitoring.

Tips

1. Root Privileges Required

nethogs needs root access to monitor network traffic. Always use 'sudo nethogs' or configure sudoers for passwordless access if running frequently.

2. Identify Unexpected Traffic

Regularly check nethogs output to identify unexpected processes consuming bandwidth. Unusual traffic patterns may indicate malware or misconfiguration.

3. Use Batch Mode with Cron

Schedule nethogs batch collection via cron for periodic network usage reports. Combine with grep to filter specific applications.

4. Monitor Specific Interfaces

On multi-interface systems, monitor specific interfaces to reduce noise and focus on relevant network activity.

5. Combine with Other Tools

Use nethogs with ss/netstat to get connection details, or with tcpdump for packet-level analysis when more details are needed.

6. Use watch for Continuous Monitoring

Wrap nethogs in watch command for automated refresh: 'watch -n 1 "sudo nethogs -b -d 1 -c 1"' for continuous updates.

Written by Dai AokiPublished: 2026-01-20

Related Articles

Explore More