Linux / UNIX: Clear bash history

Posted on in Categories , , last updated February 17, 2009

Q. I’m using CentOS Linux server and how do I clear bash history in UNIX / Linux / BSD operating systems?

A. Type the following command to clear your bash history:


Another option is link ~/.bash_history to /dev/null:
ln -sf /dev/null ~/.bash_history

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

19 comment

  1. 1) Another option is link ~/.bash_history to /dev/null:
    ln -sf /dev/null ~/.bash_history

    2) The sintax is wrong, it shoud say:
    ln -sf /dev/null ~/.bash_history

    both these look identical to me!
    tell u what tho, it is syntax and NOT sintax ;)

  2. Hello All,

    I am using Putty Interface to connect to Linux server in windows machine. I want to de-activate UP Down arrow key or remove the history stored in these up down arrow key. Is it possible?

    Note : I don’t want to remove the entire history stored in ~./bash_history

    Prashanth D

  3. ok guys had a go too

    history -c knocks all out but as Raj says it comes back after reboot
    to make it stick you need to run history -w afterwards

    so :

    to remove all

    history -c then history -w

    to remove one line same principle

    history -d 345 then history -w

Leave a Comment