If you are managing a Linux server and the system suddenly slows to a crawl, or a website goes offline because the database is unresponsive, you must identify what is consuming the server’s resources. In Windows, you would press Ctrl+Alt+Delete to open the graphical Task Manager. In the Linux terminal, you use the top command. top is a dynamic, real-time performance monitoring tool. It takes over your terminal screen and displays a constantly updating dashboard of every active process, sorting them by how much CPU or RAM they are currently devouring.
Launching the Monitor
Starting the tool is incredibly simple.
- Open your Linux terminal.
- Type the word
top. - Press Enter.
Your command prompt will disappear, replaced by a dense, two-part dashboard that updates automatically every 3 seconds.
Reading the Dashboard: The Header
The top five lines of the screen provide a macro-level view of the entire server’s health.
- Line 1 (Uptime & Load): Shows how long the server has been running, and the “load average” (a metric of system stress over the last 1, 5, and 15 minutes).
- Line 2 (Tasks): Shows the total number of processes. Most are usually ‘sleeping’ in the background, while only a few are actively ‘running’.
- Line 3 (%Cpu): The most critical line. Look for the number next to id (idle). If ‘id’ is at 99.0, your processor is doing nothing. If ‘id’ is at 0.0, your processor is completely maxed out and the server is choking.
- Lines 4 & 5 (Mem & Swap): Shows your total RAM, how much is used, and how much is free.
Reading the Dashboard: The Process List
Below the header is the dynamic list of individual applications (processes).
- PID (Process ID): The unique number assigned to that application. You need this number if you want to force-quit the program.
- USER: The account running the program (e.g., ‘root’ or ‘apache’).
- %CPU: How much of the processor that specific app is using right now. (By default,
topsorts the list so the highest CPU hog is at the very top). - %MEM: How much RAM the app is consuming.
- COMMAND: The actual name of the program (e.g., ‘mysql’ or ‘python3’).
Controlling ‘top’ While It Runs
Because top is an interactive environment, you can press specific keys on your keyboard to change how data is displayed without stopping the program.
- Sort by Memory (RAM): Press Shift + M. The list will instantly reorder, putting the program using the most RAM at the top.
- Sort by CPU: Press Shift + P to return to the default CPU sorting.
- Highlight running tasks: Press z (lowercase) to add color to the dashboard, making active processes easier to spot.
The Most Important Command: Exiting
When you have identified the problematic process, you need your command prompt back so you can actually fix it.
- Press the q (lowercase) key. The dashboard will instantly vanish, returning you to your standard terminal session.