--- title: top โ€” Real-time process status date: 2026-10-18 time: 12:00 model: admin category: programs author_type: human summary: A basic tool that shows the top processes by CPU and memory usage in real time. The starting point for identifying the cause of load. tags: program, Service and process management, top --- **๐Ÿ’ฌ "top command"** top shows **system load and processes in real time**. This is the first screen to check when something seems wrong. You can see load average, CPU usage, memory, and top processes at a glance. - **load average**: Average load over 1/5/15 minutes. Compare it with the number of CPU cores to interpret it. - **%Cpu(s)**: The share of user/system/iowait. If iowait is high, it's a disk bottleneck. - **MiB Mem**: Total/used/free memory. If free is close to 0, it's dangerous. - **Process list**: Top CPU or memory processes are displayed. ## Frequently used options | Option | Description | | --- | --- | | -H | Display by thread | | -u | View only a specific user's processes | | -b -n 1 | Output only once (for scripts/collection) | | -o %MEM | Sort by memory | ## Three essential command combinations - `top -b -n 1 | head -15` โ€” Capture current state once - `top -o %CPU -b -n 1 | head -20` โ€” Check top CPU-consuming processes - `top -u www-data -b -n 1 | head` โ€” View only web server account processes **๐Ÿ’ฌ "Tell me how to use it together with monitoring"** Here are common situations on production servers, organized in order. ### Step 1 ยท Check overall load Check load average and CPU/memory status. ``` top -b -n 1 | head -5 ``` ### Step 2 ยท Identify the culprit process Check the top CPU/memory processes. ``` top -o %CPU -b -n 1 | head -12 ``` ### Step 3 ยท Further inspection Look at the details of that process. ``` ps -o pid,ppid,%cpu,%mem,etime,cmd -p ``` ## How it's used in practice ### 1. Slow server response **Situation** โ€” Web response suddenly became slow. ``` top -b -n 1 | head -5 ``` **Result** โ€” If load average is significantly higher than the number of cores or iowait is high, you can narrow down the cause. **Point** โ€” Even if load is high, if the CPU is idle it may be I/O wait, so check %Cpu(s) as well. ### 2. Running low on memory **Situation** โ€” You're worried about OOM. ``` top -o %MEM -b -n 1 | head -12 ``` **Result** โ€” Find processes using a lot of memory and consider limiting or restarting them. **Point** โ€” Check with free -h and also verify whether swap is being used. ## Things to watch out for - Since top refreshes in real time, use -b -n 1 to print only once in scripts. - Load average should be interpreted relative to core count (for example, on 8 cores, 8 means saturation). - Because it is a momentary snapshot, it can miss short spikes, so repeated collection may be necessary. ## Actual execution screen This is the result of checking load average and CPU/memory status. ![top command execution result: system load and processes](https://games.aidebatehub.com/assets/top-demo.png) Production server --- Source (HTML): https://games.aidebatehub.com/programs/linux/services/top.html This file is an auto-generated Markdown twin of the DevHub document.