Avatar A personal blog about technical things I find useful. Also, random ramblings and rants...

Today I Learned: Hiding Commands in Linux History

Use space before passing secrets on command line.

In the world of Linux, keeping your command history tidy and secure can be crucial, especially when dealing with sensitive information. Today I learned an invaluable trick: you can hide a command from your history simply by typing a space before it.

Why It Matters

When working with secrets, such as API keys, passwords, or confidential scripts, the last thing you want is to leave traces of these sensitive commands in your shell history. By using this technique, you ensure that these commands don’t get saved in the history file, reducing the risk of accidental exposure.

all tags