Stop your shell from guessing the wrong directory when you mistype
Environment & Shell Customization (Aliases/Functions/.Bashrc)
Stop your shell from guessing the wrong directory when you mistype
🧩 The Challenge
We have all spent years hitting backspace like maniacs because we typoed one letter in a long directory path. It’s infuriating when you just want to get to work and the shell keeps acting like you don’t know how to spell.
💡 The Fix
Enabling the shell’s built-in directory autocorrect will silently fix those annoying slips for you. It saves you from that constant “no such file or directory” headache.
shopt -s cdspell
⚙️ Why It Works
Setting this shell option tells bash to automatically correct minor spelling errors in directory names when you use the cd command. It handles swapped characters, missing letters, or accidental transpositions without you needing to lift a finger.
🚀 Pro-Tip: Stick this in your .bashrc now and thank yourself the next time you fat-finger a path.
Linux Tips & Tricks | © ngelinux.com | 8/8/2026
