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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v1.png" data-lazy- height="27" src="data:image/svg xml,” width=”376″>

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v2.png" data-lazy- height="395" src="data:image/svg xml,” width=”509″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v3.png" data-lazy- height="28" src="data:image/svg xml,” width=”319″>

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v4.png" data-lazy- height="115" src="data:image/svg xml,” width=”646″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v5.png" data-lazy- height="23" src="data:image/svg xml,” width=”344″>

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v6.png" data-lazy- height="115" src="data:image/svg xml,” width=”645″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v7.png" data-lazy- height="26" src="data:image/svg xml,” width=”345″>

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v8.png" data-lazy- height="57" src="data:image/svg xml,” width=”360″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v9.png" data-lazy- height="24" src="data:image/svg xml,” width=”344″>

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v10.png" data-lazy- height="411" src="data:image/svg xml,” width=”359″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v11.png" data-lazy- height="23" src="data:image/svg xml,” width=”343″>

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v12.png" data-lazy- height="246" src="data:image/svg xml,” width=”644″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v13.png" data-lazy- height="27" src="data:image/svg xml,” width=”347″>

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v14.png" data-lazy- height="141" src="data:image/svg xml,” width=”647″>

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:

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.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v15.png" data-lazy- height="25" src="data:image/svg xml,” width=”365″>

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/v16.png" data-lazy- height="197" src="data:image/svg xml,” width=”645″>

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.

About the author

<img alt="Aqsa Yasin" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/Author-Image-150×150.jpg5ff5f8ff6da3c.jpg" height="112" src="data:image/svg xml,” width=”112″>

Aqsa Yasin

I am a self-motivated information technology professional with a passion for writing. I am a technical writer and love to write for all Linux flavors and Windows.