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:
>~/.bash_history
Another option is link ~/.bash_history to /dev/null:
ln -sf /dev/null ~/.bash_history
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop














{ 18 comments… read them below or add one }
Hi !
The sintax is wrong, it shoud say:
ln -sf /dev/null ~/.bash_historyor else you would be pointing /dev/null to bash_historygreat site !!!
Thanks for the heads up!
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 ;)
history -c
u rock man…………….
Its great yaar. command working cool.
history -c works! Thanks
thank’s man
lol and it’s that easy… Nice one.
So simple!
ln -sf /dev/null ~/.bash_history
It is also good
but why take long, When there is already shortcut
history -c
Best Command
Simply use bellow command to clear history
>history -c
The idea behind clearing history is that nobody know it is being cleared. This is the command that does it
——
history -d $((HISTCMD-1)) && history -c
——
great yaar its too much good & easier
>history -c
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
Regards,
Prashanth D
history -c command delete history on temporary basis not permanently after reboot deleted history comes back
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
or use “history -cw”