Understanding Permissions on a Linux System

Profile pictureRocktim Saikia/2 min read
ls -l

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.

  1. The first section denotes to the type of the target whether it is a file or directory. If the the first section is d that means it's a directory. If it's a - that means it's a file.

  2. The second section refers to the the user's permissions ie. rwx . Meaning the user has read, write and execute permissions over that specific file/dir.

  3. The third section refers to group's permissions. In the above example the group rocktim has permission to read, write and execute on that specfic dir.

  4. The last section denotes to permission of others ie not any valid user or any group. In the above example other have permissions to read and execute only but does not have write perimission that's why we see a hyphen(-) there.

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 +x

chmod u+x testDir

The same way if we want to add permissions for groups we will replace u with g and for others we will use o.

Also if we want to remove permissions we can simply use - instead of + when running chmod and everything else works the same way.