How to delete command lines from the bash history

And suddenly it happened again: I’ve typed sensitive information (at this time it was a password) into the command line.

And the shell kindly saved the typed commandline into its history. This way it wants to help me if I need the same command line later again. Great!

But what happens, if the system I’m working on isn’t under my full control? Imagine I’ve worked on a customer system …

Or what if someone later looks over my shoulder while I’m searching through my history?

The sensitive line needs to be removed!

  • What’s the best way for doing this?
  • How do we protect ourselves from this happening again later?

Generally speaking: You have two options to remove command lines from the bash history: first, by using the history command and second, by editing ~/.bash_history directly.

Continue reading »