Stop burying your command history in a pile of junk
Environment & Shell Customization (Aliases/Functions/.Bashrc)
Stop burying your command history in a pile of junk
🧩 The Challenge
You ever go to hit the up arrow and find yourself scrolling through ten variations of ‘ls’ or a dozen mistyped passwords you accidentally pasted into the terminal? It makes finding that one complex find command you ran three days ago a total nightmare.
💡 The Fix
You can actually tell bash to ignore commands that match a specific pattern or start with a space, which keeps your history file clean and useful. It’s saved me from staring at a wall of junk more times than I can count.
HISTCONTROL=ignoreboth:erasedups
HISTIGNORE='&:ls:[bf]g:exit:clear'
⚙️ Why It Works
Setting ignoreboth keeps your history free of duplicates and commands starting with a space, while HISTIGNORE lets you define a colon-separated list of patterns to just drop entirely. Bash sees those and essentially pretends they never happened.
🚀 Pro-Tip: Prepend a single space to a sensitive command and it won’t even show up in your history, keeping your secrets out of the flat file.
Linux Tips & Tricks | © ngelinux.com | 10/13/2026
