[email protected]Office hours: Mon – Fri 9:00AM – 5:00PMLinkedInXFacebook
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 Implement Network Segmentation and Resource Isolation in Linux.
February 6, 2024

How to Implement Network Segmentation and Resource Isolation in Linux.

How to Implement Network Segmentation and Resource Isolation in Linux. Securing and managing networks in a Linux environment involves advanced practices like network segmentation and resource isolation. This guide explores these concepts, providing detailed instructions and examples for…

Read article
How to open or close ports in Linux.
February 6, 2024

How to open or close ports in Linux.

How to open or close ports in Linux. Effectively managing ports on your Linux system is crucial for both security and service accessibility. This comprehensive guide will provide a detailed walkthrough on opening and closing ports using the robust tools iptables and ufw. Understanding these…

Read article
How to use ypdomainname command.
January 23, 2024

How to use ypdomainname command.

How to use ypdomainname command. In the realm of Linux networking, the ypdomainname command plays a crucial role in the context of the Network Information Service (NIS). NIS, formerly known as Yellow Pages, is a distributed database service that facilitates the sharing of network configuration 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, colocation, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Office hours: Mon – Fri 9:00AM – 5:00PM