How to clear RAM memory cache, buffer and swap space on Linux

Sync will flush the file system buffer. Command Separated by “;” run sequentially. The shell wait for each command to terminate before executing the next command in the sequence. As mentioned in kernel documentation, writing to drop_cache will clean cache without killing any application/service, command echo is doing the job of writing to file.

If you have to clear the disk cache, the first command is safest in enterprise and production as “…echo 1 > ….” will clear the PageCache only. It is not recommended to use third option above “…echo 3 >” in production until you know what you are doing, as it will clear PageCache, dentries and inodes.

How to Clear Cache in Linux?

Every Linux System has three options to clear cache without interrupting any processes or services.

  • Clear PageCache only: – Enter below command for page cache

# sync; echo 1 > /proc/sys/vm/drop_caches

  • Clear dentries and inodes:-

# sync; echo 2 > /proc/sys/vm/drop_caches

  • Clear PageCache, dentries and inodes: –

# sync; echo 3 > /proc/sys/vm/drop_caches

Build Your Website with Hostiko

From professional business to enterprise, we’ve got you covered!

Copyright ©2026 QualiSpace. All rights reserved.

A Platform

QualiSpace
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.