Take the 2-minute tour ×

Does "chmod 777 .* -R" chmod parent directories (..) recursively?

share|improve this question

migrated from stackoverflow.com Jan 3 '10 at 21:13

This question came from our site for professional and enthusiast programmers.

-> serverfault? –  elcuco Jan 3 '10 at 21:10
Not sure what your intended result is. If you want to chmod everything from the current directory and down, the chmod -R 777 ., if you want to only . prefixed directories via find . -maxdepth 1 -type d -name '.*' this would still include ., also the .* expands based upon your $SHELL, not all shells will expand .* to . and ... –  Darren Hall Jan 3 '10 at 21:21

4 Answers 4

up vote 12 down vote accepted

Yes. (Learned it the hard way.)

share|improve this answer
Didn't wait too long for an answer there, did you? :) –  jensgram Jan 3 '10 at 21:07
nice to learn! . –  elcuco Jan 3 '10 at 21:09
OUCH! (padding) –  R. Martinho Fernandes Jan 3 '10 at 21:11
You can echo .*, if .. is included in the output, it's probably not the result you're looking for. –  Darren Hall Jan 3 '10 at 21:29
This is true of anything that uses .* - rm -rf .* is particularly nasty. –  James Polley Jan 3 '10 at 22:26


The use of a recursive option(-r) with a wildcard(*) is almost always a bad idea.

if you were trying this:

user@box path/$ foo -r .*

which probably means you also did this first, before realizing it missed hidden files:

user@box path/$ foo -r *

most likely what you wanted to do is

user@box path/$ cd ..
user@box $ foo -r path/

furthermore, chmod 777 is always a bad idea.

share|improve this answer
nice explanation of the problem and a good alternate way of thinking about it that leads to a real solution. –  quack quixote Jan 3 '10 at 22:02
Usually these is no need to cd .. && foo -r prevdirname. foo -r . would usually do the same. –  Chris Johnsen Jan 3 '10 at 22:17
ah, that brings us to another quirk of mine. I never. ever. ever. ever. run something like that, unless it is something harmless like grep. running a command like 'chown foo -r .' in the wrong directory can be disastrous. Going one directory up and typing the name of the directory you really mean to change forces you to pay more attention to what you are doing. –  user23307 Jan 4 '10 at 5:25
@justin: that's the alternate behavior i like. i use foo -r . all the time but i'm very very careful with it. it's still far too easy to forget to check things closely. getting into a habit & attitude of "no -r . ever" is one way to deal with the issue. –  quack quixote Jan 4 '10 at 6:44

Use .??* instead.

share|improve this answer
You also need .[^.] if you want to catch entries like .a. –  Chris Johnsen Jan 3 '10 at 22:06

Use zsh (which does not match . or .. in ANY glob), or use .[^.]* .??* to match all hidden files. The first part of the glob matches any file that begins with a dot and has as its next character something other than a dot, thus avoiding . and .. The second part matches any file that starts with a dot and is at least three characters long.

To match all files other than . and .. hardlinks, use * .[^.]* .??* , or (on Z shell ONLY) . .*

share|improve this answer

Your Answer


