Loading...

Lab 38: Monitoring System with top

Monitor a high-load Linux system with top to identify resource pressure and the heaviest processes in real time. Sort by memory inside the UI, exit cleanly, then confirm where to find help and usage options.

troubleshooting core services

Scenario

The system is reporting high load and users are complaining about slowness. You need a real-time view of CPU, memory, and the processes contributing to the load. Your task is to use top to inspect system health, sort processes by memory usage, exit cleanly, and confirm how to access documentation for the tool.

Operator context

top is often the first live telemetry you grab during an incident. It helps you answer “is this CPU-bound, memory-bound, or just too many runnable tasks” before you take corrective action.

Objective

  • Launch top to view live system utilization.
  • Interpret the header sections (load, CPU, memory, swap).
  • Sort processes by memory usage inside top .
  • Exit the viewer cleanly.
  • Display help and documentation for top .

Concepts

  • Load average as a signal of runnable queue pressure versus CPU saturation.
  • Task states (running, sleeping, stopped, zombie) and what they imply operationally.
  • CPU breakdown (user, system, iowait) to distinguish compute load from storage waits.
  • Memory versus cache behavior and when swap activity becomes an incident indicator.
  • Interactive sorting inside top for rapid triage (memory-heavy versus CPU-heavy processes).

Walkthrough

Step 1 : Launch the real-time process viewer.
Command
top

top provides a live view of system utilization and the processes consuming resources. The header gives fast health signals like load average, task states, CPU breakdown, and memory pressure.

top - 10:15:01 up  1:23,  2 users,  load average: 0.25, 0.30, 0.28
Tasks: 150 total,   1 running, 149 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3.2 us,  1.5 sy,  0.0 ni, 94.8 id,  0.4 wa,  0.0 hi,  0.1 si,  0.0 st
MiB Mem :   7820.9 total,   2988.2 free,   1075.4 used,   3757.3 buff/cache
MiB Swap:   2048.0 total,   2048.0 free,      0.0 used.   6366.4 avail Mem

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
2387 alice     20   0 2412340  74200  40200 S   5.3  0.9   0:12.34 code
2194 alice     20   0 1911224  98200  53000 S   3.1  1.2   2:01.12 firefox
2381 dev       20   0 1120332  40320  14000 S   2.4  0.5   0:45.67 python3
1324 root      20   0  169084  13872   8732 S   0.3  0.2   0:04.12 systemd
1502 root      20   0  315600   8420   6020 S   0.1  0.1   0:00.98 sshd
1650 dev       20   0  987456  25400  12000 S   0.1  0.3   0:03.01 bash
Step 2 : Sort processes by memory usage inside top.
Key
M

While top is running, pressing M sorts the process list by memory usage. Use this when the system feels slow due to RAM pressure or aggressive cache churn.

# Expected result:
# Process list reorders with highest %MEM / RES usage at the top.
Step 3 : Exit the top viewer.
Key
q

Press q to quit top cleanly and return to your shell.

# Expected result:
# top exits and you return to your prompt.
Step 4 : Confirm help and documentation for top.
Commands
top --help
# OR
man top

Use top --help for a quick options summary or man top for the full manual. This is where you confirm keybinds, sort behavior, and flags you may want in runbooks.

# Expected result:
# Help output prints or the manual page opens successfully.

Common breakpoints

Load is high but %Cpu id remains high

This often means the system is not CPU-bound. Check %Cpu wa for iowait and review the task count. High load can also come from many runnable or uninterruptible tasks even when the CPU is mostly idle.

Swap is growing and the system becomes unresponsive

Sustained swap usage can indicate memory pressure. Sort by memory with M and identify the largest resident sets. Expect latency and “stalls” when the box is paging heavily.

top does not accept keypresses

Ensure the terminal window is focused. If you are inside a nested session (for example SSH inside tmux), confirm you are sending input to the correct pane/session.

Process list moves too fast to read

You are likely dealing with bursty CPU usage or many short lived processes. Use sorting ( M ) to stabilize the view around the top consumers, then capture follow-up evidence with the manual for supported non-interactive flags if needed.

Cleanup checklist

This lab is read-only. Cleanup is confirming you exited top and captured the signals you needed (load, CPU breakdown, memory/swap, and the top resource consumers).

Commands
top
# Inside top:
# M
# q
Success signal

You can explain whether the box is CPU-bound, memory-bound, or waiting on I/O, and you can name the top processes driving the pressure.

Reference

  • top : Interactive real-time system monitor showing load, CPU, memory, and per-process usage.
    • M (inside top) : Sorts the process list by memory usage.
    • q (inside top) : Quits top and returns to the shell.
  • top --help : Displays a quick summary of command-line options.
    • --help : Prints built-in usage text (options summary) and exits.
  • man top : Opens the manual page for top.
    • man : Manual page viewer.
    • top : The manual page topic to open.