Linux Top Command Usage with Examples
By Jithin on January 5th, 2017
One of the most basic command to monitor processes on Linux is the top command. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel. The processes are listed out in a list with multiple columns for details like process name, pid, user, cpu usage, memory usage. Apart from the list of processes, the top command also shows brief stats about average system load, cpu usage, and ram usage on the top. Top is one of the important tool for monitoring system usage and also to make any change for improving system performance. In this documentation, we can discuss about how to use the top command by explaining the different switches available.
How to use Top command
1) To display the running processes, just run the top command without any options.
The output will be something like this:
You can press ‘q’ to quit exit the window. The process list shows all the processes with various process specific details in separate columns.
PID: It is the task’s unique process id.
USER: It is the effective user name of the task’s owner.
PR: It is the priority of the task.
NI: The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task’s dispatchability.
VIRT: It is the total amount of virtual memory used by the task.
RES: It is the Resident size, the non-swapped physical memory a task has used.
SHR: It means the Shared Mem size (kb), the amount of shared memory used by a task.
%CPU: It shows the CPU usage. The task’s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
%MEM: It shows the Memory usage, a task’s currently used share of available physical memory.
TIME+: CPU Time, the same as ‘TIME’, but reflecting more granularity through hundredths of a second.
COMMAND: Display the command line used to start a task or the name of the associated program.
2) Press ‘c ‘option in running top command, it will display absolute path of running process.
3) Press ‘z’ option in running top command will display running process in color which may help you identify the running process easily.
4) To show the current version of the top command, run the following command.
$ top -h
The output will be look like:
procps-ng version 3.3.9
5) To specify a delay between the screen refreshes, run the below command.
$ top -d <number of seconds>
If you want to refresh every 10 seconds, run top -d 10
6) To show only the processes that a specific user is running, use the following command.
$ top -u <username>
7) There are more switches available and you can read more about them by using the following command.
$ man top
If you need any further assistance please contact our support department.