Use the Top command to see the processes running in Linux

The top command in Linux is used to display all processes running in the Linux environment. This tutorial shows you how to use the top command through explaining the various parameters available and the content they display.

Control the processes running in Linux with the top command

  1. How to run the top command
  2. What information is displayed?
    1. Line 1
    2. Line 2
    3. Line 3
    4. Line 3
    5. Line 4
    6. Main board
  3. Keep the top command always running in the background on a Linux computer
  4. The main parameters for the top command
    1. Show current version
    2. Specify a delay between screen refreshes
    3. Get a list of columns to sort by
    4. Sort columns in top command by column name
    5. Show only processes for a specific user
    6. Hide Task Idle
    7. Add the column displayed with the top command
    8. Switch between modes
    9. Change color
    10. Change the display while the top command is running

How to run the top command

Basically, all you need to do to display the currently running processes is to type the following into the terminal:

 top 

What information is displayed?

Use the Top command to see the processes running in Linux Picture 1

The following information is displayed when you run the top command in Linux:

Line 1

  1. Time
  2. How long has the computer been running?
  3. Number of users
  4. Average load
  5. Average load displays system load time in the last 1, 5 and 15 minutes.

Line 2

  1. Total tasks
  2. Number of running tasks
  3. Number of actions in 'sleep' state
  4. Number of tasks stopped
  5. Number of zombie tasks (the process does not exist)

Line 3

  1. User CPU usage by percentage
  2. CPU usage by system in percentage
  3. CPU usage by low priority processes by percentage
  4. CPU usage by idle process (process indicates the processor is idle) in percentage
  5. CPU usage by io wait (CPU time does not work to wait for I / O disk to complete) as a percentage
  6. CPU usage by hardware interrupt by percentage
  7. CPU usage by software interrupt by percentage
  8. CPU usage by steal time (virtual CPU time "standby" real CPU, while virtualization is serving other virtual processors) according to percentage

Line 3

  1. Total system memory
  2. Memory free
  3. Memory used
  4. Buffer cache cache

Line 4

  1. Total swap is available
  2. Total swap is empty
  3. Total swap used
  4. Memory available

Swap is virtual RAM, used when physical memory (RAM) is full.

Main board

  1. Process ID
  2. User
  3. Priority level
  4. Nice level (call a shell script with a specific priority)
  5. Virtual memory used by the process
  6. 'Resident' memory that a process uses (ie the process is always in memory and cannot be transferred to other storage devices)
  7. Memory can be shared
  8. CPU is used by process according to percentage
  9. Memory is used by processes in percentage
  10. The process time has been run
  11. Order

Keep the top command always running in the background on a Linux computer

You can easily keep the top command always running without having to enter the command into the terminal each time you open the machine.

To pause the top command and continue using the terminal, press CTRL + Z on the keyboard.

To bring the top command back to the foreground, enter fg.

The main parameters for the top command

  1. -h - Display the current version
  2. -c - This parameter converts the command column state from displaying the command to displaying the program name and vice versa
  3. -d - Specify the delay time when refreshing the screen
  4. -o - Sort by named school
  5. -p - Displays only processes with the specified ID
  6. -u - Displays only the processes of the specified user
  7. -i - Do not display task idle

Show current version

Enter the following information to display the current version details for the top command:

 top -h 

Output in the following form:

 procps -ng version 3.3.10 

Specify a delay between screen refreshes

To specify the delay between screen refreshes while using top, enter the following command:

 top -d 

To refresh the screen after every 5 seconds, enter:

 top -d 5 

Get a list of columns to sort by

Get the list of columns that you can sort top commands by entering the following:

 top -O 

There are many columns listed, so you can reduce the output shown as follows:

 top -O | less 

Sort columns in top command by column name

Use the command in the previous section to find a sortable column, then use the following syntax to sort by that column:

 top -o 

To sort by% CPU, type the following command:

 top -o %CPU 

Show only processes for a specific user

To show only the processes that specific users are running, use the following syntax:

 top -u 

For example, to display all the processes that the user is running, type the following command:

 top -u gary 

Hide Task Idle

The default view in the top may be a bit confusing and if you only want to see active processes (ie processes not in idle mode - 'idle') then you can run the following command:

 top -i 

