Environment & Shell Customization (Aliases/Functions/.Bashrc)
Stop your shell history from leaking sensitive passwords
đź§© The Challenge
You are midway through debugging a remote DB connection and you type out your password as a flag because you’re tired, forgetting it’s going straight into your .bash_history. I’ve cleaned up more leaked credentials from git repos because of that one-line history file than I care to admit.
đź’ˇ The Fix
Change your bash settings to ignore commands that start with a space and prevent duplicates from piling up. It saves you from yourself when you’re moving fast and making mistakes.
export HISTCONTROL=ignorespace:erasedups
HISTSIZE=10000
HISTFILESIZE=20000
⚙️ Why It Works
Setting the HISTCONTROL variable this way tells the shell to skip saving any line that has a leading space and cleans out the duplicate entries that just clutter up your search results. Bash will then parse these rules before committing anything to disk.
🚀 Pro-Tip: Get into the habit of prefixing your “oops” commands with a space and they’ll never hit the logs.
Linux Tips & Tricks | © ngelinux.com | 10/12/2026
