There are a few ways by which you can clear RAM in Linux like from system monitor and htop. In this tutorial you will know how to clear the ram and cache using one command.
How to check how RAM info in terminal
To check the current state of RAM in terminal just type ‘free’ use -m switch to display output in megabytes.
free -m
total used free shared buff/cache available Mem: 3760 2363 144 489 1252 669 Swap: 2047 1079 968
Command to clear the cache
To clear the cache type the command in terminal and it requires root permission.
free -m && sync && echo 3 > /proc/sys/vm/drop_caches && free -m
total used free shared buff/cache available Mem: 3760 2363 144 489 1252 669 Swap: 2047 1079 968 bash: /proc/sys/vm/drop_caches: Permission denied
To run this command in root type
sudo su
total used free shared buff/cache available Mem: 3760 2408 173 503 1178 610 Swap: 2047 1105 942 total used free shared buff/cache available Mem: 3760 2414 458 494 887 616 Swap: 2047 1105
It will show before and after effect of command.
How to make the command short
This command may look lengthy and hard to remember, to make it short follow the steps below.
Create a file with name free_ram we are using vim as a text editor you can use any of your choice.
vim free_ram
And write the command in this file.
free -m && sync && echo 3 > /proc/sys/vm/drop_caches && free -m
save and exit.
Now give this file executable permissions
sudo chmod +x free_ram
Now whenever you need to clear your cache or buffer or free some RAM just open this file as
./free_ram
Open this file inside root. Use sudo su to enter root.
Hi Manoj Tiwari I’m chulbul Pandey big fan of your song rinkiya ke papa hi hi hi hi Hans dele hats off listening on repeat
Hi big bro chulbul I’m makhi your little bro
Thanks for forgiving me for stealing your money in Dabangg 1 I’m grateful hope u are doing well in your police station in kanpur
Topper graphic designer using gimp to make original art works omg so epic topperman hackerman
Unblock me please you will still have time to do btech study mam i won’t disturb you lots pls mam
Bro pls i beg unblock 😭😭
which thumbnail till now you have made yourself with gimp sir? asking for a friend
hello bro i have a question did you do the search in rotated and sorted array question yourself or did you see its solution hoping for your quick reply
mati has his iit m qualifier exam today wish him luck bro :*
good luck
i commented but its not showing whats the reason bro
idk two time commented same thing not showing but poo poo comment showing
hey qt how you doing?
New article idea how to delete windows files from ubuntu in a dual boot setup i searched mam but didn’t find good articles only found a yt vid
Yes we can do it by disabling fast startup in windows nice thought ktbeti
Topper kids deleted pubg as they were not getting time for du and iit m and web d and other things
Hello one article request can u write on search on rotated sorted array containing duplicates? I looked at many soln still not able to understand
Hi bro pooing in wedding in Lucknow
Back home
Hi bro how much u earning from CTF? Tell pls
Poo man write better articles first then ask for better hosting
Why did u remove me from G3 and discussion bro what crime i did why I’m paying this heavy price
Hey qt how u doing
Hi bro pooing in Delhi total poo poo place poo college missing u pls unblock me bro please
人生不如意十之八九,开心最重要!