FedoraRHEL Based

How To Install Nethogs on Fedora 42

Install Nethogs on Fedora 42

Network monitoring is essential for system administration and troubleshooting on Linux systems. When unexpected bandwidth consumption occurs, knowing which processes are responsible can help quickly resolve issues. Nethogs stands out as an excellent tool for this purpose on Fedora 42, providing process-level network traffic monitoring with minimal setup. This comprehensive guide will walk you through everything you need to know about installing and using Nethogs on Fedora 42.

Introduction

Nethogs is a compact yet powerful command-line utility often described as a “net top” tool for Linux systems. Unlike conventional network monitoring tools that categorize traffic by protocol or subnet, Nethogs takes a unique approach by grouping bandwidth usage by process. This makes it invaluable for system administrators and power users who need to identify which specific applications or processes are consuming network resources.

Fedora 42, the latest release in the Fedora Linux distribution family, continues to provide robust networking capabilities and support for essential monitoring tools. With the growing complexity of network operations and the increasing number of network-enabled applications, having a reliable tool like Nethogs becomes crucial for effective system management.

In this guide, we’ll explore multiple methods to install Nethogs on Fedora 42, from the straightforward DNF package manager approach to compiling from source code. We’ll also cover basic and advanced usage scenarios, troubleshooting common issues, and compare Nethogs with alternative tools to give you a complete understanding of network monitoring options.

What is Nethogs and Why You Need It

Nethogs is a specialized network monitoring utility that provides real-time insights into network bandwidth consumption on a per-process basis. Created as a solution to the common problem of identifying which specific programs are responsible for network traffic, Nethogs fills an important gap in the Linux system administrator’s toolkit.

Core Functionality and Purpose:

Nethogs operates by capturing network packets and associating them with the processes that generate them. This process-centric approach differs significantly from traditional tools that focus on protocols or network interfaces. The tool displays a continuously updated list of processes using the network, sorted by bandwidth usage, allowing you to instantly identify bandwidth-intensive applications.

Key Distinctions from Other Monitoring Tools:

While tools like iftop, nload, and bmon provide valuable network statistics, they typically show aggregate data or break down traffic by connection rather than by process. Nethogs uniquely answers the question “Which program is using all my bandwidth?” making it indispensable for troubleshooting network-related issues.

Benefits of Using Nethogs:

  • Process-level visibility: Directly identifies which applications are consuming bandwidth
  • No kernel module requirements: Works without special kernel modifications
  • Real-time monitoring: Provides continuous updates on network usage
  • Simple interface: Easy to use with minimal learning curve
  • Low resource consumption: Lightweight design with minimal system impact

On Fedora 42, you’ll have access to Nethogs version 0.8.8-2.fc42, which includes all the essential features and improvements from recent releases. This version offers stable performance, improved IPv6 support, and enhanced monitoring capabilities across multiple network interfaces.

Real-world Applications:

Nethogs proves particularly valuable in scenarios such as:

  • Identifying rogue applications consuming excessive bandwidth
  • Troubleshooting unexpected network slowdowns
  • Monitoring data usage of specific applications
  • Detecting potentially malicious network activity
  • Optimizing bandwidth allocation among applications

For system administrators managing servers or power users monitoring their desktop systems, Nethogs provides critical insights that other network tools simply cannot offer.

Prerequisites for Installing Nethogs

Before proceeding with the installation of Nethogs on Fedora 42, ensure your system meets the necessary requirements and is properly prepared. This preparation will help avoid potential issues during installation and ensure optimal functionality.

System Requirements:

Fedora 42 runs efficiently on most modern hardware configurations, but for optimal performance of Nethogs, consider the following minimum specifications:

  • 1 GHz processor (dual-core recommended)
  • 1 GB RAM (2 GB recommended)
  • 10 GB available disk space
  • Active network interface

Required Permissions:

