[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedAugust 1, 2023

How to use vnstat command in Linux.

How To Use Vnstat Command.

vnStat is a network utility for the Linux operating system. It is a console-based network traffic monitor that keeps a log of hourly, daily, and monthly network traffic for the selected interface(s).

Nexonhost Dedicated Servers , Virtual Servers

Installing vnstat on Linux

For RedHat based Linux  use:

yum install vnstat

For ubuntu or debian Linux use: 

apt install vnstat 

To get basic stats of all network interfaces.

vnstat

This command will print all the basic stats of the network interfaces connected to the system.

To monitor a specific interface.

vnstat -i wlo1

This will monitor and display the stats of the specified interface that is wlo1. 

To get the daily stats of an interface.

vnstat -d -i wlo1

This will print the daily stats of the specified interface which is wlo1. 

To get the hourly stats of an interface.

vnstat -h -i wlo1

This will print the hourly stats of the specified interface which is wlo1. 

To display the monthly stats of a interface.

vnstat -m -i wlo1

This command will display the monthly stats of the specified interface. 

To save output to a XML file 

vnstat --xml -i wlo1 >output.xml

The command will create an XML file with name output.xml and will have the output of the command in XML format. 

To save output to a JSON file 

vnstat --json -i wlo1 >output.json

This command will create a JSON file with name output.json and will have the output of the command in JSON format. 

To save output to a text file.

vnstat --oneline -i wlo1 >output.txt

This command will create a text file with name output.txt and will have the output in a one-line format. 

To calculate traffic on the current interface.

vnstat -tr

This command will display the traffic on the current network interface in use. 

To display vnstat help.

vnstat --help

This command will display the vnstat help section.

  1. Check the traffic on the Ethernet interface (e.g., eth0):

vnstat -i eth0

This command will display statistics about network traffic for the “eth0” interface, including total traffic (rx and tx), daily traffic, current month, and previous months.

  1. Display the total traffic for the current month on all interfaces:

vnstat -m

This command will display the total traffic for the current month for each available network interface on the system.

  1. Display the total traffic for a specific period (e.g., last 7 days):

vnstat -d -i eth0 --days 7

This command will display the total traffic on the “eth0” interface for the last 7 days.

  1. Display the total traffic for the current year on a specific interface:

vnstat -y -i wlan0

This command will display the total traffic on the “wlan0” interface for the current year.

  1. Display the monthly traffic on a specific interface in a human-readable format:

vnstat -m -i eth0 --style 0

This command will display the monthly traffic on the “eth0” interface in a human-readable format, making it easier to read.

These are just a few examples of VnStat commands, and the utility has many other options and arguments that you can explore by consulting its manual page with the command:

man vnstat

Please note that to get the most accurate and up-to-date statistics, VnStat needs to be set up to run in the background and update the data periodically. Also, make sure you have superuser privileges (sudo) to run certain commands, especially those that request information about all network interfaces available on the system.

Keep reading
How to Check if a File or Directory Exists in Bash.
May 30, 2023

How to Check if a File or Directory Exists in Bash.

How To Check If A File Or Directory Exists In Bash. Many times when writing Shell scripts, you may find yourself in a situation where you need to perform an action based on whether a file exists or not. In Bash, you can use the test command to check whether a file exists and determine…

Read article
How to install RPM on ubuntu.
May 29, 2023

How to install RPM on ubuntu.

How To Install RPM On Ubuntu. The Ubuntu repositories contain thousands of deb packages which can be installed from the Ubuntu Software Center or by using the apt command-line utility. Deb is the installation package format used by all Debian based distributions, including Ubuntu. Some packages…

Read article
How to Delete/Remove Users.
May 29, 2023

How to Delete/Remove Users.

How To Delete/Remove Users. This tutorial covers the userdel command and its options. Linux is a multi-user system, which means that more than one person can interact with the same system at the same time. As a system administrator, you have the responsibility to manage the system’s users and…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00