How to Monitor System Activity in Linux | top Command
Last Updated :
25 Jul, 2025
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.
Syntax of the 'top' command
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,
- PID: Shows task’s unique process id.
- USER: User name of owner of task.
- PR: The process’s priority. The lower the number, the higher the priority.
- NI: Represents a Nice Value of task. A Negative nice value implies higher priority, and positive Nice value means lower priority.
- VIRT: Total virtual memory used by the task.
- RES: How much physical RAM the process is using, measured in kilobytes.
- SHR: Represents the Shared Memory size (kb) used by a task.
- %CPU: Represents the CPU usage.
- %MEM: Shows the Memory usage of task.
- TIME+: CPU Time, the same as ‘TIME’, but reflecting more granularity through hundredths of a second.
- COMMAND: The name of the command that started the process.
Options for the top command
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:
Key | Function |
---|
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.
Uptime
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:
- System Time: The current time on the system.
- Uptime: How long the system has been running since the last boot.
- Users: The number of users currently logged into the system.
- Load Average: This is shown in three numbers separated by commas. These numbers represent the average number of processes waiting for CPU time over the last 1 minute, 5 minutes, and 15 minutes, respectively. A value of 1.0 means the system's CPU is fully utilized; higher values indicate potential overloading.
Tasks
This section provides an overview of the total number of processes currently managed by the system.
- total: Indicates the total count of processes currently being tracked by the system.
- running: Represents the number of processes currently actively using CPU time.
- sleeping: Refers to processes that are currently idle and waiting for a signal to wake up.
- stopped: Denotes processes that have been manually stopped, typically through a signal.
- zombie: Indicates processes that have completed execution but still have an entry in the process table.
%Cpu(s):
The %Cpu(s)
line in the top
command provides information about CPU usage and statistics on a Linux system. It typically includes:
- us: Percentage of CPU time spent running user processes.
- sy: Percentage of CPU time spent running kernel (system) processes.
- ni: Percentage of CPU time spent running processes with a nice value (priority adjusted).
- id: Percentage of CPU time spent idle (no work being done).
- wa: Percentage of CPU time spent waiting for I/O operations to complete.
- hi: Percentage of CPU time spent servicing hardware interrupts.
- si: Percentage of CPU time spent servicing software interrupts.
- st: Percentage of CPU time stolen from this virtual machine by the hypervisor (if virtualized).
MiB Memory:
The "MiB Memory" line in the top
command provides information about memory usage and statistics on a Linux system. It typically includes:
- total: Total amount of physical memory (RAM) available in MiB.
- used: Amount of RAM currently in use by processes and the kernel.
- free: Amount of RAM not being used at all.
- buff/cache: Amount of memory used for buffering data and caching filesystems.
Mib Swap:
The "MiB Swap" line in the top
command provides information about swap usage and statistics on a Linux system. It typically includes:
- total: Total amount of swap space available in MiB.
- used: Amount of swap space currently in use.
- free: Amount of swap space that is not being used.
- available: Estimate of how much memory is available for starting new applications without swapping.
Top Common Options Used in top Command
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:
top
Option 2. '-v'
The -v option in top command is used to check the version.
Syntax:
top -v
or
top --version
Example:
top -v
Option 3. '-p'
The -p command is used to monitoring the process by their Process ID.
Syntax:
top -p <PID>
Example:
top -p 7760
Option 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
htop
Option 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 1
Option 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 = 1869
Option 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 4002
Option 8. '-1'
The command top -1
is used in the Linux top
command to show CPU usage per core.
Syntax:
top -1
Example:
top -1
Option 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 -h
Other 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.
Comprehensive System Monitoring with Glances on Linux
Glances in Linux is a system monitoring tool that provides:
- Overview Dashboard: Displays real-time statistics on CPU, memory, disk, network, and processes.
- Process Table: Lists detailed information about running processes, including CPU and memory usage.
- Alerts and Notifications: Alerts users about critical system metrics exceeding predefined thresholds.
- Plugins and Extensions: Supports various plugins for additional monitoring capabilities, such as Docker and SNMP.
- Interactive UI: Offers an interactive command-line interface or a web-based interface for monitoring multiple systems remotely.
Are There Alternatives to Top?
- htop: An interactive and visually appealing process viewer with color-coding, easy navigation, and process management features.
- Glances: A cross-platform monitoring tool that provides a comprehensive view of system performance, including CPU, memory, disk I/O, and network usage.
- nmon: A performance monitoring tool designed for AIX and Linux systems, offering detailed statistics and a user-friendly interface.
- atop: An advanced system and process monitor that provides detailed resource consumption for both current and historical data, including CPU, memory, disk, and network usage.
- dstat: A versatile resource statistics tool that combines the functionality of
vmstat
,iostat
,netstat
, and ifstat
into a single command, offering real-time performance monitoring. - sar: Part of the
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.
Conclusion
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.
Similar Reads
Linux/Unix Tutorial Linux is one of the most widely used open-source operating systems. It's fast, secure, stable, and powers everything from smartphones and servers to cloud platforms and IoT devices. Linux is especially popular among developers, system administrators, and DevOps professionals.Linux is:A Unix-like OS
10 min read
Getting Started with Linux
What is Linux Operating SystemLinux is based on the UNIX operating system. UNIX is a powerful, multi-user, multitasking operating system originally developed in the 1970s at AT&T Bell Labs. It laid the foundation for many modern operating systems, including Linux.Linux is free and open-source, accessible to everyone.Its sour
10 min read
LINUX Full Form - Lovable Intellect Not Using XPLINUX stands for Lovable Intellect Not Using XP. Linux was developed by Linus Torvalds and named after him. Linux is an open-source and community-developed operating system for computers, servers, mainframes, mobile devices, and embedded devices. Linux receives requests from system programs and it r
2 min read
Difference between Linux and WindowsLinux: Linux could be a free and open supply OS supported operating system standards. It provides programming interface still as programme compatible with operating system primarily based systems and provides giant selection applications. A UNIX operating system additionally contains several several
7 min read
What are Linux Distributions ?A Linux distribution, often shortened to âdistro,â is a packaged version of Linux that comes with the Linux kernel plus a collection of software and utilities that make the OS functional and user-friendly. Some distros are optimized for business environments, offering tools for productivity and ente
8 min read
Difference between Unix and LinuxUnix was created in the 1970s by Ken Thompson and Dennis Ritchie at Bell Labs. Dennis Ritchie was also the creator of the C programming language. Originally a command-line operating system, Unix has evolved to support graphical interfaces (GUI) as well. It became popular in universities, enterprises
5 min read
Installation with Linux
How to Install Arch Linux in VirtualBox?Installing Arch Linux on a virtual machine is an excellent way to experience this powerful and flexible Linux distribution without affecting your main system. If you're looking to install Arch Linux in VirtualBox, this guide will take you through the process step-by-step. Arch Linux is known for its
7 min read
Fedora Linux Operating SystemFedora Linux is a free and open-source operating system based on the Linux kernel and was developed by the community-supported Fedora Project. It is known for its fast release cycle, which keeps the operating system up to date with the latest software and technologies.What is the Fedora Linux Operat
12 min read
How to install Ubuntu on VirtualBox?Installing Ubuntu on VirtualBox is a great way to experience the powerful features of this popular Linux distribution without altering your main operating system. Whether youâre a developer, a student, or simply curious about Linux, setting up Ubuntu on VirtualBox allows you to test and explore in a
6 min read
How to Install Linux Mint?Linux Mint is the second-largest Linux-based distro used in the world. Linux Mint is a community-driven Linux distribution based on Ubuntu which itself is based on Debian and bundled with a variety of free and open-source applications. So here we discuss the installation of Linux mint. Installation
3 min read
How to Install Kali Linux on Windows?Kali Linux is an open-source Linux distribution based on Debian, designed for sophisticated penetration testing and security auditing. Kali Linux includes hundreds of tools for diverse information security activities such as penetration testing, security research, computer forensics, and reverse eng
2 min read
How to Install Linux on Windows PowerShell Subsystem?There are several ways to Install a Linux subsystem on your Windows PC Powershell Environment. It is good for learners, but it is recommended using original Linux OS if you are a developer as the Subsystem lacks the pre-installed Linux tools. Before we begin installing a Linux subsystem, we need to
2 min read
How to Find openSUSE Linux Version?openSUSE is well known for its GNU/Linux-based operating systems, mainly Tumbleweed, a tested rolling release, and Leap, a distribution with Long-Term-Support(LTS). MicroOS and Kubic are new transactional, self-contained distributions for use as desktop or container runtime. Here we figure out which
2 min read
How to Install CentOSCentOS is a popular open-source Linux distribution aimed at servers and provides compatibility with Red Hat's RPM package manager. It is built with the goal of providing a stable operating system that provided great compatibility with the upstream RHEL (Red hat enterprise Linux) CentOS is therefore
2 min read
Linux Commands
Linux CommandsLinux commands are essential for controlling and managing the system through the terminal. This terminal is similar to the command prompt in Windows. Itâs important to note that Linux/Unix commands are case-sensitive. These commands are used for tasks like file handling, process management, user adm
15+ min read
Essential Unix CommandsUnix commands are a set of commands that are used to interact with the Unix operating system. Unix is a powerful, multi-user, multi-tasking operating system that was developed in the 1960s by Bell Labs. Unix commands are entered at the command prompt in a terminal window, and they allow users to per
7 min read
How to Find a File in Linux | Find CommandThe find command in Linux is used to search for files and directories based on name, type, size, date, or other conditions. It scans the specified directory and its sub directories to locate files matching the given criteria.find command uses are:Search based on modification time (e.g., files edited
9 min read
Linux File System
Linux File SystemA file system is a structured method of storing and managing dataâincluding files, directories, and metadataâon your machine. Think of it like a library. If thousands of books were scattered around, finding one would be hard. But in an organized structure, like labeled shelves, locating a book becom
12 min read
Linux File Hierarchy StructureThe Linux File Hierarchy Structure or the Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Unix-like operating systems. It is maintained by the Linux Foundation. In the FHS, all files and directories appear under the root directory /, even if they are sto
6 min read
Linux Directory StructureIn Linux, everything is treated as a file even if it is a normal file, a directory, or even a device such as a printer or keyboard. All the directories and files are stored under one root directory which is represented by a forward slash /. The Linux directory layout follows the Filesystem Hierarchy
6 min read
Linux Kernel
Linux KernelLinux Kernel is the heart of Linux operating systems. It is an open-source (source code that can be used by anyone freely) software that is most popular and widely used in the industry as well as on a personal use basis. Who created Linux and why? Linux was created by Linus Torvalds in 1991 as a hob
4 min read
Kernel in Operating SystemA kernel is the core part of an operating system. It acts as a bridge between software applications and the hardware of a computer. The kernel manages system resources, such as the CPU, memory and devices, ensuring everything works together smoothly and efficiently. It handles tasks like running pro
9 min read
How Linux Kernel Boots?Many processes are running in the background when we press the system's power button. It is very important to learn the Linux boot process to understand the workings of any operating system. Knowing how the kernel boots is a must to solve the booting error. It is a very interesting topic to learn, l
11 min read
Difference between Operating System and KernelIn the world of computing, two terms that are frequently mentioned are Operating System (OS) and Kernel. In this article, we will explore the key differences between the OS and the Kernel, their functions, and how they work together to manage hardware and software.What is an Operating System?An Oper
3 min read
Linux Kernel Module Programming: Hello World ProgramKernel modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system. Custom codes can be added to Linux kernels via two methods. The basic way is to add the code to the kernel source tree and
7 min read
Linux Loadable Kernel ModuleIf you want to add code to a Linux kit, the basic way to do that is to add source files to the kernel source tree and assemble the kernel. In fact, the process of setting up the kernel consists mainly of selecting which files to upload to the kernel will be merged. But you can also add code to the L
7 min read
Loadable Kernel Module - Linux Device Driver DevelopmentFor Linux device drivers, we can use only two languages: Assembler and C. Assembler implements the main parts of the Linux kernel, while C implements the architecture-dependent parts. Uploaded kernel modules are often referred to as kernel modules or modules, but those are misleading names because t
4 min read
Linux Networking Tools
Network configuration and troubleshooting commands in LinuxComputers are often connected to each other on a network. They send requests to each other in the form of packets that travel from the host to the destination. Linux provides various commands from network configuration and troubleshooting. Network Configuration and Troubleshooting Commands in Linux
5 min read
How to configure network interfaces in CentOS?A network interface is a link between a computer and another network(Private or Public). The network interface is basically a card which is known as NIC or Network Interface Card, this does not necessarily have to be in a physical form instead, it can be inbuilt into the software. If we take the exa
5 min read
Command-Line Tools and Utilities For Network Management in LinuxIf you are thinking of becoming a system administrator, or you are already a system admin, then this article is for you.As a system admin, your daily routine will include configuring, maintaining, troubleshooting, monitoring, securing networks, and managing servers within data centers. Network confi
8 min read
Linux - Network Monitoring ToolsNetwork monitoring is using a system (hardware or software) that continuously observes your network and the data flows through it, depending on how the monitoring solution actually functions and informs the network administrator. We can keep a check on all the activities of our network easily. While
4 min read
Linux Process
Linux Firewall
Shell Scripting & Bash Scripting
Introduction to Linux Shell and Shell ScriptingWhenever we use any modern operating system like Linux, macOS, or Windows we are indirectly interacting with a shell, the program that interprets and executes our commands. While running Ubuntu, Linux Mint, or any other Linux distribution, we are interacting with the shell by using the terminal. In
8 min read
What is Terminal, Console, Shell and Kernel?Understanding the terms terminal, console, shell, and kernel is crucial for anyone working with computers or learning about operating systems. These concepts are key components of how we interact with our devices and software. The terminal is a text-based interface used to interact with the computer
5 min read
How to Create a Shell Script in linuxShell is an interface of the operating system. It accepts commands from users and interprets them to the operating system. If you want to run a bunch of commands together, you can do so by creating a shell script. Shell scripts are very useful if you need to do a task routinely, like taking a backup
7 min read
Shell Scripting - Different types of VariablesThe shell is a command-line interpreter for Linux and Unix systems. It provides an interface between the user and the kernel and executes commands. A sequence of commands can be written in a file for execution in the shell. It is called shell scripting. It helps to automate tasks in Linux. Scripting
4 min read
Bash Scripting - Introduction to Bash and Bash ScriptingBash is a command-line interpreter or Unix Shell and it is widely used in GNU/Linux Operating System. It is written by Brian Jhan Fox. It is used as a default login shell for most Linux distributions. Scripting is used to automate the execution of the tasks so that humans do not need to perform them
12 min read
Bash Script - Define Bash Variables and its typesVariables are an important aspect of any programming language. Without variables, you will not be able to store any required data. With the help of variables, data is stored at a particular memory address and then it can be accessed as well as modified when required. In other words, variables let yo
12 min read
Shell Scripting - Shell VariablesA shell variable is a character string in a shell that stores some value. It could be an integer, filename, string, or some shell command itself. Basically, it is a pointer to the actual data stored in memory. We have a few rules that have to be followed while writing variables in the script (which
6 min read
Bash Script - Difference between Bash Script and Shell ScriptIn computer programming, a script is defined as a sequence of instructions that is executed by another program. A shell is a command-line interpreter of Linux which provides an interface between the user and the kernel system and executes a sequence of instructions called commands. A shell is capabl
4 min read
Shell Scripting - Difference between Korn Shell and Bash shellKorn Shell: Korn Shell or KSH was developed by a person named David Korn, which attempts to integrate the features of other shells like C shell, Bourne Shell, etc. Korn Shell allows developers to generate and create new shell commands whenever it is required. Korn shell was developed a long year bac
3 min read
Shell Scripting - Interactive and Non-Interactive ShellA shell gives us an interface to the Unix system. While using an operating system, we indirectly interact with the shell. On Linux distribution systems, each time we use a terminal, we interact with the shell. The job of the shell is to interpret or analyze the Unix commands given by users. A shell
3 min read
Shell Script to Show the Difference Between echo â$SHELLâ and echo â$SHELLâIn shell scripting and Linux, the echo command is used to display text on the terminal or console. When used with the $SHELL variable, which contains the path of the current user's shell program, the output of the echo command can be different depending on whether the variable is enclosed in single
4 min read