Last Updated: February 25, 2016
·
388
· weaselkeeper

rm -rf * / <oops>

sudo touch /%nodelete
sudo touch /.%nodelete
sudo chattr +i /%nodelete
sudo chattr +i /.%nodelete

now, if you rm -rf * / accidentally, it will fail on the /%nodelete and /.%nodelete file giving you a chance to recover from your extra space oops.

Only works on filesystems with chattr functionality, and if you are using other than LANG_C you might have to choose another symbol rather than % as a leading character, you want whatever char shows up first in the charset.