Linux Process Monitoring

In Linux, the top command is a powerful utility used to monitor running processes in real-time. It displays an ordered list of active processes and updates regularly, showing critical system information like CPU usage, memory consumption, swap memory, cache size, buffer size, process IDs (PIDs), users, and commands. This tool is essential for system administrators to identify processes consuming high memory and CPU resources.

How Top Command Works

The top command provides a dynamic view of the system's running processes. It refreshes every few seconds by default and sorts processes by CPU usage, with the most resource-intensive processes appearing at the top of the list.

Basic Usage

To start monitoring processes, simply type the following command in the terminal:

top

This command requires appropriate permissions to display all system processes. For comprehensive system monitoring, you may need to run it with elevated privileges:

sudo top

Understanding Top Command Output

The top command output is divided into two main sections: the system summary (header) and the process list.

System Summary Section

The header displays overall system statistics:

  • Load average − System load over 1, 5, and 15 minutes

  • Tasks − Total number of running, sleeping, stopped, and zombie processes

  • CPU usage − Percentage of CPU time spent on user processes, system processes, and idle time

  • Memory usage − Total, used, free, and cached memory

  • Swap usage − Total, used, and available swap space

Process List Columns

Column Description
PID Process ID
USER Username of the process owner
PR Process priority
NI Nice value (-20 to 19)
VIRT Virtual memory used by process
RES Physical memory used by process
SHR Shared memory used by process
S Process status (R=running, S=sleeping)
%CPU Percentage of CPU time used
%MEM Percentage of physical memory used
TIME+ Total CPU time consumed
COMMAND Command name or command line

Common Top Command Options

Several command-line options enhance the functionality of top:

top -u username    # Show processes for specific user
top -p PID         # Monitor specific process by PID
top -d seconds     # Set refresh interval
top -n iterations  # Run for specified number of iterations
top -b             # Batch mode (useful for scripts)

Interactive Commands

While top is running, you can use interactive keys to modify the display:

  • k − Kill a process by entering its PID

  • r − Change process priority (renice)

  • M − Sort by memory usage

  • P − Sort by CPU usage (default)

  • q − Quit top command

  • h − Display help screen

Alternative Process Monitoring Tools

Besides top, Linux offers other process monitoring utilities:

htop     # Enhanced version of top with better interface
ps aux   # Static snapshot of running processes
pstree   # Display processes in tree format

Conclusion

The top command is an essential tool for Linux system monitoring, providing real-time insights into process behavior and resource consumption. Understanding its output and interactive features helps administrators identify performance bottlenecks and manage system resources effectively.

Updated on: 2026-03-17T09:01:38+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements