"rm" command defaults "--preserve-root" option?

They say rm command defaults to the option --preserve-root. Is that right?

Otherwise I should put the line

alias rm='rm --preserve-root'`

in ~/.bashrc to make that option happen without typing it every time I run the rm command. To confirm this I ran type rm, and got rm is hashed (/bin/rm).

I expected rm is aliased to rm --preserve-root. Does anyone know what's going on with the rm command?


Solution 1:

rm is not being aliased to rm --preserve-root, but the option is selected by default in the rm binary.

From the manpage of rm in Ubuntu 17.10, you can find the following details of the --preserve-root and --no-preserve-root options:

   --no-preserve-root
          do not treat '/' specially

   --preserve-root
          do not remove '/' (default)