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

Looking for a Good OOP Book to Kickstart My Learning

Hey everyone! I've been on a journey to learn distributed systems, but I quickly discovered it has a bunch of prerequisites. I thought I...

Best Dictation Apps for Writing a Book

My dad is working on writing a book, but he's having a tough time typing it out. We've got him a dictaphone and a...

Has the 4o Model’s Performance Dropped Recently?

I've been wondering if anyone else has noticed a drop in the 4o model's intelligence over the past few weeks. I can't tell if...

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

Online Hash Generator – String to Hash Converter

Need to quickly generate a hash from a string? Whether you're verifying file integrity, securing data, or just experimenting with cryptographic tools, this simple...

Convert CSV To HTML Table

Need to quickly turn CSV data into an HTML table? Whether you're copying data from Excel, Google Sheets, or another spreadsheet, this tool makes...

Student Group Randomizer

Creating fair and balanced groups in the classroom can be time-consuming — especially when you're trying to avoid repetition, manage different skill levels, or...

Random Group Generator

Need to split a list of people, items, or ideas into random groups? Our free Random Group Generator makes it quick and easy. Whether...

Flip Text Upside Down – Free Online Tool

Ever wanted to flip your text upside down just for fun or to grab someone’s attention in a creative way? This free online Upside...

Raffle Ticket Generator

If you're running a fundraiser, charity draw, or local event and need raffle tickets fast, this free online tool lets you generate and print...

Latest Posts

Latest Questions