[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Suggesion: rm: --preserve-root should be even more paranoid

From: Andrey Maykov
Subject: Suggesion: rm: --preserve-root should be even more paranoid
Date: Wed, 1 Dec 2021 01:42:54 +0600

Hello. Someone just recently made a post on reddit( about adding an accidental
space in a path to the command line and running `rm -rf XXX /*/*`. Before
that, the bumble bee install script did `rm -rf /usr` by accident( and I
also made the same mistake at some point while learning linux.

Maybe rm should have either a new mode for everyday use, like
--preserve-root=paranoid or even be paranoid in the default mode

I suggest that before deleting any file rm should quickly check if path
names seem suspicious, and if so, then stop completely. Suspicious can be
defined as "a path matches /XXX, i.e. a path starts with / and it's the
only forward slash in the path" and  "a path matches /usr/XXX, i.e. it
starts with /usr/ and has no more forward slashes'': people rarely intend
to nuke /bin, /dev, /etc, /usr or /usr/bin, so catching it seems very
useful if you/package maintainer makes a typo and it's only slightly
annoying for people who actually need to break the file system.

As of right now, the default option --preserve-root=all, while preventing
`rm /`,  doesn't prevent accidental `rm /*`

reply via email to

[Prev in Thread] Current Thread [Next in Thread]