Syntax
General: _rwxrwxrwx 1 owner group
_ | rwx | rwx | rwx
= Special | Owner | Group | All Users
Shorthand
4
|r
= Read2
|w
= Write1
|x
= Execute
Detailed
0
=---
1
=--x
2
=-w-
3
=-wx
4
=r-
5
=r-x
6
=rw-
7
=rwx
Commands
chgrp
= Change group
Example: sudo chgrp -R <group> <folder>
chown
= Change ownership
Example: sudo chown -R <user>:<group> <file/folder>
chmod
= Change permissions
Example: sudo chmod -R 774 <file/folder>
Make new files inherit the group: sudo chmod g+s <folder>
Example
Create a shared directory for a group.1. Create a shared directory for users to access: /share
- Assign users to a common group (staff):
sudo usermod -a -G staff <user>
- Verify user groups:
groups <user>
- Create shared directory and assign permissions:
sudo mkdir /share && \
sudo chgrp -R staff /share && \ # assign group
sudo chmod -R g+w /share && \ # permissions
sudo chmod -R +s /share # inherit permissions for newly created files/folders