Understanding Permissions on a Linux System
Outputs something similar like this
drwxrwxr-x 10 rocktim rocktim 4.0K 2022-03-11 22:00 work/
The permission string(
drwxrwxr-x) can broken down into four different pieces.
The first section denotes to the type of the target whether it is a file or directory. If the the first section is
dthat means it's a directory. If it's a
-that means it's a file.
The second section refers to the the
user's permissions ie.
rwx. Meaning the user has
executepermissions over that specific file/dir.
The third section refers to
group's permissions. In the above example the group
rocktimhas permission to
executeon that specfic dir.
The last section denotes to permission of others ie not any valid user or any group. In the above example other have permissions to
executeonly but does not have
writeperimission that's why we see a hyphen(
How to change permissions of any of dir of file
To change the permission of a specific file/directory we run the following command against the targated file
chmod +x testDir
Here we are grating permission of
execute to everyone. If we want to be more specific of our permission. Say we only want to add permission for user not anyone else.
The we can do that with the
u option before the
chmod u+x testDir
The same way if we want to add permissions for groups we will replace
g and for others we will use
Also if we want to remove permissions we can simply use
- instead of
+ when running
chmod and everything else works the same way.