Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I recursively execute chmod or chown for hidden files?

sudo chmod -R 775 * does not work on hidden files.

The same thing goes for sudo chown -R user:group.

share|improve this question

migrated from Oct 12 '11 at 13:12

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

up vote 24 down vote accepted

If you're okay also chmod'ing the current directory, do that and let -R do the heavy lifting. -R does not ignore hidden files.

sudo chmod -R 775 .
share|improve this answer
This (* .*) is not the safest way to do it. Particularly, it would recurse into parent directory, which means it chmods also siblings of the current directory. The proper way would be * ..?* .[^.]* or, even better (considering the wildcards might not match any files) $(ls -A). – jpalecek Oct 12 '11 at 13:34
@jpalecek: The output of ls is unparseable; trying to parse it is asking for trouble. The proper approach is to use shell globbing. – Scott Severance Dec 11 '11 at 17:58
Even though in linux you have the ability to change the order of args for chmod, when doing x-plat scripts between linux and OS X, this is the order you should use, e.g., sudo chmod 775 -R would go belly-up, so stick to this answer. – kayleeFrye_onDeck Jun 17 at 18:30

* doesn't include hidden files by default, but if you're in bash, you can do this with:

shopt -s dotglob

Read more about it in bash's builtin manual:

If set, Bash includes filenames beginning with a `.' in the results of filename expansion.

This will make * include hidden files too.

chmod -R 775 *

Disable it with:

shopt -u dotglob
share|improve this answer
How to do that in zsh ? – nothing-special-here Oct 25 '14 at 13:57
You use the (D) globbing qualifier, e.g. chmod -R 775 *(D) – slhck Oct 25 '14 at 14:39

Another option is to use find i like it since you can have very fine grained control over it.

find <path to start from> -exec chown <options> {} \+

find -path '<path to include>' -exec chown <options> {} \+

The only downside is that find has different syntax on different versions.

share|improve this answer

All files in the current directory, recursively, including hidden files:

chmod 755 -R ./* ./.[!.]*

All files in the current directory, not recursively, including hidden files:

chmod 755 ./* ./.[!.]*

This will not change an exception filename starting with 2 dots, as example, "./..thisonescapesunharmed.txt"

Also, be carefull not to remove the "x" bit, or else all your directories will not be accessible (one needs the x bit to cd into a dir).

Remember this alert: never use bare * but ./* instead.

To avoid problems setting permissions on directories, use find instead.

find . -type f -exec chmod `VALUE` {} \;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.