Home Linux Commands How to Find Top Running Processes by Memory Usage

How to Find Top Running Processes by Memory Usage

Linux is the top choice of an operating system when it comes to server-based systems. System administrators and even advanced users of Linux have a good deal of knowledge of the command line and know specific commands or specific arguments to certain commands, to get the job in hand done.

Not only for servers but also for regular desktop usage, it is quite handy to know the processes and programs which are consuming the most memory. This gives an idea of the system resource usage and the user can then take appropriate action to free up the memory.

We will use the top command-line utility, which is a task manager in Unix and Linux systems that shows all the details about running processes. When executed without any argument, top shows all the Linux processes by their CPU usage, shared and private memory usage, etc. in percentage.

$ top
Show Linux Processess
Show Linux Processes

Note that it shows the output in an interactive format and not simply print the output. The column '%MEM' is showing the memory usage of each program.

Find Processes Using Highest Memory Usage

To show the most memory consuming processes, we make use of the '-o' flag at the top to sort the output.

$ top -o %MEM
List Processes with Highest Memory Usage
List Processes with Highest Memory Usage

The output of the top command is real-time; i.e. if there is a change in memory or resource usage for any program, the output will immediately show the changed values in the interactive output.

Find Top 10 Processes Using Highest Memory Usage

To get the top 5 or top 10 largest memory consuming processes from this output, we can simply pipe the output to command ‘head‘, which will display only the first ‘n’ rows of any output.

$ top -o %MEM | head -n 15
Find Top 10 Linux Processes Using Highest Memory
Find Top 10 Linux Processes Using Highest Memory

Note that the summary of resource usage is displayed at the beginning; hence 7 rows of those are considered by ‘head‘ and we can see 8 processes in the output. The user should thus enter the number as ‘required processes to see’ plus 7.

For example, If the top 15 processes are to be seen, he should pass the argument as 22.

Conclusion

In this article, we have seen how to find the top running processes by memory usage in Linux, using the top command-line utility. Make sure you check out the manual page of the top using ‘man top‘ to learn more about the command.

If you have any questions or feedback, let us know in the comments below!

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.