Linux top Command: Monitor Processes in Real Time

top is an interactive tool that repeatedly updates CPU and memory usage as well as process status. You can see in real-time which tasks are using resources when the server slows down.

What is the top command?

At the top, there is a summary of system load, CPU, and memory, and below that, the figures for each process are displayed. It is important to look at patterns that persist over several updates rather than a single high value. To exit, press q within the screen.

Basic syntax

top [option]

Installed implementations and options may vary depending on the distribution. Check the description for your current system with man top.

Examples

Viewing the real-time list

Exit by pressing q during execution, and you can change the sorting based on CPU or memory with P and M.

top

Observing a specific PID

Focus on the resource changes of a process you have already found.

top -p 1234

Print only once

When an interactive screen is not needed, record only one iteration in batch mode.

top -b -n 1

Values to view first on the real-time screen

When you run top, the top shows the load average and a summary of CPU and memory, while the bottom periodically updates each process's PID, CPU usage, and memory usage. In batch mode, you can receive a single screen as text.

top -b -n 1 | head -n 8

Structure of the example screen (numbers vary depending on the system):

top - ... load average: ...
Tasks: ... total, ... running
%Cpu(s): ... us, ... sy, ... id
MiB Mem : ... total, ... free, ... used
    PID USER      %CPU %MEM COMMAND

Do not determine a problem solely based on %CPU; consider the duration and the role of the process as well. On the interactive screen, you can sort by CPU with P, sort by memory with M, and exit with q. The display units and columns may vary depending on the implementation and settings.

Main Options and Format

Options/Format Description
-p PID Observe only the specified PID.
-d seconds Set the screen refresh interval.
-b Use batch output mode.
-n count Refresh the specified number of times.

Precautions when using

The initially displayed CPU usage and cumulative time are affected by the observation point and calculation method. If a single process uses multiple cores, the display may exceed 100%. The exit command inside top affects the actual process, so check the target PID before using it.

Frequently Asked Questions

How do I exit from top?

Press q in the interactive screen. This is an operation inside top, not a shell command entered in the terminal.

Official Documentation

You can check the exact behavior of the options and differences depending on implementation in the official documentation for top.

More in This Category
Linux nohup Command: Keep a Command Running After Logout

Linux nohup Command: Keep a Command Running After Logout

Learn how to use the Linux nohup command to keep a command running after the terminal closes or the user logs out, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux Tutorial / File Permissions and Safe sudo Use

Linux Tutorial / File Permissions and Safe sudo Use

Learn to read file and directory permissions, practice chmod safely, and understand when to use sudo and how to diagnose access errors.

Linux nice Command: Set a New Process's Scheduling Priority

Linux nice Command: Set a New Process's Scheduling Priority

Learn how to set a New Process's Scheduling Priority with the Linux nice command, including practical examples, key options, and important precautions.

Linux sort Command: Sort Text Lines

Linux sort Command: Sort Text Lines

Learn how to sort text lines with the Linux sort command, including practical examples, key options, and important precautions.

Linux whereis Command: Locate Binaries, Source, and Man Pages

Linux whereis Command: Locate Binaries, Source, and Man Pages

Learn how Linux whereis locates binaries, source files, and manual pages, limits each search type, lists effective paths, and differs from which and find.

Linux lsblk Command: Inspect Disks, Partitions, and Mounts

Linux lsblk Command: Inspect Disks, Partitions, and Mounts

Learn how to inspect Disks, Partitions, and Mounts with the Linux lsblk command, including practical examples, key options, and important precautions.

Linux nmap Command: Scan Authorized Hosts and Ports

Linux nmap Command: Scan Authorized Hosts and Ports

Learn how to scan Authorized Hosts and Ports with the Linux nmap command, including practical examples, key options, and important precautions.

Linux join Command: Combine Files by a Common Field

Linux join Command: Combine Files by a Common Field

Learn how to combine Files by a Common Field with the Linux join command, including practical examples, key options, and important precautions.

Linux ssh Command: Connect to a Remote Host Securely

Linux ssh Command: Connect to a Remote Host Securely

Learn how to connect to a Remote Host Securely with the Linux ssh command, including practical examples, key options, and important precautions.

Linux split Command: Divide Large Files into Smaller Parts

Linux split Command: Divide Large Files into Smaller Parts

Learn how to divide Large Files into Smaller Parts with the Linux split command, including practical examples, key options, and important precautions.