In Linux, you can use various tools and commands to monitor network activity. Here are some commonly used methods:
- iftop:
iftopis a real-time console-based network bandwidth monitoring tool. It shows a list of network connections and their corresponding bandwidth usage.
sudo iftop - nload:
nloadprovides a visual representation of incoming and outgoing traffic separately. It also displays a graph for easy interpretation.
sudo nload - iftop:
- Similar to iftop,
iptrafprovides a variety of statistics about IP traffic on a network. It includes information about the size of each packet, its source and destination, and more.
sudo iptraf - Similar to iftop,
- netstat:
- The
netstatcommand displays various network-related information, including active connections, listening ports, and routing tables.
netstat -a - The
- ss:
- Similar to
netstat, thesscommand provides socket statistics, displaying information about active connections and listening ports.
ss -a - Similar to
- tcpdump:
tcpdumpis a packet analyzer that allows you to capture and display network packets. It’s a powerful tool for detailed network traffic analysis.
sudo tcpdump -i <interface> - Wireshark:
- Wireshark is a graphical packet capture and analysis tool. It provides an in-depth analysis of network traffic and is useful for troubleshooting and security analysis.
sudo wireshark - sar:
- The
sarcommand (System Activity Reporter) provides various system-related statistics, including network-related metrics. Install it if not already available.
sudo apt-get install sysstat sar -n DEV 1 - The
- ss:
- The
sscommand can also be used for more advanced filtering and display options to show detailed information about network sockets.
ss -t - The
- iftop:
- Customize
iftopwith filters to focus on specific network connections or protocols.
sudo iftop -f <filter_expression> - Customize
Choose the tool that best suits your needs based on the level of detail and real-time monitoring you require. Combine these tools to get a comprehensive view of your Linux system’s network activity.