DEV Community

loading...

I finally have done it (without sudo) - the catastrophic command

patarapolw profile image Pacharapol Withayasakpunt ・1 min read

I mistaken rm -rf /* for rm -rf *; and didn't backup. I Ctrl+C after a while though, but

  • Fonts and Pictures are gone
  • ~/.ssh is still there
  • No, I don't have any important files that aren't somewhere else. I can easily reinstall Ubuntu

Talking about prevention

  • How do I periodically backup?
  • How do I have stricter permissions / ban command combinations?

Discussion (5)

pic
Editor guide
Collapse
louy2 profile image
Yufan Lou

I have found that I never use rm -rf * in the first place. Either I don't need the folder so I get out and remove it without the glob, or the clean up procedure is part of a build script that I don't manually type out.

But habit can't prevent one-shot brain shorts so here is a Server Fault question: How do I prevent accidental rm -rf /*?

Collapse
thefern profile image
Fernando B 🚀

I would recommend to put Clonezilla in a usb stick, install ubuntu out of the box, install whatever software you like, adjust settings, etc, then backup your system. There are also snapshot like tools like timeshift, but I personally never used it before. Clonezilla is easy to use, I backup my system manually every two months.

github.com/teejee2008/timeshift
clonezilla.org/

Not sure if you can completely disable that one command, but a good idea is to add rm -rf * to an alias, so you don't mistakenly type /*

Collapse
ctrleffive profile image
Chandu J S

I use timeshift for backup

Collapse
yujiri8 profile image
Ryan Westlund

zfsnap for ZFS or snapper for BTRFS are good.

Collapse
patarapolw profile image
Pacharapol Withayasakpunt Author

I am on ext4.

If I had to reinstall Linux, what should I choose?