How to monitor network connections in Linux with pktstat

If you're wondering what processes are using your bandwidth on Linux, a small utility called pktstat can help.

If you're wondering what processes are using your bandwidth on Linux, a small utility called pktstat can help. This command-line tool displays package activity in real time, with several convenient options for common functions.

What is pktstat?

pktstat is a utility that displays the behavior of packets to and from your computer, similar to how top or htop displays information about processes. It's a full-screen program that runs in the terminal.

How to install pktstat

Installing pktstat is easy as it is available in the package manager for most major Linux distributions.

For example, to install pktstat on Debian or Ubuntu, use the following command:

sudo apt install pktstat

And on Arch, use the command:

sudo pacman -S pktstat

And for the Red Hat family, use the command:

sudo dnf install pktstat

Monitor network connections with pktstat

Picture 1 of How to monitor network connections in Linux with pktstat

To see any open network connections with pktstat, you can simply call it from the command line. Because network connectivity affects system security, you usually need to run it as root:

sudo pktstat

This will display full screen. It will display all open network connections on your machine. You'll see the source and destination of any packets moving between your local machine and the remote computer.

As with many other Linux programs, pktstat's real power comes from its various options. The -i option allows you to specify the interface you want to monitor. For example, you might want to monitor connections on a wired Ethernet interface rather than WiFi:

sudo pktstat -i [interface]

By default, pktstat will display shortened hostnames. To see the full hostname, use the -F option .

The -n option will completely strip the hostname, showing only the IP address. You can also press n to switch numeric mode while pktstat is running.

The -c option will separate traffic streams that pktstat would normally combine into one, such as multiple TCP connections.

You can change the sort order by pressing t for 'top mode' to sort by number of bits as well as by using the -t option .

pktstat is a useful console-based tool for monitoring incoming and outgoing network connections on your Linux system in real time. It's like top or htop for your network.

Update 08 November 2023
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile