1. top command
The top command gives real-time information about the running processes as well as a summary of system information. It displays uptime, load averages, CPU states, memory usage, and tasks i.e. total, running, sleeping, stopped, and zombie tasks.
It also displays a list of real-time running processes with all the details. To run the top command, execute the following command in a terminal window:
top |
![top-running-processes-1](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-00-43-16.png)
To sort the processes by memory usage, Execute the following command:
top -o %MEM |
![top-running-processes-2](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-00-45-25.png.webp)
2. ps command
Unlike top command, which repeatedly displays a list of processes repeatedly, the ps command displays a snapshot of active processes i.e. it does not display the updated information continuously. To run ps command sorted by memory in descending order, Execute the following command:
ps aux -- sort -%mem |
![top-running-processes-3](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-11-44.png.webp)
To sort by cpu, Replace the %mem by %cpu in the above command:
ps aux -- sort -%cpu |
![top-running-processes-4](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-02-18-47.png)
To limit the number of processes using head command, Change the above command as shown:
ps aux -- sort -%mem | head -15 |
![top-running-processes-5](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-18-41-1024x174.png.webp)
To list only specific information about the processes sorted by memory, Execute the following command:
ps -eo pid,%cpu,%mem,cmd -- sort -%mem |
![top-running-processes-6](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-21-33.png)
3. glances command
glances is a monitoring tool that provides maximum information in minimum space. It is written in Python and can also be used for server monitoring and remote monitoring. To install glances, Execute the following command in a terminal window:
sudo apt install glances |
![top-running-processes-7](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-19-16-06-57-1.png)
Run the glances command:
glances |
![top-running-processes-8](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-36-49-1024x847.png.webp)
To monitor the system using a web user interface( web UI), enter the following command:
glances -w |
![top-running-processes-9](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-40-33.png.webp)
Right-click on the given address and open it in the browser.
![top-running-processes-10](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-40-57-1024x545.png.webp)
4. htop and atop command
Though it is similar to the glances command, htop command provides you with more information in a colorful display. To install htop command, Run the following command:
sudo apt install htop |
![top-running-processes-11](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-48-29.png.webp)
Run the htop command:
htop |
![top-running-processes-12](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-48-02-1024x610.png.webp)
Similarly, atop command also displays the system information in a more interactive way, It can also store the output in a file. To install atop, Run the following command:
sudo apt install atop |
![top-running-processes-13](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-52-07.png.webp)
Run the atop command:
atop |
![top-running-processes-14](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-01-55-20-1024x558.png.webp)
5. nmon command
nmon is another monitoring tool that displays all information such as CPU, memory, DIsks, network, kernel, NFS, top processes and resources. To install nmon command, Run the following command:
sudo apt install nmon |
![top-running-processes-15](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-02-04-32.png.webp)
Run the nmon command:
nmon |
![top-running-processes-16](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-02-05-52-1024x639.png.webp)
Press the appropriate keywords as per your needs. Here, It displays the CPU, memory, Disks, resources, kernel, and network information. To find the top running processes, Press t.
![top-running-processes-17](https://cdn.linuxfordevices.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-20-02-07-14.png.webp)
Conclusion
So, We discussed How to find the top running processes by memory and CPU. All the commands almost work similar, only the interface and some information are different. Thank you for reading!
credit: https://www.linuxfordevices.com/tutorials/linux/find-top-running-processes