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 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 df Command: Check Filesystem Free Space

Linux df Command: Check Filesystem Free Space

Learn how to check Filesystem Free Space with the Linux df command, including practical examples, key options, and important precautions.

Linux type Command: Identify How a Command Is Resolved

Linux type Command: Identify How a Command Is Resolved

Learn how to use the Linux type command to identify aliases, functions, built-ins, keywords, and executable paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux sync Command: Flush Buffered Writes to Storage

Linux sync Command: Flush Buffered Writes to Storage

Learn how to flush Buffered Writes to Storage with the Linux sync command, including practical examples, key options, and important precautions.

Linux basename Command: Extract the Final Component of a Path

Linux basename Command: Extract the Final Component of a Path

Learn how to use the Linux basename command to remove directory prefixes and optional suffixes from path strings, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux gzip Command: Compress a File in gzip Format

Linux gzip Command: Compress a File in gzip Format

Learn how to compress a File in gzip Format with the Linux gzip command, including practical examples, key options, and important precautions.

Linux renice Command: Change the Priority of a Running Process

Linux renice Command: Change the Priority of a Running Process

Learn how to change the Priority of a Running Process with the Linux renice command, including practical examples, key options, and important precautions.

Linux unzip Command: List and Extract ZIP Archives

Linux unzip Command: List and Extract ZIP Archives

Learn how to list and Extract ZIP Archives with the Linux unzip command, including practical examples, key options, and important precautions.

Linux history Command: Review and Reuse Shell Command History

Linux history Command: Review and Reuse Shell Command History

Learn how to use the Linux history command to review, search, reuse, and manage shell command history, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux help Command: Read Help for Bash Built-in Commands

Linux help Command: Read Help for Bash Built-in Commands

Learn how to use the Linux help command to read usage information for Bash built-in commands, with essential options, practical examples, output interpretation, and common troubleshooting tips.