Commands.page Logo

Sort Ubuntu Processes by Memory Percentage Descending

Managing system performance on Ubuntu often requires identifying which applications are consuming the most resources. This guide explains how to quickly sort active processes by their memory usage percentage in descending order using standard command-line tools. By following these steps, you can efficiently monitor RAM consumption and pinpoint heavy processes affecting your system’s speed.

Using the Top Command

The top utility provides a dynamic real-time view of running processes. To sort by memory usage:

  1. Open your terminal.
  2. Type top and press Enter.
  3. Once the interface loads, press Shift + M on your keyboard.

This action immediately reorders the list so that processes using the highest percentage of memory appear at the top. The %MEM column displays the memory usage for each process. Press q to exit the utility when finished.

Using the PS Command

For a static snapshot of processes sorted by memory, use the ps command. This method is useful for scripting or when you do not need an updating view. Run the following command in your terminal:

ps aux --sort=-%mem

The aux flags display all users’ processes with detailed information. The --sort=-%mem argument sorts the output by memory percentage in descending order, indicated by the minus sign. The head of the list will show the processes consuming the most RAM at that specific moment.