Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


.* 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#L...

checkdot is called against all argv:

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...

(edit: it does - thanks, was running from memory and didn't actually check it)


The 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...


Well, 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).


Both are true: It will only go up one level, and current rm has protection that will not let it delete the root.


The shell expands .* to all directories beginning with a dot, including the two special hard links "." and ".." .

See for yourself by running:

  echo .*


'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.


Given 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.


Definitely true on Linux with bash - .* will expand to .. as well as all hidden files/folders.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: