Linux File permissions - samuelGreitzer/SYS255-tech-journal GitHub Wiki

Create New Group

groupadd (group)

add user to group

usermod -aG (group) (user)

View file permissions

ls -l (file)

ex:

ls -l test.txt

rwxrw-r--. 1 root root 5

three sets of 3 letters or dashes first set is the owner permissions second set is group permissions third set is everyone else

r: Read permission

w: Write permission

x: execute permission

View directory permissions

ls -ld (directory)

change file/directory group

chgrp (group) (target)

change file/directory permissions

chmod (permission changes) (target)

ex:

chmod g+rw /secrets

chmod u-x /secrets

chmod o-rwx /secrets

Permission Changes Explained

First letter: determines which section of the permissions you edit:

u: edits permissions for the user who owns the file

g: edits permissions for users in the file's group

o: edits permissions for every other user

Second character is a + or - and means you are adding or removing permisssions

After that is the specific permissions you are changing so

chmod g+rw /secrets

means giving read and write permissions to the group who has access to the /secrets directory