← All articles

What happens if you run rm -rf on a production server?

rm -rf on the wrong path can delete your entire system in seconds. Recovery is hard—backups, snapshots, and approval-before-run on AI tools are how operators prevent it.

Running rm -rf on the wrong directory can destroy a production server in seconds. Recovery depends entirely on snapshots and backups you made before the mistake—not on undelete tools.

What rm -rf actually does

  • -r — recursive into every subdirectory
  • -f — no prompts, ignores missing files

One typo—rm -rf / var/log instead of /var/log—can start deleting from root.

Real-world scenarios

MistakeResult
rm -rf /* as rootSystem gutted; instant outage
Wrong deploy pathApplication + releases gone
rm -rf on mounted volumeDatabase or upload data lost
AI-suggested “cleanup”Over-broad glob deletes live files

If it just happened

  1. Stop writes — kill runaway process if still deleting
  2. Do not reboot hoping it fixes things
  3. Provider snapshot — restore to point-in-time if available
  4. Separate backups — S3, restic, DB dumps off-box
  5. Document for postmortem—how did the command get approved?

Prevention (operators)

  • Snapshots before risky maintenance
  • Least privilege — daily work not as root
  • Trash tools for interactive shells
  • alias rm='rm -i' on jump boxes (not a silver bullet)
  • Read-only checks firstls, du, find dry-run

Prevention (AI on servers)

ChatGPT will suggest rm commands you paste manually. Autonomous agents may run them.

Ohuriya AI is an AI DevOps Copilot built for VPS owners: every shell command appears on a card and nothing runs until you approve. That is how you catch / in the path before it executes.

Read: approve-before-run · safe production commands mindset

Quick answers

Can you recover after rm -rf on /?

Usually no—not from the running system. Restore from a provider snapshot, backup, or reinstall and recover data from separate volume backups. Act fast and stop writes.

Why do AI tools make rm -rf incidents more common?

Autonomous agents and copy-paste from chat can run destructive commands without a human reading the full path. Approval-before-run and read-only checks first reduce risk.

What is safer than rm for cleanup?

Use trash-cli, delete named files explicitly, run ls first, and use find with -delete only after a dry-run find. Never alias rm to rm -rf on servers.