How can I change all the file permissions of a directory in one command in Unix?
migrated from stackoverflow.com Nov 8 '10 at 17:56
This question came from our site for professional and enthusiast programmers.
You can use capital 'X' to do the right thing for folders: 'X' = "execute/search only if the file is a directory or already has execute permission for some user"
So, e.g.: chmod -R ug=rwX,o-rwx .
Would make an entire tree accessible to the owner and the group of each file, and not accessible to anyone else. Any already executable files would still be executable afterwards, and all directories would have the 'x' for the user and the group and not for others.
From the man page of
File permission may be for eg. 777, 755, 644 etc.
To change permissions on a file or directory entry non-recursively, use the
To change the owner of a file/directory recursively (affecting all descendants):
To change permissions bits of all files in a directory, recursively:
To change permissions bits of all directories:
It would be nice if you could just do this:
However, this has problems. It treats files and directories the same. The above command makes directories listable and readable by all users, but it also makes all files executable, which is usually what you do not want to do.
If we change it to
The problem is that
The point is,