Add the column displayed with the top command

While running the top command, you can press F to display the list of fields that can be displayed in the table:

Use the arrow keys to move up and down the list of fields.

To display a field on the screen, press D. To delete the field, press D on the field again. The asterisk (*) will appear next to the displayed fields.

You can sort the table by school by pressing the S key on the field you want to sort.

Press Enter to confirm the change and press Q to exit.

Switch between modes

While running the top command, you can press A to switch between standard and replacement screens.

Change color

Press Z to change the color of the values ​​in the top.

There are three stages needed to change colors:

1. Press S for summary data, M for notification, H for column heading or T for task information to target areas that need to change colors.

2. Select the color for the specified target: 0 is black, 1 is red, 2 is green, 3 is yellow, 4 are blue, 5 is magenta, 6 is green and 7 is white

3. Press Enter to confirm the change

Press B to bold the text.

Change the display while the top command is running

While the top command is running, you can enable and disable many features by pressing the relevant keys.

The following table shows the key to press and the function it provides:

Function key DescriptionA Replacement display (default off) d Refresh the screen after the specified delay, in seconds (default is 1.5 seconds) p PID monitoring (default off), display all processes B Activate bold (default on), values ​​displayed in bold text l Display load averages (default on) t Specify how to display tasks (default 1 + 1) m Specify the memory usage displayed (default 2 lines) 1 single CPU (default off) - ie display for multiple CPUs J Align numbers to the right (default turn on) j Align text right (default off) R Reverse arrangement (default on) - From the highest progress to the lowest progress S Accumulation time (default off) u User filter (default off ), display only euid U User filter (default off) displays any uid V Forest view (default turned on) displayed as branches x Highlight column (default off) z Multiple display color or monochrome (default on)

There are more parameters for the top command. You can read more about them by entering the following information in the terminal window:

 man top 
4.5 ★ | 4 Vote

May be interested

  • Basic Linux commands everyone needs to knowBasic Linux commands everyone needs to know
    when using linux, you should also learn basic linux commands to make operations quicker and easier. here are some basic commands on linux you should know.
  • 18 Interesting Linux Commands in Terminal18 Interesting Linux Commands in Terminal
    terminal is a very powerful tool, but it can be made 'interesting' through a few bash commands that tipsmake.com will introduce to you below. let's follow and learn because some commands are quite useful.
  • 8 commands for efficient management of Linux processes8 commands for efficient management of Linux processes
    there are three main states in the life cycle of an application process: start, run, and stop. if you want to be a competent linux administrator, you need to know how to manage each state carefully. the following 8 commands can be used to help you manage the entire process lifecycle.
  • How to prevent Microsoft Edge from running too many processes on WindowsHow to prevent Microsoft Edge from running too many processes on Windows
    if you take a look at the windows task manager while edge is running, you're sure to see dozens of processes for the browser, even if you only have one or two tabs open. but why does edge require so many active processes and is there a way to reduce the number?
  • The Cat command in LinuxThe Cat command in Linux
    the cat command (short for 'concatenate') is one of the most frequently used commands in operating systems like linux / unix. the cat command allows users to create one or more files, view file contents, join files, and redirect output in a terminal or file.
  • How to use the last command in LinuxHow to use the last command in Linux
    want to know who, what time and which device to access your linux computer? please read the following article.
  • How to use ss command on LinuxHow to use ss command on Linux
    the ss command is a new alternative to the classic netstat. you can use it on linux to get data about network connections. here's how to work with this helpful tool.
  • Instructions for using zforce command on LinuxInstructions for using zforce command on Linux
    the gzip command is a popular tool used to compress / decompress files in linux. tipsmake.com presents the basics of this tool in the article: some basic terminal commands in linux mint 11.
  • How to limit access to su command in LinuxHow to limit access to su command in Linux
    if you have added linux to your data center or are just using a single linux machine for your business, you need to make sure it is as secure as possible.
  • 12 things Linux is easier to do in the command line than graphical software12 things Linux is easier to do in the command line than graphical software
    graphical user interfaces (guis) were invented to make life easier for computer users, so it's very common to use them to perform most everyday tasks.