The ps_mem is a command line tool for checking RAM usage for a programs. This tool calculates the amount of RAM (private memory + shared memory) being used by each program. Python interpreter is rquired to run the ps_mem tool.
This tutorial demonstrates how to install ps_mem on Ubuntu 20.04.
Download ps_mem script from GitHub repository to the
sudo wget -qO /usr/local/bin/ps_mem https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py
Set execute permissions for a file:
sudo chmod a+x /usr/local/bin/ps_mem
ps_mem command can be used all users as a system-wide command.
We can check ps_mem version:
If you are receiving an error message
/usr/bin/env: 'python': No such file or directory, you need to create a symbolic link for
/usr/bin/python. In Ubuntu 20.04, only Python 3 is installed by default.
sudo ln -s /usr/bin/python3 /usr/bin/python
ps_mem command without any arguments:
You will get memory usage of each program. A part of the output of a command:
Private + Shared = RAM used Program 212.0 KiB + 94.5 KiB = 306.5 KiB atd 308.0 KiB + 79.5 KiB = 387.5 KiB agetty 308.0 KiB + 144.5 KiB = 452.5 KiB cron ....... 8.6 MiB + 3.9 MiB = 12.5 MiB systemd (3) 14.0 MiB + 475.5 KiB = 14.5 MiB multipathd 44.1 MiB + 87.5 KiB = 44.2 MiB snapd --------------------------------- 151.8 MiB =================================
A list is sorted by RAM usage from the smallest to the largest.
If you decide to remove ps_mem, run the following command:
sudo rm -rf /usr/local/bin/ps_mem