File Permissions and chmod
Original = http://www.redbrick.dcu.ie/help
Permission Binary Octal <br> rwx 111 7 rw- 110 6 r-x 101 5 r– 100 4 -wx 011 3 -w- 010 2 –x 001 1 — 000 0
For permission rw——-, use 600.<br> For permission rwx–x–x, use 711.<br> For permission rw-r–r–, use 644.
chmod -R 600 files/directory
Case: Take a website folder. We want two users to be able to both read/write into this folder. We can add both users to a new group on the server, and by setting the sgid we can have it so that any files created in that folder will be of the parent group (as opposed to the default user group). Take the following example: groupadd testgroup adduser existingusername1 testgroup adduser existingusername1 testgroup mkdir /srv/vhost/website chown existingusername1:testgroup /srv/vhost/website chmod 2775 /srv/vhost/website su existingusername1 touch /srv/vhost/website/testfile chmod 755 /srv/vhost/website/testfile ls -la /srv/vhost/website
drwxrwsr-x 2 existinguser1 testgroup 4096 2008-05-24 00:04 . drwxrwxr-x 6 root root 4096 2008-05-23 23:48 .. -rwxrwxr-x 1 existinguser1 testgroup 0 2008-05-24 00:04 testfile
Any files created by either username will be created in the “testgroup” group.
Excellent SGID and SUID and Sticky explaination: http://www.zzee.com/solutions/linux-permissions.shtml#setuid