Top command on Linux (list processes)
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 |
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).