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
🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.
🐧 19 comments so far... add one ↓
🐧 19 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Hi !
The sintax is wrong, it shoud say:
ln -sf /dev/null ~/.bash_history
or 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”
DO NOT enter
>~/.bash_history
It will re-run all the commands in the history, which is extremely dangerous!!