On any modern system it's actually "sudo rm -rf / --no-preserve-root" and then entering your password while staring at the command.
"rm -rf ~/blue /" will not come close to deleting / unless you are in the habit of running every command as sudo, even ignoring the presence of --no-preserve-root
Much, much, much the worse is "rm -rf ~ /blue". I don't give a crap about 99% of the stuff outside of $HOME, but of course, the stuff in $HOME is the stuff that's trivial to destroy.
You're missing the point:
$ cd dir where there are source files and temp files
$ rm *.tmp # or so you think
'.tmp not found'
# too bad
Re:Count to ten when a plane goes down
by daurnimator on Monday July 21, 2014 @08:21PM
(#8066820)
Except when: (these are terrible lessons to learn)
1. You type it into the wrong system (D'oh)
2. You have run `mount --bind / /somewhere/else` then `rm -rf /somewhere` a week later
:(
Re:Count to ten when a plane goes down
by colanderman on Tuesday July 22, 2014 @11:04AM
(#8069337)
It boggles my mind that --one-file-system is not the default :/
Re:Count to ten when a plane goes down
by daurnimator on Tuesday July 22, 2014 @01:44AM
(#8067533)
> Not really, a lot of novice unix users are of the habit of removing files with -rf switch. I cringe everytime I see it.
Every few days I remind myself of this.... then I have to delete another directory with a git repository in it, and end up add the -f in again
I run into this all the time, too. Now my -rf usage is almost always wrapped by this:
rmgit()
{
git status
read -p "Are you sure? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm .git -rf
fi
}I think this would be a bit better for interactive cases. Note: written just now, I haven't actually felt the need for this safeguard... yet.
rmrf()
{
(echo "The following files are going to be deleted!!!"
for FILE in "$@"; do
echo "<<<" "$FILE" ">>>"
done) | less
read -p "Are you sure? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm -rf "$@"
fi
}
Re:Count to ten when a plane goes down
by colanderman on Tuesday July 22, 2014 @11:02AM
(#8069329)
Doesn't help against network filesystems mounted in subdirectories. --one-file-system (which really ought to be the default) prevents this.
Re:Count to ten when a plane goes down
by mandalar12 on Tuesday July 22, 2014 @02:49AM
(#8067650)
What would be the "good" alternative ? I often tries "rmdir" or "rm -r" if the directory is not empty and very often there are some "protected files" so I add -f.
Thus it happens that I directly lauch "rm -rf".
Watch it fail first, verify that the failure makes sense, check to see if there's a way to delete one file with -f before deleting the rest with -r. Use -rf only as a last resort, and only by appending the f to an already-failed command whose syntax you've validated.
Re:Count to ten when a plane goes down
by artursapek on Monday July 21, 2014 @09:45PM
(#8067068)
More easily, "rm -rf ~" with a premature "Enter"
do the -rf after the directory to avoid this in future
Premature enter just results in:
[web@server /]$ rm ~
rm: cannot remove `/home/web': Is a directory
Hehe, I did something like that once, except that I typed "rm -rf ~ /blue/". There was no /blue/, but I managed to wipe out my home directory, and I did not have a backup. :-|
It was on my personal machine, so at least I did not delete anybody else's files, but I still got burned hard enough to learn a valuable lesson.
The command "rm -rf ~/blue/" is just a single space key from being equivalent to "rm -rf /" with "rm -rf ~/blue /"