How to Clear RAM Memory Cache, Buffer and Swap Space on Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

81 Responses

  1. Md Rizwan says:

    How can i create swap size in already running server?

  2. Saurabh says:

    This worked a treat for me.. thanks guys

  3. dantou says:

    Bizarre. Am the only one for whom none of the listed commands works? Is this space between the terms?

    Because if I copy the first command, either: “sync; echo 1> / proc / sys / vm / drop_caches

    I get: “bash: /: is a folder” and that’s it!
    Thank you for correcting me.
    Sincerely, Dan.

    • Gary says:

      Definitely no spaces after first forward slash. I would probably put a space between 1> , but not sure it is required.

  4. taneer says:

    echo "echo 3 > /proc/sys/vm/drop_caches" not sure about this command

  5. Venkatesh says:

    Before going to shut down or reboot production server , what are the required steps before to perform. Could you please explain with commands with examples.

  6. Aniket says:

    Very useful… Thank you very much!!

  7. Cae says:

    Quote from the Article:

    > At the same time scheduled script run and clears everything in cache.
    > Now all the user are fetching data from disk. It will result in server crash and corrupt the database.

    WHAT??? If this were a true statement, then you would get server crashes and corrupted databases upon first boot or reboot of the server. This obviously is not the case. Worst case you’ll have increased response times, or server timeouts. This untrue statement unfortunately detracts from an otherwise informative article.

  8. Angelo says:

    How can I stop or remove the echo 1 because its running

  9. mandar says:


    When i try to create .sh file with given contents, its showing error as bash: ./ /bin/bash^M: bad interpreter: No such file or directory

    • prashant kumar says:

      Use file format use command dos2unix as above file is in DOS format.

    • Ravi Saive says:


      Seems like you have a dos line ending file. The clue is the ^M.

      You need to save the file using Unix line endings, for example – open your script with vi/vim editor and then hit (key ESC) and type this:

      :set fileformat=unix

      If you have a dos2unix command line program that will also do this for you.

  10. Md Sameer says:

    Thanks to provide such a great article.

    I am having one doubt about echo 3 if I use "echo 3" in my production environment to clean buffer cache. Any impact of above command in os RAM ? Will it delete useful data of physical RAM ?

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.