Check Linux Memory Usage by Process
The following command can be used in the Linux system to check who is occupying the memory:
- To sort the process list by memory usage and see which process is using memory, enter the “top” command in the terminal and press the M key.
- htop command: If htop is not installed on the system, you can install it by using the following command:
- Install htop using the sudo apt install command on Ubuntu/Debian system.
- After installing on CentOS/RHEL system, type “htop” in the terminal, press F6, select MEM% to display the process list sorted by memory usage.
- ps command: By typing ps aux –sort=-%mem in the terminal, you can display a list of all processes sorted by memory usage from highest to lowest.
- pmap command: Inputting pmap -x
in the terminal allows you to view the memory information of a specific process. - To check the usage and available memory on the system, type the command “free -m” in the terminal.
- The /proc/meminfo file provides detailed information about the system’s memory, including the amount of memory that is currently in use, and can be viewed using the command cat /proc/meminfo.
These are several commonly used methods, you can choose the appropriate way to check who is occupying the memory based on the actual situation.