4 ms·
6-7 years ago, a co-worker was doing some work on a server that we were phasing out. It wasn't being used for anything of critical importance, so a Jr level per
by LordKano 11y ago
6-7 years ago, a co-worker was doing some work on a server that we were phasing out. It wasn't being used for anything of critical importance, so a Jr level person was permitted to have root. He was actually my colleague and equal on the org-chart but he had less experience with *NIX administration.
He was copying directories to the new server and deleting them when he was done. Well...
I don't remember the sub-directory he had just finished copying but when he went to delete it he typed in "rm -rf / SOMEDIR/SOMESUBDIR" and hit enter.
He almost immediately realized what he had done and hit CTRL-C but by that point the damage was done. Our boss had access to the previous week's backups and since the server wasn't critical, he just rebooted it and restored but we had a good laugh about it.
The next day, I made a paper airplane and on the side I wrote in red Sharpie "Linux Air" and then "rm -rf" inside of a red circle with a line through it and taped it to the top of his monitor.
He was a good sport about it and left it up for a couple of months.
- pdw 11y agoThis particular variation was (finally!) fixed in the 2013 POSIX revision: "If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component) or if an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands." http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm... Warning: not yet widely implemented outside the GNU world.
- TheLoneWolfling 11y agoPersonally, I wish two things: 1) that rm had a (configurable) number of files / directories above which it'll ask you to double-check. 2) that files had a "pleasedontdelete" flag that rm would check and ask about.
- Zenst 11y agoYou can script that all up and call it rm and pop it higher up the user PATH and if you need the pure rm command without the wrapper protection (for say scripts) then can just point to that with the full path.
- derefr 11y ago> pleasedontdelete flag For some programs (rm isn't one of them), removing the write permission is sufficient to get an interactive prompt when you try to overwrite/truncate/delete the file. I really like OSX's current metaphor, where files that haven't been touched in a while get "locked", and must then be "unlocked" to modify them further. Phrasing it in terms of stability rather than permission makes a lot of sense to me. It's too bad the metaphor isn't echoed in the CLI.
- alcari 11y ago`rm` is definitely one of them, it's just suppressed by the `-f` flag. (examples from Ubuntu) $ touch foo $ chmod -w foo $ rm foo rm: remove write-protected regular empty file ‘foo’? There's also the immutable attribute many modern filesystems support, which prevents the file from being modified unless the attribute is removed. $ sudo chattr +i foo $ rm foo rm: remove write-protected regular empty file ‘foo’? y rm: cannot remove ‘foo’: Operation not permitted
- ethbro 11y agoThat's a surprisingly good idea for UAC too. People would hate that it's non-deterministic (from "how will my program run on a user's system" perspective), but makes more sense than other approaches. If I'm tapping a file that's been sitting there since the OS was installed and hasn't been touched since... Probably fair to ask me to confirm!
- JoshTriplett 11y ago> 1) that rm had a (configurable) number of files / directories above which it'll ask you to double-check. Install safe-rm; it does exactly that.
- bronson 11y agoNo protection for `rm -rf file.bak ~`? I'd love to know whoever it was that thought tilde was a good character to use in backup filenames.
- placeybordeaux 11y agoA week of stress produced this doozy while attempting to upgrade from go 1.2 to go 1.3 [peter@bamboo-sb bin]$ sudo mv /bin/ /usr/local/bin/go1.3 [peter@bamboo-sb bin]$ sudo mv /tmp/go/bin/ /usr/local/bin/go1.3 sudo: mv: command not found [peter@bamboo-sb bin]$ mv -bash: mv: command not found [peter@bamboo-sb bin]$ ls -bash: /bin/ls: No such file or directory [peter@bamboo-sb bin]$ ls -bash: /bin/ls: No such file or directory [peter@bamboo-sb bin]$ ls -bash: /bin/ls: No such file or directory All during a skype call. It is very recoverable, but I felt quite foolish.