The 'top'
Command in Linux is a dynamic, real-time utility that provides a detailed overview of system performance. It displays critical information such as CPU usage, memory utilization, process activity, system load averages, and more, making it an essential tool for monitoring and managing system resources efficiently.
The syntax of the command 'top'
demonstrates how it can be used to monitor system activity directly from the Linux terminal.
top [options]Example :
Run top
without any options to display a live view of all processes running on the system:
Syntax:
top
The top
command launches in interactive mode, displaying active processes along with real-time system information. You can customize the view using various keyboard shortcuts. Pressq
to exit the interface.
Here,
Options in the top
command modify its behavior and output. They control which processes are displayed, how frequently the data is refreshed, and which system resources are emphasized. You can specify these options when launching top
in the terminal or use interactive hotkeys within the top
interface to adjust the view in real time.
The table below lists the most commonly used top
command options and their functions:
q
press q key in the keyboard for exit from the monitoring the process.
-v
This option is used to check the version.
-P
The option -p is used for monitoring the process by the Process ID (PID) -M
This option is used to display memory usage. -b
This option known as batch mode. This is used to send output from top to file or any other programs. -k
k is a key shortcut used inside the top command to kill a process by their Process ID (PID) -r
It is used to change process priority (renice) -1
It is used to show CPU usage per core -h
This option is used to display help information Hoe to Intrepret top Command Output
The top
command output is divided into several sections, each with specific information about system performance and processes. This section provides a breakdown of the output based on the information it shows.
When you first open the top
command, the initial line, often referred to as the header or summary line, displays information similar to what you see when you use the uptime
command. It shows:
This section provides an overview of the total number of processes currently managed by the system.
The %Cpu(s)
line in the top
command provides information about CPU usage and statistics on a Linux system. It typically includes:
The "MiB Memory" line in the top
command provides information about memory usage and statistics on a Linux system. It typically includes:
The "MiB Swap" line in the top
command provides information about swap usage and statistics on a Linux system. It typically includes:
Below are the most common top command options.
Option 1. 'q'q is the keyword used to exit from the process interface.
Syntax:
top press q
Example:
topOption 2. '-v'
The -v option in top command is used to check the version.
Syntax:
top -v or top --version
Example:
top -vOption 3. '-p'
The -p command is used to monitoring the process by their Process ID.
Syntax:
top -p <PID>
Example:
top -p 7760Option 4. '-M'
The -M
option in the top
command is used to set the memory display unit
Syntax:
top -M [k|m|g]
Example:
top -M k
Displays memory usage in kilobytes
Note: The -M
option is available in some versions of top
, particularly in older or alternative implementations (like on BSD or in older procps
versions)
Alternate Example:
sudo apt install htop htopOption 5. '-b'
This option is used to send output from top
to a file or another program in batch mode.
Syntax:
top -b [options]
Example:
top -b -n 1Option 6. '-k'
The k
key in interactive mode of the top
command is used to kill (terminate) a running process directly from within the top
interface.
Syntax:
top press k PID to kill :
Example:
top PID to Kill = 1869Option 7. '-r'
r key is used inside the interactive top
interface to change the priority (nice value) of a running process.
Syntax:
top PID to renice : renice value:
Example:
top PID to renice : 9290 Renice PID 9290 to value 4002Option 8. '-1'
The command top -1
is used in the Linux top
command to show CPU usage per core.
Syntax:
top -1
Example:
top -1Option 9. '-h'
The h option is used in system to display help information about the top
command's options and usage.
Syntax:
top -h
Example:
top -hOther Useful Command Options using in top command
1) Exit Top Command After Specific repetition:
Top output keep refreshing until you press ‘q‘. With below command top command will automatically exit after 10 number of repetition.
top -n 10
2) Display Specific User Process
top -u paras
3) Highlight Running Process in Top: Press ‘z‘ option in running top command will display running process in color which may help you to identified running process easily.
4) Shows Absolute Path of Processes: Press ‘c‘ option in running top command, it will display absolute path of running pro.
5) Sort by CPU Utilisation: Press (Shift+P) to sort processes as per CPU utilization.
6) Secure Mode: Use top in Secure mode.
top -s
7) Command Line: The below command starts top with last closed state.
top -c
8) Delay time: It tells delay time between screen updates.
Top -d seconds.tenths
9) Color and Highlighting: using the z
key toggles color and highlighting of the process list. This feature enhances visibility by color-coding different aspects of the processes, such as CPU usage, memory consumption, and process states (running, sleeping, etc.). It helps users quickly identify resource-intensive processes or anomalies in system behavior.
10) Alert Display Mode: Pressing the A
key toggles the alternative display mode. This mode rearranges the display to show multiple windows, each focusing on different aspects of system performance, such as CPU usage, memory, and processes.
Glances in Linux is a system monitoring tool that provides:
vmstat
,iostat
,netstat
, and ifstat
into a single command, offering real-time performance monitoring.sysstat
package, it collects and reports on various system activity statistics, including CPU, memory, and I/O usage, with the ability to save data for historical analysis.In this article we discussed the top
command which is an essential tool for Linux users and system administrators, offering real-time insights into system processes and resource usage. Its dynamic interface, interactive commands, and customization options make it a powerful tool for monitoring and troubleshooting. From sorting processes and killing tasks to specific user monitoring, the top
command provides a concise yet comprehensive view of system health, enabling users to maintain optimal performance efficiently.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4