3 Ways To Check RAM Usage Via Linux Command Line

Here are 3 simple ways to check your systems current RAM usage, when working via command line.

The free command has multiple options. Free on its own will provide you the ram usage in bytes. This is probably useless to most so adding -m after it will give you the value in megabytes.

free -m

The output should be something like this

total used free shared buffers cached

             total       used       free     shared    buffers     cached
Mem:          4096        712       3383        131          0        307
-/+ buffers/cache:        405       3690
Swap:          128          0        128

An alternative is to use top. This will give you the specific applications that are using the memory along with CPU usage. The best thing about this command is it’s in real time. The data is very much like that displayed in task manager for Windows.

top

This should output something like this

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   1 root      20   0 19364  436  132 S  0.0  0.0   0:01.11 init
   2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd/69576
   3 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper/69576
   4 root      20   0     0    0    0 S  0.0  0.0   0:00.00 rpciod/69576/0
   5 root      20   0     0    0    0 S  0.0  0.0   0:00.00 rpciod/69576/1
   6 root      20   0     0    0    0 S  0.0  0.0   0:00.00 rpciod/69576/2
   7 root      20   0     0    0    0 S  0.0  0.0   0:00.00 rpciod/69576/3
   8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 nfsiod/69576
 127 root      16  -4 10652  280    0 S  0.0  0.0   0:00.01 udevd
 499 root      20   0  179m 2256  324 S  0.0  0.1   0:10.23 rsyslogd
 545 named     20   0  307m  26m 1720 S  0.0  0.7   1:24.78 named
 563 root      20   0  4580  148   60 S  0.0  0.0   0:00.06 mdadm
 572 dbus      20   0 21436  236    4 S  0.0  0.0   0:00.00 dbus-daemon
 610 root      20   0 66220  900  192 S  0.0  0.0   0:07.61 sshd
 621 root      20   0 52112  628   88 S  0.0  0.0   0:00.28 vsftpd
 657 root      20   0  105m  304    4 S  0.0  0.0   0:00.05 mysqld_safe
 864 mysql     20   0 1727m 170m 3940 S  0.0  4.2  49:40.23 mysqld

vmstat is another simple way to check RAM usage. This isn’t quite as useful if you want to quicky check. It will display most of what the free command displays along with a few extra details.

vmstat -s

Output

4194304 total memory
728952 used memory
296176 active memory
383972 inactive memory
3465352 free memory
0 buffer memory
314504 swap cache
131072 total swap
0 used swap
131072 free swap
887837 non-nice user cpu ticks
1429 nice user cpu ticks
199846 system cpu ticks
182661931 idle cpu ticks
134832 IO-wait cpu ticks
0 IRQ cpu ticks
0 softirq cpu ticks
0 stolen cpu ticks
13589860 pages paged in
5739148 pages paged out
0 pages swapped in
0 pages swapped out
0 interrupts
46730701 CPU context switches
1423896862 boot time
105029 forks

While on the subject of RAM the following commands will give you the technical information about the RAM that is installed on the system you are working on. dmidecode will get you the max capacity, number of devices and some other basic information.

dmidecode -t 16
dmidecode -t 17

Related Articles

Related Questions

Can a federal felony affect my job prospects as a software engineer?

I'm wondering if having a federal felony for lying to a federal agent about a firearm will make it difficult for me to get...

I’m New to Game Development – Where Should I Begin?

Hi everyone! I'm a student who has never created anything more complex than a simple drawing, but I'm eager to dive into game development....

Should I Choose the RTX 5070 or the Sapphire Pulse 9070XT for My New Build?

I'm putting together a new PC that I want to last for a good while, and I'm stuck deciding between two graphics cards. I...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

OpenAI Token Calculator

This tool is a simple OpenAI token calculator, web-based utility designed to help you quickly estimate the number of tokens in your text when...

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

Latest Posts

Latest Questions