-9

Will rm -rf *.* corrupt your filesystem while rm -rf / will not do this?

9

There's nothing special to it, rm -rf *.* is a command with a filename wildcard, it will recursively remove all files in the current directory that contain a dot in their names.

rm -rf / would give an error about trying to run rm on the root directory. This is mandated by POSIX:

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

Depending on the shell and its settings, *.* might also match .. for the parent directory, but as well as the /, trying to remove that is also an error.

Neither of those will corrupt the filesystem, rm will only (try to) remove files using the usual file system calls. The effect on the system at large, or the user's files, may of course be substantial if the first command is executed in a directory containing important files.

  • for sufficiently new versions of GNU rm (feature originally stolen from Solaris IIRC). Best not cry if your embedded lightweight rm is not compatible with the latest POSIX. – sourcejedi Mar 21 '18 at 15:33

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.