Linux – What does rm –preserve-root prevent exactly

linuxrm

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 *

or

rm /*

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

Best Answer

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

but

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

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

Related Question