2 ms·
Where is this true? It was most likely "sudo rm -rf .*" which will actually go BACKWARDS up the tree as well. Edit: At the very least, this doesn't work on
by nyellin 14y ago
Where is this true?
It was most likely "sudo rm -rf .*" which will actually go BACKWARDS up the tree as well.
Edit: At the very least, this doesn't work on OS X 10.5, Ubuntu 10.04 (server edition), and CentOS 5.8. For example:
$ mkdir -p foo/bar
$ cd foo/bar
$ rm -rf ..
rm: "." and ".." may not be removed
- archivator 14y agoDefinitely true on Linux with bash - .* will expand to .. as well as all hidden files/folders.
- Flimm 14y agoThe shell expands .* to all directories beginning with a dot, including the two special hard links "." and ".." . See for yourself by running: echo .*
- deleted 14y ago[deleted]
- mikeash 14y ago'echo .*' and notice how the second entry is .., the parent directory. It won't go up the tree indefinitely, but it will go up one level.
- CrLf 14y agoWell, that happened to me at least once on Linux, ten years or so ago. I don't remember if it goes backwards up the tree or just one level (I think it's the latter), or if the current 'rm' protects against this or not. Imagine you place yourself in '/tmp' to throw away all those pesky '.' directories and files that applications leave there. You run that command, it matches '..' and your whole system is gone (btw, 'rm -rf .??*' avoids this).
- ars 14y agoBoth are true: It will only go up one level, and current rm has protection that will not let it delete the root.
- nikcub 14y ago.* will be expanded by the shell to . .. and all local files beginning with . the BSD version of rm will never remove . or .. see: https://github.com/freebsd/freebsd/blob/master/bin/rm/rm.c#L583 https://github.com/freebsd/freebsd/blob/master/bin/rm/rm.c#L... checkdot is called against all argv: https://github.com/freebsd/freebsd/blob/master/bin/rm/rm.c#L150 https://github.com/freebsd/freebsd/blob/master/bin/rm/rm.c#L... any version of rm that does remove '.' or '..' is not POSIX compliant. The GNU coreutils version of rm does not contain this check: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/rm.c;h=02809f21452c56cef035c653ef1686f1a747bca5;hb=master http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f... (edit: it does - thanks, was running from memory and didn't actually check it)
- caf 14y agoThe GNU version of rm does contain this check - it's in remove.c, not rm.c: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/remove.c;h=f44a9821b6e5f2d43bbcc444893746be2576c3c7;hb=master#l477 http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f...
- orenjacob 14y agoGiven my memory of standard .alias and .cshrc files back then, as well as the studio wide aliases in use, it seems likely the the command someone typed in expanded into.. > /bin/rm -r -f * Running that command from the top of the directory tree where ToyStory2 lives should delete everything below, which would wipe the show.