Raspberry Pi

How to Find Top Running Process by Highest Memory and CPU Usage in Raspberry Pi

In a device with small storage space or RAM such as Raspberry Pi, users always have to stay conscious about what they are storing and how large it is, because this all can greatly affect the device’s performance. Usually, Raspberry Pi users stay vigilant about the space on the disk but they tend to forget that it’s not only the data that occupy the space but the system processes also occupy the space on memory and CPU. Though there are different processes running in the background and finding those consuming the highest memory and CPU utilization is difficult for someone.

If you are having trouble finding the information of a process consuming the highest memory and CPU usage on the Raspberry Pi system, follow this guide to learn about different commands for this task.

Finding Top Processes by Memory and CPU Usage in Raspberry Pi

The commands to find the top running process are mentioned below, go through each of them one by one and choose your best fit:

Command 1

The first command on our list is the ps aux command which displays the overall process report with PID (Process Identification) number, memory usage, CPU usage and other important details:

$ ps aux

Command 2

If you are not interested in all the details and you only want to display the top most processes that are consuming memory and CPU then you can use the below-mentioned command to get a straight forward output with only memory and CPU usage amount:

$ ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

Command 3

Lastly, if you want to display the processes in such a way that they are sorted on the basis of memory usage then run the below-written command:

$ ps aux --sort -%mem

You can also do the same for CPU usage too, just replace %mem with %cpu in the above command:

$ ps aux --sort -%cpu

Conclusion

There are three commands which can be used to display the top running processes based on highest memory and CPU usage. The syntax and purpose of each are discussed in the above-mentioned guidelines; Users can opt for any of these.

About the author

Zahra Zamir

An Electronics graduate who loves to learn and share the knowledge, my passion for my field has helped me grasp complex electronics concepts and now I am here to share them with others.