Introduction to top command
The top command is one of the most used tools in Linux systems to observe the behavior of processes in real time. It runs from the terminal and displays a dynamic table that is updated every few seconds, allowing the administrator to quickly identify what they consume more CPU, memory or other resources. Your interface, although text-based, is intuitive and offers a lot of information without installing additional packages.
How top works
When you launch top, the program reads information from the pseudo-file system / proc and presents it in columns. The first line shows a system summary: current time, activity time, number of users and average load. Then each row corresponds to a process and contains data such as the PID, the owner, the percentage of CPU and memory used, the status and command that started it.
Main columns and their meaning
- PID: process identification number.
- USER: user running the process.
- PR and NI: implementation priority and its nice value.
- VITR: total virtual memory reserved.
- RES: real physical memory in use.
- SHMem: shared memory.
- % CPU:% CPU consumed since last update.
- % MEM:% of RAM used.
- TIME +: total CPU time that has consumed the process.
- COMMAND: name or route of the executable.
Interactive commands within top
While top is running, you can type various letters to modify your behavior without leaving the program. Some of the most useful are:
- k: allows to kill a process by entering your PID and the desired signal.
- r: renews the (nice) priority of a process.
- c: alternates between showing only the command name and the complete route.
- f: enters a menu to choose which columns to show and in which order.
- S: changes the accumulated time mode, showing the CPU time of the child processes.
- h: shows the internal support of top.
- q: gets out of the program.
Most commonly used launch options
Top supports several lags that modify your output from the start. Among the most common are:
- -d: sets the delay between updates (default 3.0 s).
- -n: limits the number of iterations before top ends automatically.
- -b: runs top in batch mode, useful to redirect your output to a file or to another command without interactivity.
- -u: filters the processes to show only those belonging to a specific user.
- -p: shows only the processes whose IDs are specified.
Practical and alternative advice
To get a more friendly view, many administrators prefer to use htop, an improved version of top with progress bars, colors and ability to move with the mouse. However, knowing top is essential because it is present in virtually any Linux distribution, even in minimum systems where additional packages cannot be installed. Some tips:
- Use top in batch mode with the -b option and redirect to a file to create resource consumption logs.
- Combine top with grep to follow a concrete process: top -b -n 1 | grep name _ of _ process.
- Observe the average load line to detect peaks that may indicate bottlenecks.
- Remember that the CPU percentage can exceed 100% in multi-process systems, as it refers to an individual core.
In short, top remains an indispensable tool for anyone who manages Linux servers or workstations. Its ability to provide an instant view of the state of the system makes it the first point of consultation when a performance problem arises.


