vnStat Demystified: Understanding and Optimizing Linux Network Performance

vnStat is a tool used on Linux and BSD-based systems to monitor and report network traffic statistics. This tool collects, stores, and provides users with various statistics related to network traffic. Some key features of vnStat include:

  1. Daily, Weekly, Monthly Reports: vnStat collects and reports network traffic statistics on a daily, weekly, and monthly basis.
  2. Total Consumption Information: Displays the total amount of data sent and received.
  3. Visualization of Changes Over Time: Presents graphical representations of changes in network traffic over time.
  4. Lightweight and Efficient: vnStat is a lightweight tool that operates with low system resources and can run continuously in the background.
  5. Compatibility with Various Interfaces: Supports various interfaces, including a Command Line Interface (CLI) and web-based interfaces.

Installing vnStat:

Here are some basic commands to install vnStat:

Debian/Ubuntu-Based Distributions (Using apt Package Management):

sudo apt update
sudo apt install vnstat

Red Hat/Fedora/CentOS-Based Distributions (Using yum or dnf Package Management):

sudo yum install vnstat

or

sudo dnf install vnstat

openSUSE-Based Distributions (Using zypper Package Management):

sudo zypper install vnstat

Once vnStat is installed, you can use various commands to view network traffic statistics. For example:

  • To view the daily report: vnstat -d
  • To view the weekly report: vnstat -w
  • To view the monthly report: vnstat -m

These commands allow you to view network traffic statistics for specific time intervals.

vnStat Cheat Sheet:

  1. Show Daily Statistics:
    vnstat -d
    • Displays daily network statistics.
  2. Show Weekly Statistics:
    vnstat -w
    • Displays weekly network statistics.
  3. Show Monthly Statistics:
    vnstat -m
    • Displays monthly network statistics.
  4. Show Total Summary:
    vnstat -t
    • Displays a total summary of network statistics.
  5. Live Monitoring:
    vnstat -l
    • Initiates live monitoring, continuously updating network statistics.
  6. Display Hours Distribution:
    vnstat -h
    • Shows the distribution of network usage over hours.
  7. Reset Statistics:
    vnstat -r
    • Resets the network statistics.
  8. Set Rate Unit:
    vnstat -u
    • Changes the rate unit (bits, bytes, kbit, etc.).
  9. Export Database:
    vnstat -e
    • Exports the database to a file.
  10. Clear Database:
    vnstat --clear
    • Clears all collected data.
  11. Help and Options:
    vnstat --help
    • Displays the help menu with available options.

These commands provide a quick reference for interacting with vnStat and exploring various network statistics. Feel free to customize the commands based on your specific needs.

You May Also Like
Proxmox commands cheat sheet terminal output
Read More

Proxmox Commands – cheat sheet

Managing Proxmox Virtual Environment (PVE) through the command line can significantly speed up administration tasks, especially when working…