Index ¦ Archives ¦ Atom

Setting file permissions

This is a fairly short post but it's another one of those Note to self things, I've done this 100 times but I can never remember and need to keep looking up again.

Often I want to go through a directory and set all subdirectories to be readable and all the files to be read only by everyone except the owner who should have write permissions as well.1

I've got a little command I use, taken from a thread on stack overflow that was about WordPress but it's very applicable elsewhere.

chown www-data:www-data -R *          # Let apache be owner
find . -type d -exec chmod 755 {} \;  # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 644 {} \;  # Change file permissions rw-r--r--

  1. without the execute bit set of files so chmod -R 755 doesn't work but if you do chmod -R 644 you can't open the directories. 

Creative Commons License
Content on this site is licensed under a Creative Commons Attribution 4.0 International License.
Built using Pelican. Based on a theme by Giulio Fidente on github.