Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>I'm pretty sure that means it won't do anything

Assuming an rm without the "-preserve-root" default, it would remove everything that it had permission to. So, eventually, for example, it would wipe your home directory.

I suspect this to be the case for OSX, Alpine Linux (or other distros that use busybox), probably some of the BSD distributions, etc.



  $ uname -sr
  FreeBSD 11.1-RELEASE

  $ rm -rf /
  rm: "/" may not be removed
No idea about other BSDs.

Busybox's rm is indeed happy to nuke /.


Also:

  $ uname -sr
  OpenBSD 6.1
  
  $ rm -rf /
  rm: "/" may not be removed


The latest POSIX standard actually requires this behavior:

If […] an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands.

Source: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm...




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: