5

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

5

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

history -c

1

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.

  • I have just tried it, and this doesn't work :( – paper1111 Apr 30 '17 at 10:51
  • 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
-1

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!

  • 1
    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 at 21:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .