How to Monitor Linux Network Bandwidth using vnStat

Monitoring network bandwidth is an essential task for any Linux system administrator. While tools like top show CPU and RAM usage, they don’t tell you how much data your server is pushing over the network. For a lightweight, persistent way to track bandwidth usage over time, vnStat is one of the best command-line utilities available for Ubuntu.

What is vnStat?

Unlike other network monitoring tools that actively sniff traffic and consume CPU resources, vnStat simply reads network statistics provided by the Linux kernel. This makes it incredibly lightweight and perfect for running in the background on low-resource servers.

How to Install and Use vnStat

  1. Open your terminal or connect to your server via SSH.
  2. Update your package list and install vnStat by running:
    sudo apt update && sudo apt install vnstat
  3. Once installed, the vnStat service will start automatically in the background and begin collecting data.
  4. To view your network statistics, simply type:
    vnstat

Advanced vnStat Commands

By default, vnStat provides a quick summary. You can use flags to view more specific data:

  • Live traffic: Use vnstat -l to see a live, real-time view of your bandwidth usage.
  • Hourly breakdown: Use vnstat -h to see traffic statistics for the past 24 hours.
  • Daily breakdown: Use vnstat -d for day-by-day statistics.

Because vnStat stores its data in a database, your network history will survive system reboots, making it an invaluable tool for tracking monthly server bandwidth quotas.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.