RAM (random access memory) is used by your computer to handle active apps and tasks. If you don't have enough RAM, your computer will slow down. We'll show you how to test your RAM for both Linux.
To check memory usage, Linux provides a variety of commands. When working on servers, the only option is to use shell access. All operations must be performed using these commands. Let's look at some Linux commands for monitoring memory usage.
Free command
On Linux, the free command is the simplest and most direct way to check memory usage
$ free -m
total used free shared buff/cache available
Mem: 969 388 109 49 471 394
Swap: 1022 87 935
/proc/meminfo
It's worth noting that the free command is simply a quick way to examine data that's already on the screen. Look at the /proc/meminfo pseudo-file if you want to get right to the source:
$ cat /proc/meminfo
cat /proc/meminfo
MemTotal: 993052 kB
MemFree: 110372 kB
MemAvailable: 401572 kB
Buffers: 74016 kB
Cached: 380492 kB
SwapCached: 14140 kB
Active: 290580 kB
Inactive: 480264 kB
Active(anon): 47348 kB
Inactive(anon): 319040 kB
Active(file): 243232 kB
Inactive(file): 161224 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 1047548 kB
SwapFree: 958176 kB
Dirty: 12 kB
Writeback: 0 kB
AnonPages: 302408 kB
Mapped: 110660 kB
Shmem: 51028 kB
KReclaimable: 28604 kB
Slab: 57504 kB
SReclaimable: 28604 kB
SUnreclaim: 28900 kB
KernelStack: 8716 kB
PageTables: 15244 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1544072 kB
Committed_AS: 5560032 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
Percpu: 640 kB
HardwareCorrupted: 0 kB
AnonHugePages: 184320 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 130928 kB
DirectMap2M: 917504 kB
Vmstat
Virtual memory statistics are reported by the vmstat command, which is a valuable tool. Processes, memory, paging, block IO, traps, and CPU activity are all displayed by vmstat.
$ vmstat
vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 89372 111272 74160 410008 0 0 1 13 65 66 1 1 99 0 0
Top command
The top command is frequently used to inspect per-process memory and CPU consumption. It does, however, display total memory consumption and can be used to monitor total RAM usage. The output header contains all the necessary information.
$ top
Keep an eye on the MEM% column:
htop command
The application htop is a process viewer that allows you to interact with it. It functions similarly to top, but it also allows you to scroll the list vertically and horizontally to examine all processes and their complete command lines. On most Linux distributions, the htop command isn't installed by default.
Comments
Article is closed for comments.