BASH Memory
From Indie IT Wiki
Revision as of 14:41, 12 December 2020 by imported>Plittlefield (→Installation)
HOWTO: INFO:
Display True Memory Usage
Most people use the free command to show RAM usage, but read it wrong. In the example below, it looks like the computer only has 67 MB available. However, Linux keeps data stored in RAM when reading disks and some more for programs just in case they need it, effectively being greedy for better performance.
What the Linux system is actually using or needs to use is shown on the 3rd line!
free -m total used free shared buffers cached Mem: 4049 3982 67 0 16 3530 -/+ buffers/cache: 435 3614 Swap: 6142 53 6088
So, a slightly tweaked command would be...
free -m | awk 'NR==3 {print $4 " MB free."}' 3614 MB free.
(The above command for awk translates to "print 4th column of third line" :-)
Thanks to Thoughts by Clag G.
HOWTO: INSTALL:
ps_mem
Installation
cd /tmp/ sudo wget https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py sudo install -m 755 ./ps_mem.py /usr/local/bin/psmem sudo psmem
Python 3
sudo nano /usr/local/bin/psmem #!/usr/bin/env python3 psmem
Usage
sudo psmem sudo psmem | grep -E thunderbird
For more information see the GitHub page, and thanks to Epety ET.