top
Command in LinuxOverview:top
is a powerful command-line utility in Linux that provides a dynamic real-time view of a running system. It displays a detailed overview of system processes, including information about CPU and memory utilization.
top
:d
: Specifies the delay between screen updates. For example, top -d 5
updates every 5 seconds.u
: Shows processes by a specific user. For example, top -u username
shows processes for username
.p
: Monitors specific processes. For example, top -p PID
where PID
is the Process ID.n
: Limits the number of iterations. For example, top -n 10
will update 10 times and then exit.b
: Runs top
in batch mode, useful for sending output to a file or another process.top
:h
or ?
: Displays help.k
: Kills a process. You need to enter the PID of the process.u
: Filters processes by a specific user.P
: Sorts by CPU usage.M
: Sorts by memory usage.q
: Quits top
.Command:
top
Sample Output:
top - 15:30:05 up 10 min, 2 users, load average: 0.42, 0.44, 0.27
Tasks: 162 total, 1 running, 160 sleeping, 0 stopped, 1 zombie
%Cpu(s): 5.1 us, 2.1 sy, 0.0 ni, 91.7 id, 0.8 wa, 0.0 hi, 0.3 si, 0.0 st
MiB Mem : 7822.0 total, 5068.3 free, 1703.3 used, 1050.4 buff/cache
MiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 5799.7 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1023 user 20 0 457904 64740 32020 S 6.2 0.8 0:03.89 gnome-shell
1 root 20 0 170392 11344 8244 S 0.0 0.1 0:01.23 systemd
[other processes...]
Explanation of Output:
us
), system processes (sy
), and idle (id
).top
is an invaluable tool for system administrators and power users. It gives a quick and detailed view of the system’s state, helping in diagnosing performance issues, monitoring resource usage, and managing system processes.