Linux File permissions - Liam-DiFalco/Sys255-FA24 GitHub Wiki

Linux File permissions

User create

useradd "username"
passwd "username"

Group Create

groupadd groupname

Add user to group

usermod -aG "groupname" "username"

Change file ownership

chown :"groupname" /your/directory/yourfile.txt

Change file permissions

chmod "PERMISSIONOCTAL" /your/directory/yourfile.txt

Octal Permissions?

Octal permissions specify the permissions for a file or directory. Each digit in the number represents a different set of permissions for three categories: Owner, group and others.

Permission values: 
4 = read
2 = Write
1 = Execute

Order:
* First digit = Onwer
* Second digit = Group
* Third digit= Others

You add the permission values together to get the permissions for the individual digits in the number.

Eg:
* 640:
  * Owner: Read and Write (4+2)
  * Group: Read (4)
  * Others, No permission (0)
* 660:
  * Owner: Read and Write (4+2)
  * Group: Read and Write (4+2)
  * Others, No permission (0)

Modify Access Control

setfacl -m u:"username":rwx /your/directory/yourfile.txt

R, W and X?

R = Read
W = Write
X = Execute