Modern rm by default has the --preserve-root option enabled, but what exactly does this prevent?

I understand it will prevent rm -r / (right?)

but does it prevent

cd /
rm *


rm /*

for example? The man page and help are not clear, annoying for such an important and dangerous command.


You can try it yourself with -i so nothing gets deleted.

rm -ri /
rm: it is dangerous to operate recursively on '/'
rm: use --no-preserve-root to override this failsafe


cd /
rm -ri *
rm: descend into directory 'bin/'?

Note that the second would not delete files and directories that match the /.* glob.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.