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.

Author

Cody Craven enjoys sharing tidbits of information that he learns through his life-long journey developing websites and configuring web servers.

When at work, Cody can often be found banging his head against his keyboard for hours days weeks-on-end trying to solve technical issues that would otherwise prevent his teammates from creating Member value at AAA.

All content that Cody contributes to this site are his own ideas and do not necessarily represent AAA's positions or opinions.