Stop piping secrets into your command line history
Shell Scripting / Bash Tricks
Stop piping secrets into your command line history
🧩 The Challenge
You know the drill, you’re trying to quickly test a database connection or curl an API and you accidentally paste the production password right into your terminal. Now it’s sitting in .bash_history for any nosey admin or local script to scrape later.
💡 The Fix
Use a leading space before your command to keep it out of the history file entirely. It saves you the headache of scrubbing your history logs after every sensitive operation.
command_name --password-flag="supersecret"
⚙️ Why It Works
Most modern shells like Bash and Zsh are configured by default to ignore lines that start with a space, assuming your HISTCONTROL variable is set correctly. Check your environment, but once you get in the habit of hitting space first, it becomes second nature.
🚀 Pro-Tip: Run ‘echo $HISTCONTROL’ to verify ‘ignorespace’ or ‘ignoreboth’ is active before you trust it with your secrets.
Linux Tips & Tricks | © ngelinux.com | 9/3/2026
