In Linux the top command provides a dynamic real-time view of a running system to the user. It provides a summary report or information about process or threads currently being managed by the kernel. You can install and use htop application later for these information in details. In this tutorial I will provide you a general information about the command top
How to execute top:
To execute top command just open your terminal window and after writing top hit enter.
After executing the command you will able to see a screen like below
Now we will learn what is the meaning of these output
The first line of the result gives you the following information:
- current time (17:27:10)
- uptime of the machine (up 1 day, 10:33)
- users sessions logged in (2 users)
- average load on the system (load average: 0.01, 0.02, 0.05) the 3 values refer to the last minute, five minutes and 15 minutes.
The second row gives the following information:
- Processes running in totals (77 total)
- Processes running (1 running)
- Processes sleeping (76 sleeping)
- Processes stopped (0 stopped)
- Processes waiting to be stoppati from the parent process (0 zombie)
The third line indicates how the cpu is used. If you sum up all the percentages the total will be 100% of the cpu. Let’s see what these values indicate in order:
- Percentage of the CPU for user processes (0.3%us)
- Percentage of the CPU for system processes (0.0%sy)
- Percentage of the CPU processes with priority upgrade nice (0.0%ni)
- Percentage of the CPU not used (99.7%id)
- Percentage of the CPU processes waiting for I/O operations(0.0%wa)
- Percentage of the CPU serving hardware interrupts (0.0%hi) — Hardware IRQ
- Percentage of the CPU serving software interrupts (0.0%si) — Software Interrupts
- The amount of CPU ‘stolen’ from this virtual machine by the hypervisor for other tasks (such as running another virtual machine) this will be 0 on desktop and server without Virtual machine. (0.0%st — Steal Time)
The fourth and fifth rows respectively indicate the use of physical memory (RAM) and swap. In this order: Total memory in use, free, buffers cached.
Below are some shortcuts for top commands. Use these while running the top command.
l –To display or to hide load average line
t –To display or to hide task/cpu line
1 –To display or hide all other CPU’s
m –to display or to hide RAM and SWAP details
s –To change the time interval for updating top results(value is in sec’s)
R –To sort by PID number
u — Press u then username to get only that user process details
P –To sort by CPU utilization
M –To sort by RAM utilization
c –To display or hide command full path
r –To renice a process, press r then the PID no then the renice value to renice a process.
k –To kill a process, press k then PID number then enter to kill a process
w –To save the modified configuration permanently.
q –To quit the top command.
h –for getting help on top command
Latest posts by Tapas Mishra (see all)
- Working with Docker – II - December 16, 2016
- Working with Docker – I - November 28, 2016
- How to work with Chef using Oracle VirtualBox and Vagrant on a Windows host – Part II - November 30, 2014