Ubuntu: Setting group ID for website development folder

Having recently migrated to Ubuntu I wanted to have all my website projects stored in my home folder but allow Apache to load them from there.

This has given me a little bit of a headache when it comes to permissions and ownership. Warren Daly helped out and did some CLI magic which I haven’t yet fully documented but I’m starting to get a handle on how it’s all working.

One issue which did crop up was that any files I was creating/copying into the /home/websites folder was ending up with the wrong permissions. Ideally I wanted every new folder to be 755 and each new file to be 644. This should then allow Apache the permissions it needs.

Fortunately this can be easily achieved by setting the sticky bit.

find websites/. -type d -exec chmod 2755 {} \;

This command is a handy one for searching for all folders (“-type d”) and executing a chmod command on them. Usually we’d just run 755, but in this case we’re adding the sticky bit at the front of the command to set these folders to always have new files at 644 and new folders at 755.

I think.

It’s going to take me a little while to fully get my head around a new world of permissions, ownership, group handling and so on, but hopefully I’ll get there sooner rather than later.

If you list your files/folders after this command you should see something like this:

Folders and files with sticky bit set

My understanding of it is that the d shows our directories, and the ‘s’ you see in the directory permissions is setting the sticky bit to the user or group ID. Perhaps Warren will be able to clarify that fully for me.

Comments