> The command that had been run was most likely ‘rm -r -f *’, which—roughly speaking—commands the system to begin removing every file below the current directory. This is commonly used to clear out a subset of unwanted files. Unfortunately, someone on the system had run the command at the root level of the Toy Story 2 project and the system was recursively tracking down through the file structure and deleting its way out like a worm eating its way out from the core of an apple.
As a linux neophyte, I once struggled to remember whether the trailing slash on a directory was important. So I typed "rm -rf", and pasted the directory name "schoolwork/project1 " (with a trailing space), but then I waffled and decided to add a trailing slash. So I changed it to "rm -rf schoolwork/project1 /".
One feature I've always wanted is to make a directory non-deletable without otherwise changing the directory's functionality. So if I do "rm -rf ~/work" I don't lose anything, but I can still do "touch ~/work/whatever". As far as I know, this is impossible.
You don't actually need write access to a file/directory to delete it. You only need write access to the parent (removing or adding a file modifies the container, not the contained).
Remove write access to the parent directory, while keeping traversal and read rights, and you'll be sorted.
So don't put the stuff you want to protect this way in your home directory, but somewhere else, and symlink the relevant directories to your home directory.
If I remember correctly, they were using Solaris at the time, and I know for sure that Solaris did not have this safety net, nor did Linux at the time. The requirement of --no-preserve-root was introduced almost a decade later.
it's one thing to shoot yourself in the foot, but without safe-rm you (or someone else less cautious) will eventually fire the accidental head-shot. it's happened to me a couple times; but never again since I started using safe-rm everywhere.
I have totally never done that. If I had done that, I might have been saved by a lack of permissions. Like if I was on a mounted external drive, so not in my home directory and it didn't get too far.
Edit: What would have been much more worse, if I had done it, would have been
This is why I never use bash for scripting, and opt for Ruby instead.
You can use the `Pathname` class to treat paths as objects, which you can concatenate only valid paths with. Aside from obviously all the other sanity-saving features.
Same. Ruby isn't my preference, but I avoid bash scripting whenever possible. I see very little need to use it when practically every machine requires Python, Ruby, and other high-level dynamic languages as pre-requisite for some basic software that's included by default. I respect bash, but it's from a bygone time. Why deal with the esoteric one-character test operators, the nitpicky spacing issues, etc? Use modern, readable, testable code. So much nicer and easier to read and work with that way.
I'd love to see someone deploy a Python or Ruby-based shell. I'm sure these are available, but they're not widely used.
Bash may be worse than Ruby or Python for scripting, but it's far better as an interactive shell.
And I'm quite happy not having shell use hold back evolution of Ruby or Python, and not having drama like Ruby 1.8 -> 1.9 or Python 2.x -> 3.x affecting shell use.
Or, maybe you forget which directory you are in, and delete the wrong one that way: `rm -rf ../*` when you think you're in `/mnt/work/grkvlt/tmp` but are actually in `/mnt/work/grkvlt` at the time.
Safe shell coding tip #10451: Variables containing directories always have to end in a slash, and paths may never be built using variables and slashes.
> The command that had been run was most likely ‘rm -r -f *’, which—roughly speaking—commands the system to begin removing every file below the current directory. This is commonly used to clear out a subset of unwanted files. Unfortunately, someone on the system had run the command at the root level of the Toy Story 2 project and the system was recursively tracking down through the file structure and deleting its way out like a worm eating its way out from the core of an apple.