Installing and running Nethogs requires elevated privileges. You’ll need:

  • Root access or sudo privileges for installation
  • Root/sudo access for running Nethogs (as it needs to capture network packets)

System Update and Package Requirements:

Before installation, ensure your Fedora 42 system is up-to-date:

sudo dnf clean all
sudo dnf update

This update process refreshes your package repositories and upgrades existing packages, providing the most stable environment for installing Nethogs.

Checking System Compatibility:

Verify that your system has the necessary networking components by running:

ip link show

This command displays all available network interfaces, which you’ll need to know when running Nethogs.

Network Connectivity:

Ensure you have an active internet connection for downloading packages during installation. You can verify connectivity with:

ping -c 3 fedoraproject.org

With these prerequisites in place, you’re ready to proceed with installing Nethogs on your Fedora 42 system using either the package manager or by compiling from source code.

Method 1: Installing Nethogs Using DNF Package Manager

The DNF (Dandified YUM) package manager provides the simplest and most reliable method to install Nethogs on Fedora 42. This approach handles all dependencies automatically and ensures you receive a version that’s been tested and optimized for your specific Fedora release.

Preparing the System Environment:

Before installing Nethogs, it’s advisable to ensure your DNF cache is up-to-date:

sudo dnf makecache

This command updates the package metadata, ensuring you’ll get the latest available version of Nethogs.

Installation Command and Process:

To install Nethogs using DNF, execute the following command:

sudo dnf install nethogs

When prompted, confirm the installation by entering ‘Y’. DNF will automatically:

  1. Resolve all required dependencies
  2. Download the necessary packages
  3. Install Nethogs and its components
  4. Set up appropriate file permissions

Expected Output and Confirmation:

During installation, you’ll see output similar to:

Dependencies resolved.
================================================================================
 Package          Arch        Version              Repository              Size
================================================================================
Installing:
 nethogs          x86_64      0.8.8-2.fc42         fedora                 XXkB
Installing dependencies:
 libpcap          x86_64      1.10.X-X.fc42        fedora                 XXkB

Transaction Summary
================================================================================
Install  2 Packages

Total download size: XXkB
Installed size: XXkB
Is this ok [y/N]:

Verifying the Installation:

After installation completes, verify that Nethogs was installed correctly by checking its version:

nethogs -V

This should display output confirming the version number (0.8.8-2.fc42 for Fedora 42).

Package Details and Configuration:

The Fedora 42 package of Nethogs includes:

  • The main executable file (typically installed to /usr/bin/nethogs)
  • Man pages for documentation
  • Any necessary support files

No additional configuration is typically required after installation. The DNF-installed version comes pre-configured with sensible defaults suitable for most use cases.

This installation method is recommended for most users due to its simplicity and reliability. The package maintained in the Fedora repositories receives regular security updates and bug fixes, ensuring a stable and secure experience.

Method 2: Building Nethogs from Source

While the DNF package manager provides a convenient installation method, building Nethogs from source code offers several advantages for advanced users. This approach allows you to access the latest features, customize the build process, and potentially optimize performance for your specific system configuration.

When to Choose Source Installation:

Consider building from source in these scenarios:

  • When you need the absolute latest version with recent bugfixes
  • If you want to modify the source code for customized functionality
  • When you require specific optimization flags for your hardware
  • If you prefer to have greater control over the installation process

Installing Required Development Packages:

Before compiling Nethogs, you’ll need to install several development tools and libraries:

sudo dnf groupinstall "Development Tools" -y
sudo dnf install ncurses-devel libpcap-devel -y

These packages provide the necessary compilation tools, header files, and libraries required to build Nethogs from source.

Downloading and Extracting the Source Code:

Obtain the latest Nethogs source code from the official GitHub repository:

git clone https://github.com/raboof/nethogs
cd nethogs

Alternatively, if you prefer to download a specific release version:

wget https://github.com/raboof/nethogs/archive/refs/tags/v0.8.8.tar.gz
tar -xzf v0.8.8.tar.gz
cd nethogs-0.8.8

Compilation Process:

Compile the source code using the make utility:

make

This process may take a few minutes depending on your system’s performance. The output will show the compilation progress and any warnings (which are typically safe to ignore unless errors are reported).

Installation Steps:

After successful compilation, install Nethogs to your system:

sudo make install

By default, this installs Nethogs to /usr/local/sbin/nethogs. If you want to specify a different installation path, you can modify the Makefile or use the PREFIX variable:

sudo make install PREFIX=/your/preferred/path

Verifying the Source-Built Installation:

Confirm the installation was successful by checking the version:

nethogs -V

The output should display the version number corresponding to the source code you compiled.

Path Configuration:

Ensure that the installation directory is in your system PATH. If you installed to the default location (/usr/local/sbin/), it should already be accessible. If you used a custom path, add it to your PATH variable:

echo 'export PATH=$PATH:/your/preferred/path/bin' >> ~/.bashrc
source ~/.bashrc

Building from source provides greater flexibility and control, though it requires more technical knowledge than the package manager approach. The resulting installation will function identically to the package version but may include newer features or customizations based on the source code used.

Basic Usage of Nethogs

Once Nethogs is successfully installed on your Fedora 42 system, you can begin monitoring network traffic at the process level. This section covers the essential operations to get you started with this powerful utility.

Starting Nethogs for the First Time:

To launch Nethogs with default settings, simply run the command with root privileges:

sudo nethogs

This command will start Nethogs monitoring all active network interfaces. You’ll immediately see a display showing processes that are currently using the network, ordered by bandwidth consumption.

Install Nethogs on Fedora 42

Understanding the Command Syntax:

The basic syntax for Nethogs is:

nethogs [options] [device(s)]

Where:

  • [options] are optional parameters that modify Nethogs behavior
  • [device(s)] specifies which network interface(s) to monitor (e.g., eth0, wlan0)

Specifying Network Interfaces:

To monitor specific network interfaces rather than all interfaces, specify them after the command:

sudo nethogs eth0

You can monitor multiple interfaces simultaneously:

sudo nethogs eth0 wlan0

This is particularly useful on systems with multiple network connections.

Understanding the Nethogs Display:

The Nethogs interface displays:

  1. PID: The process ID of each program
  2. USER: The user who owns the process
  3. PROGRAM: The program name and sometimes command arguments
  4. DEV: The network device being used
  5. SENT: Data sent by the process (KB/s)
  6. RECEIVED: Data received by the process (KB/s)
  7. Total SENT/RECEIVED: Cumulative bandwidth usage at the bottom

The display updates periodically, showing real-time network activity.

Practical Examples:

Monitor traffic while streaming video:

sudo nethogs

Observe which processes handle the streaming data.

Monitor specific interface with a custom refresh rate:

sudo nethogs -d 5 wlan0

This refreshes the display every 5 seconds and monitors only the wireless interface.

Interactive Controls:

While Nethogs is running, you can use these keyboard commands:

  • m: Change the sort mode (sort by received, sent, or total traffic)
  • r: Sort in reverse order
  • q: Quit the program
  • s: Start/stop display updates
  • +/-: Increase/decrease the refresh rate

These interactive features make Nethogs a dynamic tool for real-time monitoring and troubleshooting network issues on your Fedora 42 system.

Advanced Nethogs Configuration

Beyond basic usage, Nethogs offers several advanced configuration options that allow for more specialized monitoring and detailed analysis of network traffic. Mastering these options will help you get the most out of this powerful utility on your Fedora 42 system.

Command-line Options and Parameters:

Nethogs supports various command-line parameters that modify its behavior:

sudo nethogs -d 3 -v 2 eth0

