KEuVUe149Y7e320zVKJqOjpo0SGIHzz7ueew9qo8
Bookmark

Find Top Running Processes by Highest Memory and CPU Usage

Display top running processes in CLI terminal Linux - As always, command line is It's simple, flexible, and powerful. Using command line via terminal is good deal to save your time. So you can use your time to learn new things.

For that reason, today I will show you quick Linux tips how to find processes are consuming lots of Memory and CPU utilization in Linux via terminal.

The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel.

Also on Linuxslaves :

The types of system summary information shown and the types, order and size of information displayed for processes are all user configurable and that configuration can be made persis‐ tent across restarts.

top

Here's the output example :

Listing Memory and CPU Usage from Terminal Linux

You can add pipeline and head to print the first x lines as shown :

# top | head -n 15
top - 10:36:39 up 17 min,  1 user,  load average: 0.27, 0.45, 0.55
Tasks: 225 total,   1 running, 224 sleeping,   0 stopped,   0 zombie
%Cpu(s):  8.2 us,  1.5 sy,  0.2 ni, 83.5 id,  6.5 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8068884 total,  5452088 free,  1256932 used,  1359864 buff/cache
KiB Swap:   999996 total,   999996 free,        0 used.  6323236 avail Mem 

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND     
4609 tiwo      20   0   41804   3772   3120 R   6.2  0.0   0:00.01 top         
1 root      20   0  119744   5856   3932 S   0.0  0.1   0:02.10 systemd     
2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd    
3 root      20   0       0      0      0 S   0.0  0.0   0:00.04 ksoftirqd/0 
4 root      20   0       0      0      0 S   0.0  0.0   0:01.54 kworker/0:0 
5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:+ 
7 root      20   0       0      0      0 S   0.0  0.0   0:01.21 rcu_sched   
8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh

Save top Output to File

Additionally, you can use top in batch mode to save the output to a file :

top -b | head -n 22 > memoryusage.txt

For more usage, simply read the manual page, do :

man top

These were all how to listing top running processes in Linux by highest memory and CPU usage using top. Thanks for visiting us!