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. 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
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.
You should read it
- Top 10 examples of Netstat commands on Linux
- How to Set Up and Use SSH in Linux
- How to fix an empty Network Connections interface
- How to use ss command on Linux
- Network testing with Network Monitor 3.4 - Part 1
- How to use the Netstat command in Windows 11 to monitor network activity
- Data analysis with Network Monitor
- How to monitor, clean and optimize Linux with Stacer
May be interested
- Does the download process continue when Windows is in sleep mode?have you ever wondered if windows 11 or windows 10 continues downloading files when your pc goes to sleep?
- Top 13 best Python compilerspython is an interpreted programming language and has many different execution environments. there are many different compilers for executing python programs.
- How to create collaborative playlists in Apple Musiccollaborative playlists in apple music let you add, remove, or rearrange songs with people who have access to your albums. with this feature, playlists in apple music are more interesting when you enjoy different music styles.
- 5 disadvantages when switching to Raspberry Pi 5while the raspberry pi 5 is undisputedly the current champion of this popular family of single-board computers, performance benchmarks don't tell the whole story and the raspberry pi foundation's latest sbc has some drawbacks. need to consider before upgrading.
- 12 best file compression tools on Linuxthere are many powerful compression tools for linux that make backing up system data easier.
- Are humans or machines better at detecting deepfakes?humans' ability to identify fake content is critical to neutralizing misinformation, but as ai technology improves, who can we trust to detect deepfakes: humans or machines?