The most commonly used options include:

  • -d [seconds]: Set the refresh rate (delay between updates)
  • -v [level]: Set verbosity level (0-2, with 2 being most verbose)
  • -t: Enable tracemode (continuously print process bandwidth usage)
  • -p: Enable promiscuous mode (capture packets not specifically addressed to monitored interfaces)
  • -a: Monitor all interfaces, including loopback
  • -c [count]: Process count updates and then quit
  • -s: Sort by sent traffic (default is received)

Customizing Refresh Rate:

The update frequency can significantly impact how you monitor traffic:

sudo nethogs -d 0.5

This sets a very fast refresh rate of 0.5 seconds, useful for capturing brief network bursts.

sudo nethogs -d 10

A slower 10-second refresh rate reduces CPU usage for long-term monitoring.

Promiscuous Mode Settings:

When troubleshooting complex network issues, promiscuous mode allows capturing all packets visible to the network interface:

sudo nethogs -p eth0

Note that this mode:

  • Requires additional system resources
  • May require special permissions on some networks
  • Is generally not recommended for routine monitoring

Using Trace Mode for Detailed Analysis:

Trace mode continuously outputs process bandwidth usage to stdout, which can be redirected to a file for later analysis:

sudo nethogs -t > network_log.txt

This creates a log file recording all network activity by process, valuable for:

  • Long-term traffic analysis
  • Identifying patterns in network usage
  • Creating custom reports or visualizations

Filtering and Focusing:

While Nethogs doesn’t have built-in filtering options, you can combine it with other tools:

sudo nethogs eth0 | grep firefox

For more complex filtering, consider piping the output through awk or sed.

Custom Device Monitoring:

Monitor virtual interfaces or specific devices:

sudo nethogs tun0

This is particularly useful when:

  • Using VPNs (monitor tun0/tap0 interfaces)
  • Working with container networking
  • Analyzing traffic on specific network segments

These advanced configuration options transform Nethogs from a simple monitoring tool into a powerful diagnostic utility capable of providing detailed insights into network usage patterns across your Fedora 42 system.

Integrating Nethogs into Your System Administration Workflow

To maximize the utility of Nethogs on your Fedora 42 system, consider integrating it into your regular system administration workflow. This section explores practical ways to incorporate Nethogs into your daily operations, making network monitoring more efficient and effective.

Creating Aliases for Faster Access:

Save time by creating custom aliases in your shell configuration:

echo "alias nh='sudo nethogs'" >> ~/.bashrc
echo "alias nhwifi='sudo nethogs wlan0'" >> ~/.bashrc
echo "alias nheth='sudo nethogs eth0'" >> ~/.bashrc
source ~/.bashrc

These aliases allow you to quickly launch Nethogs with common configurations using simple commands like nh or nhwifi.

Setting Up Shell Scripts for Automated Monitoring:

Create a basic monitoring script that logs bandwidth-intensive processes:

#!/bin/bash
# File: netmon.sh
# Description: Logs top bandwidth users periodically

LOG_FILE="/var/log/nethogs_$(date +%Y%m%d).log"
INTERVAL=300  # 5 minutes

while true; do
    echo "=== $(date) ===" >> $LOG_FILE
    sudo nethogs -t -c 1 | grep -v "0.0000" >> $LOG_FILE
    sleep $INTERVAL
done

Make the script executable and run it in the background or as a service:

chmod +x netmon.sh
./netmon.sh &

Integrating with Other Monitoring Tools:

Combine Nethogs with other utilities for comprehensive system monitoring:

  • Use nethogs alongside iftop for both process and protocol-level insights
  • Incorporate into monitoring dashboards with tools like Grafana
  • Combine with system monitoring tools like Glances or htop

Example combined monitoring script:

#!/bin/bash
# Display system resources and network usage
echo "==== SYSTEM RESOURCES ===="
free -h
echo
echo "==== DISK USAGE ===="
df -h
echo
echo "==== NETWORK USAGE BY PROCESS ===="
sudo nethogs -t -c 1
echo
echo "==== NETWORK USAGE BY INTERFACE ===="
ifstat -T 1 1

