I have a 30GB website, with loads of folders, and files. I want all the folders to have the permission 745 and all the files to have 644. I tried using chmod -R 745 public_html/ but all the sub files get that permission.
How can I change all the folders (only) to this permission with chmod?
Asked
Active
Viewed 6,851 times
3
j0h
- 14,548
- 28
- 104
- 178
-
dupe http://askubuntu.com/questions/30629/how-can-i-recursively-change-the-permissions-of-files-and-directories – Rinzwind Sep 21 '15 at 21:47
-
2745 is a typo I hope... – Rinzwind Sep 21 '15 at 21:49
1 Answers
10
Unless you delibaretely not want the group members to access the directory (will be a unusual case), you should use 755 for directories.
You can use find.
For files :
find /path/to/public_html/ -type f -exec chmod 0644 {} +
For directories (using 755) :
find /path/to/public_html/ -type d -exec chmod 0755 {} +
-type fwill only find the files and executechmod 0644accordingly-type dwill find the directories only and executechmod 0755on them.
heemayl
- 90,425
- 20
- 200
- 267