# Check if 'webmasters' group exist
cat /etc/group | grep webmasters
# Create 'webmasters' group
sudo addgroup webmasters
# Add users to 'webmasters' group
sudo usermod -a -G webmasters username
# INFO: Group assignment changes won't take effect until the users log out and back in.
# Change group owner of the directory to webmaster user
sudo chgrp -R webmasters /etc/nginx/
# Give write permission to the group
sudo chmod -R g+w /etc/nginx/
# Create file as different user
sudo -u username touch /etc/nginx/test.txt
# When using a number mask for permission representation there are only a few basic permissions
4: Read
2: Write
1: Execute
# Combined you get this table
+-----+---+--------------------------+
| rwx | 7 | read write execute |
| rw- | 6 | read write |
| r-x | 5 | read execute |
| r-- | 4 | read |
| -wx | 3 | write execute |
| -w- | 2 | write |
| --x | 1 | execute |
| --- | 0 | |
+------------------------------------+
# The permissions for user, group and other are listet after each other when looking them up
+------------+------+-------+
| Permission | Octal| Field |
+------------+------+-------+
| rwx------ | 700 | User |
| ---rwx--- | 070 | Group |
| ------rwx | 007 | Other |
+------------+------+-------+
# This boils down to this
+------------------------+-----------+--------------------------------------+
| chmod u=rwx,g=rwx,o=rx | chmod 775 | For world readable directories |
| | | Members of group can change files |
| chmod u=rwx,g=rx,o= | chmod 750 | For group readable directories |
| | | Members of group can change files |
| chmod u=rwx,go= | chmod 700 | For private direcories |
+------------------------+-----------+--------------------------------------+
Comments