Regular Usage Recommendations:

Develop a routine monitoring schedule:

  • Run Nethogs during system boot to catch startup network activity
  • Schedule periodic checks during peak usage hours
  • Use Nethogs before and after installing new software
  • Monitor during suspected network issues or slowdowns

Logging and Data Collection:

Implement structured logging for trend analysis:

#!/bin/bash
# Collect network usage data hourly
LOGDIR="/var/log/nethogs_data"
mkdir -p $LOGDIR

while true; do
    TIMESTAMP=$(date +%Y%m%d_%H%M)
    sudo nethogs -t -c 3 > $LOGDIR/nethogs_$TIMESTAMP.log
    sleep 3600
done

This creates timestamped logs that can be analyzed later to identify patterns or anomalies in network usage.

By incorporating Nethogs into your regular system administration practices, you’ll develop a deeper understanding of your system’s network behavior and be better equipped to identify and resolve issues quickly on your Fedora 42 system.

Troubleshooting Common Nethogs Issues

Even with straightforward installation and usage, you may encounter certain issues when working with Nethogs on Fedora 42. This section addresses common problems and provides practical solutions to keep your network monitoring running smoothly.

Permission-Related Problems:

One of the most common issues is insufficient permissions:

Error: You need to be root to run nethogs

Solution:

  • Run with sudo: sudo nethogs
  • If using a script, ensure it’s executed with appropriate privileges
  • For regular users, consider setting up sudo rules specifically for nethogs:
# Add to /etc/sudoers.d/nethogs (via visudo)
username ALL=(ALL) NOPASSWD: /usr/sbin/nethogs, /usr/bin/nethogs

Interface Detection Issues:

You might encounter errors related to network interfaces:

Error opening one or more devices

Solutions:

  • Verify the interface exists: ip link show
  • Check interface status: ip link show eth0
  • Ensure the interface is up: sudo ip link set eth0 up
  • Try using the device path: sudo nethogs /dev/eth0
  • For wireless interfaces, ensure they’re active: iwconfig

Display and Formatting Problems:

Terminal size or display issues can affect usability:

Error: terminal too small

Solutions:

  • Resize your terminal window to be larger
  • Switch to a different terminal emulator
  • Use trace mode instead: sudo nethogs -t
  • For SSH sessions, ensure your terminal settings are correctly configured

Performance Considerations:

On high-traffic networks, you might experience:

  • High CPU usage
  • Delayed updates
  • Incomplete process information

Solutions:

  • Increase the refresh interval: sudo nethogs -d 5
  • Monitor specific interfaces instead of all interfaces
  • Limit monitoring to specific protocols or ports using tcpdump in conjunction with Nethogs
  • Consider using a more lightweight monitoring tool for continuous monitoring

Dependency Conflicts:

If you installed from source, you might face dependency issues:

error while loading shared libraries: libncurses.so.5: cannot open shared object file

Solutions:

  • Install missing dependencies: sudo dnf install ncurses-libs libpcap
  • For source installations, ensure development packages are installed: sudo dnf install ncurses-devel libpcap-devel
  • Check library paths: ldconfig -p | grep libpcap
  • Reinstall using the package manager if persistent issues occur

Specific Fedora 42 Issues:

For issues specific to Fedora 42:

  • Ensure SELinux is not blocking Nethogs: sudo ausearch -m avc -ts recent | grep nethogs
  • Check firewall settings: sudo firewall-cmd --list-all
  • Update to the latest version if bugs are encountered: sudo dnf update nethogs

By addressing these common issues, you can ensure that Nethogs functions reliably on your Fedora 42 system, providing valuable insights into process-specific network usage without interruption.

Congratulations! You have successfully installed Nethogs. Thanks for using this tutorial for installing the Nethogs on your Fedora 42 Linux system. For additional help or useful information, we recommend you check the official Ionic Nethogs website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button