I think pretty much people here mistakenly 'rm -rf
'ed the wrong directory, and hopefully it did not cause a huge damage.. Is there any way to prevent users from doing a similar unix horror story?? Someone mentioned (in the comments section of the previous link) that
... I am pretty sure now every unix course or company using unix sets rm -fr to disable accounts of people trying to run it or stop them from running it ...
Is there any implementation of that in any current Unix or Linux distro? And what is the common practice to prevent that error even from a sysadmin (with root access)?
It seems that there was some protection for the root directory (/
) in Solaris (since 2005) and GNU (since 2006). Is there anyway to implement the same protection way to some other folders as well??
To give it more clarity, I was not asking about general advice about rm
usage (and I've updated the title to indicate that more), I want something more like the root folder protection: in order to rm -rf /
you have to pass a specific parameter: rm -rf --no-preserve-root /
.. Is there similar implementations for customized set of directories? Or can I specify files in addition to /
to be protected by the preserve-root option?
rm
command with one that doesn't have that feature. – Keith Jan 20 '13 at 17:40rm -rf *
as root standing at/
, no less; caught it after eating most of/bin
, had to get the machine to a halfways usable state with the few commands left to be able to shutdown and rebuild. Ah, the memories...). – vonbrand Jan 21 '13 at 17:13rm
aliasing torm -i
is worse because it gets in your way all the time, and one way to override it is withrm -f
, so in the end you end forcing users to do morerm -f
. Perhapsrm -I
(GNU)? – njsg Jan 22 '13 at 11:49rm -rf
is an explicit call to recursively delete something (meaning no special case) without further ado and an implementation that contradics an explicit request won't to anything but leave you with a not fully functional OS, or it will teach people another explicit request that can't be contradicted in which case you can start the same discussion over. It's like becoming root whenrm -rf /usr
doesn't work. – Bananguin Jan 22 '13 at 12:59rm -rf
can be a resume generating event. Check and triple check before executing it – midnightsteel Jan 22 '13 at 14:21Resume generating event
is a good expression.. It is new to me actually.. thank you :) – amyassin Jan 22 '13 at 14:27chattr +i
), and you can'trm -rf
it even as root, but you also can't write to it or change it in anyway until you remove the immutable flag. I've used this in the past for various reasons. – Drake Clarris Jan 22 '13 at 20:38