Skip to Content
gnux

--no-preserve-root, --preserve-root

Refuse to recurse on '/' (--preserve-root, default; --no-preserve-root overrides).

An option of rmx.

Usage

rmx --no-preserve-root [FILE]...
rmx --preserve-root [FILE]...

Description

--preserve-root is the default failsafe: rmx refuses to operate recursively on the filesystem root '/'. --no-preserve-root disables the failsafe for the rare, deliberate case where you really do mean to recurse from a root. Use it with extreme care.

Permissions

This is a path check, not a permission check: rmx refuses '/' before it touches the filesystem, regardless of whether you would otherwise have permission. It never grants access you do not already have.

Use cases

  • Left at its default, protecting against a catastrophic 'rmx -r /' typo.
  • Deliberately overridden (--no-preserve-root) only in throwaway or container roots.
  • Guarding scripts where an empty variable could turn a path into '/'.
  • Stating the default explicitly (--preserve-root) in scripts for reviewers.

Details

ShortLongValueDefaultMeaning
--no-preserve-rootnonedo not treat '/' specially
--preserve-rootnonetruedo not remove '/' (default)

Examples

The default failsafe refuses to recurse on the root

rmx -r /

Disable the failsafe (dangerous - only when you mean it)

rmx -r --no-preserve-root /mnt/scratch

State the default explicitly in a script

rmx -rf --preserve-root "$BUILD_DIR/"

The failsafe makes the command fail, which a script can detect

rmx -rf / || echox "refused, status $?"

Help in the terminal

gnux help rmx --no-preserve-root

On this page