Site icon LinuxCommands.site

Linux top command tutorial: top syntax and top examples

What is the linux top command?

linux top — display and update sorted information about processes

Run this command to start an interactive command mode with the top half showing statistics that contain load, process, and resource usage. The bottom half shows a list of currently running processes.

Pressing q will only exit the command mode.

What is the linux top command syntax?

syntax

top -hv|-bcEHiOSs1 -d secs -n max -u|U user -p pid -o fld -w [cols]

options

Summary area commands

When the linux top command is run in the foreground, the following related keys are used to turn more functions on and off.

Summary display – What data can be displayed by the linux top command?

top half – resource usage

UPTIME and LOAD Averages

This portion consists of a single line containing:
current time and length of time since last boot
total number of users
system load avg over the last 1, 5 and 15 minutes

TASK and CPU States

This portion consists of a minimum of two lines. In an SMP environment, additional lines can reflect individual CPU state percentages.

* Line 1 shows total tasks or threads, depending on the state of the Threads-mode toggle.
That total is further classified as:
running; sleeping; stopped; zombie
* Line 2 shows CPU state percentages based on the interval since the last refresh.

CPU status field description:

MEMORY Usage

This portion consists of two lines which may express values in kibibytes (KiB) through exbibytes (EiB) depending on the scaling factor enforced with the `E’ interactive command.

As a default, Line 1 reflects physical memory, classified as:
total, free, used and buff/cache

Line 2 reflects mostly virtual memory, classified as:
total, free, used and avail (which is physical memory)

bottom halfrunning processes

Descriptions of fields

Top examples – How to use the linux top command?

Display Specific User Process

➜  ~ top -u ylspirit 

Display specified process information

➜  ~ top -p 652

Display thread information of the specified pid

➜  ~ top -Hp pid

Terminate update display after updating 2 time

➜  ~ top -n 2

Top information is updated at specified intervals

➜  ~ top -d 3 # 3 second

Highlight Running Process

Press ‘z‘ option in running top command will display running process in color which may help you to identified running process easily

Display the absolute path of the process command

Press ‘c‘ option in running top command, it will display absolute path of running process command

Display the number of CPU cores and their usage

Press “1” option in running top command, it will display the number of CPU cores and their usage.

For more explanation of the top command, please see man top.

The top command is used in some actual production:

Linux load average high, Java project
four ways to view linux load average and load explained
Awk tutorial: find and kill process use awk

Recommended Posts:

Linux common commands tutorial and use examples
GNU sed syntax and sed examples
Awk tutorial: awk syntax and awk examples
linux chmod command and linux chown command usage
linux iostat syntax and iostat examples
linux grep command and grep examples

Exit mobile version