Operations 26 min read

Master Linux Memory Monitoring: 6 Essential Commands Explained

This guide walks Linux administrators through six practical commands—free, vmstat, /proc/meminfo, top, htop, and per‑process memory checks—detailing their syntax, useful options, example outputs, and how to interpret key metrics for effective memory troubleshooting and performance tuning.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Memory Monitoring: 6 Essential Commands Explained

Why Monitoring Memory Matters

System memory is a critical resource; regularly checking its usage helps detect abnormal consumption, prevent service outages, and ensure stable operation of applications and servers.

1. free Command

The free utility displays total, used, free, shared, buffer/cache, and available memory. Common options include -b, -k, -m, -g for units, -o to hide the buffer column, -s<seconds> for continuous monitoring, -t to show totals, and -V for version.

free -t               # show totals
free -h -s 10        # update every 10 seconds
free -h -c 10        # output 10 times (requires -s)
free -V               # version

Key fields:

Mem : overall memory usage line.

Swap : swap usage line.

Total : physical memory available to the OS.

Used : memory allocated (interpretation differs between kernel versions).

Free : memory not yet allocated.

Shared : shared memory.

Buff/Cache : memory used for buffers and cache.

Available : memory that can be allocated without swapping (newer kernels).

2. vmstat Command

vmstat

reports virtual memory statistics, including processes, memory, paging, block I/O, traps, and CPU activity. It is part of the sysstat package.

vmstat -s               # display memory statistics
vmstat 2 1             # sample every 2 seconds, 1 time

Typical columns:

procs : r (running/ready), b (blocked).

memory : swpd, free, buff, cache.

swap : si (swap‑in), so (swap‑out).

io : bi (blocks in), bo (blocks out).

system : in (interrupts), cs (context switches).

cpu : us (user), sy (system), id (idle), wa (IO wait).

Common troubleshooting clues:

High r with low id → CPU overload.

Non‑zero pi/po → memory pressure.

High disk and queue >3 → IO bottleneck.

3. /proc/meminfo

Reading /proc/meminfo provides raw memory statistics directly from the kernel. Example: cat /proc/meminfo Important fields include MemTotal, MemFree, MemAvailable, Buffers, Cached, SwapTotal, SwapFree, Active, Inactive, and many others that give a detailed view of memory allocation, cache, swap usage, and kernel structures.

Values are in kB (kilobytes). Use less /proc/meminfo to scroll.

4. top Command

top

shows real‑time CPU and memory usage per process, along with system‑wide summaries. Basic syntax: top [-] [d delay] [q] [c] [S] [s] [i] [n] [b] Key options: d: change refresh delay. q: fastest refresh (requires root). c: toggle full command line. S: cumulative mode. i: hide idle processes. n: number of updates before exit. b: batch mode (useful for logging).

Typical output sections:

System time and load average.

Task summary (total, running, sleeping, stopped, zombie).

CPU usage percentages (us, sy, ni, id, wa, hi, si, st).

Memory summary (total, free, used, buff/cache).

Swap summary.

Per‑process table (PID, USER, PR, NI, VIRT, RES, SHR, S, %CPU, %MEM, TIME+, COMMAND).

5. htop Command

htop

is an interactive, color‑enhanced alternative to top that allows vertical and horizontal scrolling, process tree view, and easy management (kill, renice) via function keys.

# htop          # launch interactive view
# top -c        # show full command line in top

Useful shortcuts:

F1 / h / ? – help.

F2 – settings.

F3 – search.

F4 – filter.

F5 – tree view.

F6 – sort column.

F7 / [ – decrease nice.

F8 / ] – increase nice.

F9 / k – kill selected process.

F10 / q – quit.

6. Inspecting a Specific Process’s Memory

Read /proc/<pid>/status to see detailed memory usage for a given process. cat /proc/4398/status Key fields include Name, State, VmSize, VmRSS, Threads, and various capability and context‑switch counters.

Conclusion

Understanding and using these Linux tools—free, vmstat, /proc/meminfo, top, htop, and per‑process status—gives administrators the ability to quickly diagnose memory‑related issues, identify CPU or IO bottlenecks, and keep systems running smoothly.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxtopMemory MonitoringFreehtopprocvmstat
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.