The Top utility tool is a handy tool that gives Linux users a peek at the performance statistics on their systems. You can use it to monitor resource metrics such as memory usage, CPU, load average, uptime and processes that are running on the system.
Top utility tool gives the user an overview of the system’s crucial performance statistics. The image below is a screenshot of the terminal showing the system’s statistics such as users logged in, tasks, uptime, CPU utilization, memory utilization and swap usage.
Every column above represents different information as the horizontal lines indicate a summary of the different areas running in the system. Let us analyze some of the columns for better understanding.
PID – This stands for Process ID. Every running process on the Linux systems bears a PID
USER – This is the user running the process or use that the process is running under.
PR – Indicates process priority from the Linux Kernel
NI – represents the nice value that matches the user space. The value ranges from -20 as the highest figure, 0 the default, and +19 as the lowest. There is a relationship between nice value and priority which is PR = 20 + NI
VIRT – represents the amount of virtual memory the process is using. It also describes the virtual size of a process.
RES – Defines the resident memory capacity.
SHR – This refers to shared memory that a process is assigned. It also indicates how much of the VIRT is available for sharing in terms of libraries or memory.
- S – Represents the status of a particular process that has the following values:
- D – A process waiting for something to happen
- R – Ready to run the process
- S – Process sleep state waiting for a trigger
- T – Indicates a traced or stopped process
- Z – Indicates a dead process (Zombie process) or one that has completed execution
%CPU – time the task has been using since the last update. On machines with more than CPU, the percentage can be more than 100%
%MEM – a percentage of the available physical memory a process is using
TIME+ – Represents the total time a task is utilizing since it was started
COMMAND – Represents the actual process or command currently running
Other output on the command line following the top command may not be visible on the first page. They include:
- Uptime and load average
- CPU states
- Memory usage
1) Using Top Help Menu
The interactive nature of the help menu gives options on the number of commands administrators use. To get help using the top utility, simply type h or the question mark symbol ?
2) Manual Display Refresh
By default, the top command displays information on a 3 seconds interval. To get the manual refresh mode use the ENTER or SPACE keys.
3) Changing Display Mode
Instead of using a single-window to analyze your system, you can set the output to display four windows each with a different field or group using the names:
- Mem : sort by %MEM
- Def : Sort by %CPU
- Job : sort by PID
- Usr : Sort by User field