Linux Mint

Linux vmstat Command Tutorial for Beginners

Linux vmstat Command Tutorial for Beginners
As a system administrator, or even as a normal computer user, you may want to keep a keen eye on all the activities and operations taking place in your computer system. Obviously, you cannot break your hardware to see what is happening; rather, you will need a software utility to do so.

The vmstat command in Linux is used for this exact purpose. Vstat is an acronym that stands for Virtual Memory Statistics Reporter and performs this very operation on your system. This article provides a beginner's guide on the vmstat command in Linux Mint 20.

Accessing the Help Manual of vmstat

To use the vmstat command in Linux Mint 20, we will first access the vmstat help manual by running the following command

$ vmstat --help

The vmstat command help manual is shown in the following image:

Checking System Statistics with vmstat

You can use the vmstat command to see system statistics regarding CPU, memory, processes, and more. To obtain statistics about your system, use the vmstat command in the following manner:

$ vmstat

The standard output of the vmstat command is shown in the image below:

This is the basic usage of the vmstat command. This command can also be used to serve more specific purposes, as explained in the following sections.

Checking Active and Inactive Memory with vmstat

You can check the active and inactive memory of your system by running the regular vmstat command paired with the “-a” flag, as follows:

$ vmstat -a

The active and inactive memory of our Linux Mint 20 system is shown in the image below:

Checking Total Number of Forks Since Boot with vmstat

Forking is a term used in operating systems to refer to the procedure in which a parent process creates a child process or processes, depending upon the current number of tasks that are to be performed. You can easily check the total number of forks, i.e., the total number of spawned processes since your system last booted, by running the vmstat command paired with the “-f” flag, as follows:

$ vmstat -f

The total number of forks since our system last booted is shown in the image below:

Checking Event Counter Statistics with vmstat

The event counter is a measure that indicates the frequency of occurrence of a specific event. The event counter statistics of activities taking place in your system can be visualized using the vmstat command paired with the “-s” flag, as follows:

$ vmstat -s

The event counter statistics of our system are shown in the image below:

Checking Disk Statistics with vmstat

The disk of a computer system contains various aspects that can be studied in depth with the vmstat command, such as the number of input and output operations, the number of read and write operations, information about the disk sectors, and more. Specific information about the system disk can be retrieved by running the vmstat command paired with the “-d” flag, as follows:

$ vmstat -d

The disk statistics of our Linux Mint 20 system are shown in the image below:

Showing Timestamps with vmstat

You can also display timestamps with the vmstat command to determine the time of day that a particular system statistics report was generated. To show timestamps with the output of the vmstat command in Linux Mint 20, run this command paired with the “-t” flag, as follows:

$ vmstat -t

As you can see in the output of the vmstat command shown in the image below, the timestamp is now appearing with this output.

Refreshing vmstat Output after Specified Interval

Computer systems never stay static; rather, they are in a dynamic state. In other words, computer systems are always performing certain tasks, either in the background or in the foreground, unless the computer system is turned off. Due to this continuous activity, system statistics tend to change at any given moment. This change range from drastic to negligible, depending upon the operation that is taking place.

So, instead of seeing the static vmstat command output, you might want to see its output every few seconds, or perhaps another specified time interval. To refresh the vmstat output after a specified time interval, use the vmstat command with the “-t” flag, as follows:

$ vmstat -t n

Here, replace “n” with any positive integer, which represents the number of seconds after which the vmstat output will refresh. For example, to see the latest vmstat output every two seconds, we will replace “n” with “2.” We have used the “-t” flag just to be sure that the vmstat output is refreshing after the specified time interval.

As you can see from the timestamps in the output of the vmstat command shown below, the command is refreshing every two seconds.

When you want the vmstat command to stop reporting these statistics, simply press the Ctrl+ C key combination to regain control of your terminal.

Conclusion

This tutorial on the usage of the vmstat command can prove to be extremely helpful for users who have just started working in the Linux environment in general and the Linux Mint 20 environment in particular. After going through the examples explained in this article, you should have a good idea about the function and usage of the vmstat command in Linux Mint 20.

WinMouse lets you customize & improve mouse pointer movement on Windows PC
If you want to improve the default functions of your mouse pointer use freeware WinMouse. It adds more features to help you get the most out of your h...
Mouse left-click button not working on Windows 10
If you are using a dedicated mouse with your laptop, or desktop computer but the mouse left-click button is not working on Windows 10/8/7 for some rea...
Cursor jumps or moves randomly while typing in Windows 10
If you find that your mouse cursor jumps or moves on its own, automatically, randomly while typing in Windows laptop or computer, then some of these s...