Omit commands from history in Linux

- 1 min read

If you’ve ever ran commands on the command line that contain secure or sensitive information you certainly don’t want those commands recorded in your history.

Fortunately *nix provides “1 weird trick to avoid writing to the history.”

When you want to run your SSH/DB/etc command that requires a password or some other sensitive information simply enter a space before your command.

# Instead of
mysql -pSUPERSECURETHING ...

# Do
 mysql -pSUPERSECURETHING ...

Having said this, you obviously want to avoid putting anything secure directly as a command line instruction. However, sometimes it isn’t reasonably avoidable.