vnstat Command Examples in Linux

vnstat is a console-based network traffic monitor that is used to monitor network traffic usage on Linux systems. vnstat tracks network traffic usage for a specified network interface, and provides real-time and historical traffic statistics, such as total data usage, average usage rate, peak usage, and more.

vnstat works by monitoring network traffic at the kernel level, using a small daemon process that runs in the background. The daemon process records all network traffic that passes through the specified network interface, and vnstat reads and displays this information in a console-based user interface.

vnstat provides a number of options and settings that can be used to configure the network interface to monitor, the update interval for statistics, the data storage location, and more. The statistics generated by vnstat can be viewed in various formats, such as hourly, daily, monthly, and yearly, and can be exported to various formats, such as PNG, CSV, and SQL.

vnstat is typically used for monitoring network traffic usage on servers and other headless systems where a graphical interface is not available or desirable. It can also be useful for tracking bandwidth usage on limited or metered connections, such as mobile data plans.

vnstat Command Examples

1. Display traffic summary for all interfaces:

# vnstat

2. Display traffic summary for a specific network interface:

# vnstat -i eth0

3. Display live stats for a specific network interface:

# vnstat -l -i eth0

4. Show traffic statistics on an hourly basis for the last 24 hours using a bar graph:

# vnstat -hg

5. Measure and show average traffic for 30 seconds:

# vnstat -tr 30

Summary

vnstat is included in many Linux distributions and can be installed using package managers such as apt, yum, or pacman. The vnstat command is also available on other platforms, such as macOS and Windows, through third-party packages.

Overall, vnstat is a powerful and lightweight tool for monitoring network traffic usage on Linux systems, and can be a valuable tool for network administration, troubleshooting, and optimization.

Related Post