How to delete a command from the bash history / Hide an command from the bash history

Posted on Sun 14 February 2010 in Linux • 1 min read

Hide an command from the bash history:
Start a terminal and try

wget user:passwd@ftp.example.com/secret.tar.gz; kill -9 $$;

Now you can check your history ;)

How to delete a command from the bash history:
If you have already such an entry, you can use history to delete it.

history
# [...]
# 849 uname -a
# 850 wget user:passwd@ftp.example.com/secret.tar.gz
# 851 ping blog.devnu11.net
# [...]

Now you can delete your history with history -d 850 this line.

history -d 850

And see...

history
# [...]
# 849 uname -a
# 850 history
# 851 ping blog.devnu11.net
# [...]

Or simply add a blank before the command ;)

$  wget user:passwd@ftp.example.com/secret.tar.gz