Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
wc command in Linux with examples
Next article icon

vmstat command in Linux with Examples

Last Updated : 16 Dec, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

vmstat command in Linux/Unix is a performance monitoring command of the system as it gives the information about processes, memory, paging, block IO, disk, and CPU scheduling. All these functionalities makes the command vmstat also known as virtual memory statistic reporter. 

The very first report produced gives the average details since the last reboot. After that, additional reports are produced which provides report over a sampling period of time. All these process and reports are instantaneous in either case. 

Syntax: 

vmstat [options][delay [count]]

Delay: It is the time interval in between two updates. It can be termed as a sampling period after each interval of the sampling period report that will be printed with the updated details. If there will be no delay specified only one report will be printed with average value since boot. 

Count: It is the number of updates which is printed after each interval(sampling period). In absence of count and delay is specified, the default value of count is infinite. 

Note: Important fields are ‘free’ under memory and ‘si’, ‘so’ under the swap column. 

  • Free: It specifies the amount of free memory/idle memory spaces which are not being used.
  • si: Memory that is swapped in every second from disk in kilobytes.
  • so: Memory that is swapped out every second to disk in kilobytes.
  • In the given figure we can see the process, memory, swap in memory, swap out memory, io, system, and cpu update. 

Options:  

  • -a Active: It displays active and inactive memory of the system running. 
    Syntax: 
$vmstat -a

Example: The given figure shows how to use the command. The best part of it is we can see how much memory is actively used and how much is inactive. 

  • Forks: It displays the number of forks since boot. Each process is represented by one or more task, depending on thread usage. This display doesn’t repeat. 
    Syntax: 
$vmstat -f

Example: The given figure illustrates the number of forks. There is the 1832 fork process. 

  • Slabs: This command is used to display slab information. 
    Syntax: 
$vmstat -m

Example: The given figure shows that the kernel is not supporting slab info. It depends on your kernel which you are using. 

  • State: This command is used to display a table of various event counters and memory statistics. This display doesn’t repeat. 
    Syntax: 
$vmstat -s

Example: The figure given below shows the table of various event counters. 

  • Disk Statistics: This command is used to display all disk statistics. 
    Syntax: 
$vmstat -d

Example: The figure shows all disk statistics. 

  • Time stamp: Vmstat command with -t option shows timestamp with every updation. 
    Syntax: 
$vmstat -t delay count

Example: Along with the process there lies time of each update. By default memory status is shown in kilobytes, but when we want to see it in other forms we need a different command. 

  • With parameter -S M : Displays memory status in Megabytes. 
    Syntax: 
$vmstat -S M delay count

Example: The memory is shown in MB here in the given figure. 

  • -n One header: It is used to display header only once rather than periodically. 
    Syntax: 
$vmstat -n

Example: The figure illustrates the use. 

  • To get more information about vmstat and its versions, a manual page exist which can be seen in the terminal only. This is one of the best parts of the terminal that it itself provides the manual on how to use the command and what are its aspects. 
    Syntax: 
$ man vmstat

 


Next Article
wc command in Linux with examples

B

Bhumika_Rani
Improve
Article Tags :
  • Linux-Unix
  • Technical Scripter
  • Technical Scripter 2018

Similar Reads

  • uniq Command in Linux with Examples
    The uniq command in Linux is a command-line utility that reports or filters out the repeated lines in a file. In simple words, uniq is the tool that helps to detect the adjacent duplicate lines and also deletes the duplicate lines. uniq filters out the adjacent matching lines from the input file(tha
    7 min read
  • until command in Linux with Examples
    until command in Linux is used to execute a set of commands as long as the final command in the 'until' Commands has an exit status that is not zero. It is mostly used where the user needs to execute a set of commands until a condition is true. Syntaxuntil COMMANDS; do COMMANDS; donewhere, CONDITION
    2 min read
  • Linux | Uptime command with examples
    It is used to find out how long the system is active (running). This command returns set of values that involve, the current time, and the amount of time system is in running state, number of users currently logged into, and the load time for the past 1, 5 and 15 minutes respectively. Linux uptime S
    5 min read
  • How to add User in Linux | useradd Command
    useradd is a command in Linux that is used to add user accounts to your system. It is just a symbolic link to adduser command in Linux and the difference between both of them is that useradd is a native binary compiled with the system whereas adduser is a Perl script that uses useradd binary in the
    5 min read
  • usermod command in Linux with Examples
    usermod command or modify user is a command in Linux that is used to change the properties of a user in Linux through the command line. After creating a user we have to sometimes change their attributes like password or login directory etc. so in order to do that we use the Usermod command. The info
    4 min read
  • username Command in Linux With Examples
    Linux as an operating system holds the capabilities of handling multiple users each with a username and a display name (Full Name). So it is important to keep a check on the users and their related information in order to maintain the integrity and security of the system. Whenever a user is added it
    4 min read
  • users command in Linux with Examples
    users command in Linux system is used to show the user names of users currently logged in to the current host. It will display who is currently logged in according to FILE. If the FILE is not specified, use "/var/run/utmp". "/var/log/wtmp" as FILE is common.  Syntaxusers [OPTION]... [FILE]where, OPT
    2 min read
  • How to Delete User in Linux | userdel Command
    Managing user accounts is an essential aspect of Linux system administration. Understanding how to delete a user in Linux is crucial, whether you need to remove an unused account, revoke access for a departing employee, or clean up your system for security reasons. Here, we will explore the 'userdel
    6 min read
  • vi Editor in Linux
    The default editor that comes with the Linux/UNIX operating system is called vi (visual editor). Using vi editor, we can edit an existing file or create a new file from scratch. we can also use this editor to just read a text file. The advanced version of the vi editor is the vim editor.  Table of C
    9 min read
  • vmstat command in Linux with Examples
    vmstat command in Linux/Unix is a performance monitoring command of the system as it gives the information about processes, memory, paging, block IO, disk, and CPU scheduling. All these functionalities makes the command vmstat also known as virtual memory statistic reporter. The very first report pr
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences