I'm trying to clear the history of commands that have been run on Terminal, I found an article which said I can do it with rm ~/.bash_history

However, I am still able to see the previous commands that I've ran by pressing the up arrow


The correct command is history -c, as shown in the picture below.

history -c

  • 1
    In case anyone is here in 2020+ and is having a brain fart, it's ~/.zsh_history now!
    – Max
    Jun 5 '20 at 15:14
  • As @jksoegaard says, You'll need to close the terminal and open it again - after hitting the command.
    – Sanjeevcn
    Nov 19 '20 at 6:21

An easy way to accomplish this is to close all terminal windows, and then open a single new terminal window, where you run:

rm ~/.bash_history

You'll need to close the terminal and open it again. Now when you press arrow up, you'll only see the rm command, and not earlier commands.

  • 1
    I have used this method without problems. You just need to be aware that your current session's history will be saved when you close it. So close all sessions, and create a new one that will have no history to speak off - then clear the file. You can use history -c to the same effect ofcourse, but again if you have open sessions and close them afterwards, then their previous commands would be saved to history as well.
    – jksoegaard
    Apr 30 '17 at 21:22

I found this on Udemy's Linux Mastery course.

history -r; history -w

history -r removes the terminal history temporarily for the current session. history -w removes it permanently.


You have to write following in terminal step wise: -

  1. cat > .zsh_history
  2. clear
  3. press return ⏎
  4. press Ctrl ^ + D

Then close terminal using Cmd ⌘ + Q and then reopen again.

  • What does this do, especially step 3 and 4?
    – nohillside
    Oct 29 '21 at 5:17
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 29 '21 at 13:26

So what you have to do is:

  • run "rm ~/.bash_history" (without quotation marks)
  • run "exit" command
  • quit Terminal and open it again You can check that your history is cleared by running "history" command. All that should be left is the "exit" command and "rm ~/.bash_history" command.

Hope this helps!

  • 2
    Welcome to Ask Different. This isn't much different than the answers already provided. It would be better if you edit one of the other answers, to add the 'exit' command, instead of creating a new answer with mostly recycled info. - From Review
    – fsb
    Jan 16 '19 at 21:04

You must log in to answer this question.