Nethogs is a command-line utility that allows you to monitor network traffic on a Linux system. It displays the real-time network usage of each process in a terminal window, making it easy to identify which processes are consuming the most bandwidth.
Overview
To use nethogs, simply run the command followed by the name of the network interface you wish to monitor. For example, to monitor traffic on the eth0 interface, use the following command:
nethogs eth0
Nethogs will then display a list of processes currently using the network, along with the amount of data they are sending and receiving. The list is sorted by the amount of data being sent, so you can quickly identify which processes are using the most bandwidth.
By default, nethogs displays the process name and its PID (Process ID). You can also display the user owning the process and the command line used to start it by using the -v
(verbose) option:
nethogs -v eth0
Nethogs also supports filtering by process name or PID. To filter by process name, use the -p
option followed by the name of the process:
nethogs -p firefox eth0
To filter by PID, use the -pid
option followed by the PID:
nethogs -pid 1234 eth0
Options
The following table lists the available options for nethogs:
Option | Description |
---|---|
-d | Delay in seconds between updates (default is 1) |
-h | Display help message |
-m | Display data rates in MB/s instead of KB/s |
-p | Filter by process name |
-b | Bypass DNS resolution |
-pid | Filter by process ID |
-s | Sort by sent data (default) |
-r | Sort by received data |
-v | Verbose mode (display user and command line) |
-c | Do not display colors |
Troubleshooting Tips
- If nethogs is not displaying any data, make sure you are running it as root or with sudo privileges.
- If you are monitoring a wireless interface, make sure it is connected to a network and has an IP address assigned to it.
- If you are still having issues, try specifying the network interface by its full name, such as
eth0
instead of justeth
.
Notes
- Nethogs can be a useful tool for identifying processes that are consuming excessive amounts of bandwidth, which can be helpful for troubleshooting network issues or optimizing system performance.
- Keep in mind that nethogs only displays data for processes that are currently using the network. If a process is not actively sending or receiving data, it will not appear in the list.
- Nethogs is not installed by default on most Linux distributions and may need to be installed using your distribution’s package manager.