• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

Memory (RAM) usage monitoring on Linux

How VPS by How VPS
January 1, 2020
in Linux
0
0
SHARES
11
VIEWS
Share on FacebookShare on Twitter

Contents

  1. 1. vmstat command
  2. 2. top command
  3. 3. free command
  4. 4. htop command
  5. Conclusion
  6. Want to contribute?


Monitoring RAM resources of your VPS is very important. Especially, if you use caching systems such as Redis or Memcached. If your server runs out of memory, or runs short on memory, your website or service can stop or may run slow.

Luckily, Linux gives you a few handy tools that you would need to monitor memory usage. These tools can be easily used from the command line. This short (and sweet) article will give you an idea how to use those commands, and you can pick the one that fits your needs the most.

1. vmstat command

Type in vmstat to your command line and the program will display how much free memory is available.

root@localhost:/# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 3  0      0 185332  43880 150176    0    0     2     6    8    7  0  0 100  0  0

If you need more details, run vmstat with the -s or --stats parameter. Check the first line of the output to see how much free memory is available on your server.

root@209:/# vmstat -s
759872  K total memory
575220  K used memory
356148  K active memory
86168   K inactive memory
184652  K free memory
44048   K buffer memory
149248  K swap cache
0       K total swap
0       K used swap
0       K free swap
806545  non-nice user cpu ticks
1       nice user cpu ticks
533833  system cpu ticks
424692262 idle cpu ticks
54982   IO-wait cpu ticks
244344  IRQ cpu ticks
0       softirq cpu ticks
0       stolen cpu ticks
7190421 pages paged in
27240788 pages paged out
0       pages swapped in
0       pages swapped out
335817481 interrupts
285597986 CPU context switches
1425579890 boot time
332134  forks

2. top command

This is a widely known command to check both memory and CPU usage.

top - 03:20:50 up 49 days,  8:55,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  87 total,   1 running,  86 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.3 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:    759872 total,   576156 used,   183716 free,    44628 buffers
KiB Swap:        0 total,        0 used,        0 free.   149652 cached Mem

PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
1 root      20   0   36284   5312   1192 S  0.0  0.7   0:42.98 init
2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd
3 root      20   0       0      0      0 S  0.0  0.0   0:05.13 ksoftirqd/0
5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H

3. free command

This is my favorite, and probably the most simple command to view memory stats.

root@209:/# free -m
              total       used       free     shared    buffers     cached
Mem:           742        562        179         27         43        146
-/+ buffers/cache:        372        369
Swap:            0          0          0

The example above shows you how much total memory your VPS has (in Megabytes), how much memory is used, and how much memory is free.

4. htop command

This command is similar to the top command, but in my opinion, it gives you a better idea about the memory state of your server.

Conclusion

The commands listed above can be used to manually monitor memory usage. You can also write a simple script using your preferred programming language to run these commands and alert you (by email, for example) if your memory resources are low.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How to Install Gitea on Fedora 29

Next Post

Install MediaWiki on the One-Click LEMP Application

Next Post

Install MediaWiki on the One-Click LEMP Application

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet