News for hackers. Stuff that matters.
Re:How do I prevent accidental rm -rf /*? by DanielRibeiro on Saturday December 03, 2011 @04:15PM (#3308854)
Better yet: don't remove things. Move them to a folder. My rm is aliased to a 'mv to a trahs folder' function. I have aliased rrm for real rm.

Guis know this, but somehow this piece of UX is forgotten on command line tools.

Re:How do I prevent accidental rm -rf /*? by makecheck on Saturday December 03, 2011 @04:25PM (#3308889)
It's really more effective to have a very regular backup (e.g. ".snapshot" directories are really nice), because you can't control all the ways a file may be deleted.

Just because you protect one "rm" command doesn't mean there isn't another. Someone might have used unlink() in a Perl script or a C program. Maybe "mv" was used to write one file over another, or "cat >! filename", or a dozen other things.

In the end, if a file needs to be safe then it needs a backup (and the sooner it can be restored, the better). And then given a good backup the file still needs an appropriate Unix group, owner, file access control list, etc. to minimize the chance that you'll ever need the backup.

Re:How do I prevent accidental rm -rf /*? by philh on Saturday December 03, 2011 @10:23PM (#3309750)
Note that 'sudo rm' doesn't care about your aliases. It would be safer to replace the binary.
Re:How do I prevent accidental rm -rf /*? by re_todd on Sunday December 04, 2011 @12:20AM (#3309939)
Cool idea. I usually move folders and files to the /tmp/ folder instead of deleting them. The next time I boot up, they are gone.
Re:How do I prevent accidental rm -rf /*? by billswift on Sunday December 04, 2011 @03:35AM (#3310237)
The problem with using /tmp is that you may not realize something critical has been deleted until you reboot. Using an explicit trash or backups folder is safer.
Re:How do I prevent accidental rm -rf /*? by derleth on Sunday December 04, 2011 @12:24AM (#3309943)
> somehow this piece of UX is forgotten on command line tools

Because command line tools were first, and are used by people who do need to remove files, to clear disk space.

If you're never deleting anything, how do you clear disk space?

Re:How do I prevent accidental rm -rf /*? by billswift on Sunday December 04, 2011 @03:18AM (#3310205)
Use a script to alias rm to a mv command. Then to really delete something explicitly use /bin/rm.