The top command in Linux has been a fixture since 1984, serving as a crucial tool for administrators to evaluate system behavior and determine which processes are consuming the most resources. Since its inception, alternative “top” commands such as atop and htop have appeared, each offering unique insights tailored to system administrators’ needs. Nevertheless, the original top command continues to be one of the most prevalent and straightforward tools for monitoring system performance.
When executed in its simplest form by typing “top”, it presents the most essential performance metrics likely to be needed on a Unix system. Initially, the top command provides five lines of critical summary information about the system activity: system uptime, the current load average indicating system busyness, process count, and the usage statistics for memory and swap. An example follows:
Within the top output, it’s beneficial to monitor the three load averages located in the upper right corner, which reflect system busyness over the previous one, five, and fifteen minutes. These figures help gauge the system’s ongoing load intensity, though they only cover the last quarter-hour.
Further details seen in the command’s output include the total number of tasks, how many are actively running (utilizing the CPU), the number in a sleeping state, those stopped, or those in a “zombie” state (processes that have completed but still exist in the process table). The categorization of CPU usage is broken down into several abbreviations, helping to clarify the type of activity each process is engaging in.
us: % CPU time spent in user space
sy: % CPU time spent in kernel space
ni: % CPU time spent on “nice” low priority processes
id: % CPU time spent idle
wa: % CPU time spent in wait (on disk)
hi: % CPU time spent servicing/handling hardware interrupts
si: % CPU time spent servicing/handling software interrupts
st: % CPU time in involuntary wait by virtual CPU while hypervisor is servicing another processor (or) % CPU time stolen from a virtual machine
Further details provided by the top command include an extensive list of system processes, prioritizing those that use more system resources. An illustrative example is the top portion of the output:
This segment details the following components:
PID: Lists the process IDs
USER: Identifies the userid of the individual managing each process
PR: Indicates the process priority
NI: Reflects the nice value allocated to the process
VIRT: Records the total amount of virtual memory utilized by the process
RES: Denotes the resident memory consumption
SHR: Specifies the shared memory usage
S: Displays the process status (refer to the comprehensive status list for meaning)
%CPU: Reports the percentage of CPU time the process occupies since the last update
%MEM: Illustrates the portion of physical memory utilized
TIME+: Reveals the cumulative CPU time consumed by the task, in hundredths of a second
COMMAND: Describes the command name or the full command line used
The values in the “S” (process status) field represent these states:
‘D’ = uninterruptible sleep
‘R’ = running
‘S’ = sleeping
‘T’ = traced or stopped
‘Z’ = zombie
You can ask the system to tell you the version of the top command that you are using like this:
While viewing the top command’s output, you can alter the presentation of the data by using the keys described below:
Press the Q key to exit.
Press the M key to arrange the process list by the amount of memory utilized, displaying the highest first.
Press the P key to organize the process list according to CPU usage.
Press the N key to organize by process ID.
Press the T key to sort by duration of operation.
Press the R key to invert the current sorting order.
The top command is straightforward and simple to comprehend. It is advisable to become acquainted with its display before encountering any issue, as this will assist in recognizing what is considered “normal.”
Welcome to DediRock, your trusted partner in high-performance hosting solutions. At DediRock, we specialize in providing dedicated servers, VPS hosting, and cloud services tailored to meet the unique needs of businesses and individuals alike. Our mission is to deliver reliable, scalable, and secure hosting solutions that empower our clients to achieve their digital goals. With a commitment to exceptional customer support, cutting-edge technology, and robust infrastructure, DediRock stands out as a leader in the hosting industry. Join us and experience the difference that dedicated service and unwavering reliability can make for your online presence. Launch our website.