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
