Site icon New Generation Enterprise Linux

Stop accidentally nuking your production database with rm

Environment & Shell Customization (Aliases/Functions/.Bashrc)

Stop accidentally nuking your production database with rm

🧩 The Challenge

Everyone has had that heart-stopping moment where they type rm -rf in the wrong directory and realize a split second later that they are standing in /var/lib/mysql. It’s a classic rookie mistake that veterans make when they are tired or working on too many servers at once.

💡 The Fix

Turn rm into an interactive command by default so it forces you to acknowledge every single deletion request. It adds a tiny bit of friction to your workflow, but that friction is exactly what keeps your backups from becoming your only recovery path.

alias rm='rm -i'

⚙️ Why It Works

By appending the -i flag, the shell triggers a confirmation prompt before removing any file or directory. Since you are hardcoding the alias in your .bashrc, the shell will always force you to verify the target before anything actually gets wiped.

🚀 Pro-Tip: Use command rm if you really need to bypass the prompt for a legitimate bulk cleanup task.

Linux Tips & Tricks | © ngelinux.com | 11/26/2026

0 0 votes
Article Rating
Exit mobile version