Categories: Process

Top command on Linux (list processes) [Basic Guide]

The top command in Linux is an interesting way of looking at processes running on Linux, with screen updates and ordered by the process they use more CPU, at the TOP or on the screen.

This feature is useful for monitoring how one or more processes act in the system.

The most used options are:

  • -b: Run in batch mode or batch file. It is used to direct the output of the command to another process or to a file;
  • -d n: Determines the time of screen updates in n seconds. The default is five seconds;
  • -n num: Shows the number of times the updates of the processes running on the screen are updated and then terminated. Useful to be used with the —b;
  • -q: Run with updates in real time option. This option should be used with caution because it can consume a large amount of CPU;
  • -u: Monitors the processes running by a particular user;
  • -p: Monitors a particular process identified by its PID. More than one process can be defined with this option.

The top command may also support some commands that alter its behavior during its execution. They are:

  • Z: Change the color scheme of the top. For this option to be active, the terminal must support ANSI;
  • F: Add columns with more process monitoring options;
  • u: Shows the processes of a particular user;
  • k: Terminates (kills) with a particular process;
  • r: Changes the execution priority of the process ( renice);
  • R: Changes the order of processes according to CPU usage;
  • q: Exits interactive top mode.
Top Command

The top command on the first line provides the average CPU load (load average), corresponding to 1 minute, 5 minutes, and 15 minutes, the same as the “uptime” command. The higher the numbers, the more overloaded the system will be.

It is common for the system to experience high rates of an average of 1 minute. But a constant high average rate on the 15-minute indicator is a sign that the CPU is poorly sized.

The second line contains the total number of processes, the number in the running state (running – which corresponds to the number of CPUs and cores), sleeping (which are on disk), stopped (stop) and zombie processes (child processes that they stopped executing, but the parent process was not alerted).

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Share
Published by
Uirá Endy Ribeiro
Tags: commandtop

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.