Server Side

Server related posts

Clearing the Bash History

Written by: Peter Fisher on July 18, 2012
Tagged under: ,
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Linux penguin Tux

The Linux penguin is called Tux. He is the official mascot of the Linux kernel. Tux was originally created by Larry Ewing in 1996

In a recent post I discussed how to search and run a command stored in the bash history. I mentioned that the history file can get quite large and after awhile you may want to clear it down. Maybe you want to see only the commands that you have recently used or maybe your just doing some house keeping. In any case deleting the contents of the bash history is pretty straight forward.

To delete the bash history simply type the following in a terminal:

history -c

The -c flag will clear the contents of the history which is stored in RAM

I also mentioned in my previous post that the contents of the history utility is stored in the file:

~/.bash_history

You can delete this file and all its contents by typing the following in the terminal:

rm -rf ~/.bash_history

In the example above the rm command (remove) will delete the .bash_history file.  The rm command has the -r flag which means that it will recursively remove any sub directories that it has found (if any). The -f flag forces any removal without user interaction (as long as the -i flag is not supplied)

In this post I have shown how to remove the contents of the bash history which is stored in RAM and which is stored in the history file.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Peter Fisher is a web developer working in Gloucester UK. Founder of the digital agency Websomatic, author of this blog and the HowToCodeWell Youtube channel. Peter has over ten years of web development experience under his belt

Read all about Peter Fisher

Leave a Reply

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