Monday 6 June 2016

fun with recursive chown and dotfiles

 rm -rf .*  
removes all hidden subdirectories and their contents, but generates an error and does nothing when it tries to remove '.' and '..'
I've always just accepted that behaviour without thinking. I now discover that it's the wrong thing to do. I discovered this by doing
 chown -R codehare:codehare .*  
This has a very unexpected effect. A very bad, very unexpected effect. It chowns everything that matches .* (i.e. hidden directories) in the current directory, then it starts in the parent directory and recurses through all subdirectories of that. This is not good news. Especially if you do it as root/sudo. Especially if you do it in a home directory. Especially if you use key based authentication.

Well that was a fun start to the week...

No comments:

Post a Comment