6.Linux File System and Permissions (Day-6)

Mahbubur R.Mahbubur R.
4 min read

Types of file Permission

  • Basic Permission

  • Special Permission

  • ACL ( Acess Control List) permission

Permission details

Permission Description

Owner (U) : Permission user for the owner of the file.

Group ( g) : Permission used by members of the group.

Others (o) : Permission used by others users.

Permission Set

Read : This permission give you the authority to open and read a file.

Write : The write permission gives you the authority to modify the contents of a file.

Execute : Executable Permission, which the user may run the program if it is executable.

Permission with Numeric and symbol

NumberPermission TypeSymbole
0No Permission- - -
1Execute- - x
2Write- w -
3Execute + Write- wx
4Readr --
5Read + Executer-x
6Read + Writerw-
7Read + Write + Executerwx

Note : You can control all of the permissions if you can only remember three of them by adding these numbers. Eg. if you need read and write permission the value is 4+2=6.

  • r (read): 4

  • w (write): 2

  • x (execute): 1

Change the permission with a Numeric value

change the permission for a file called text.txt

Full access to Owner

Read Execute Permission to Group

Execute permission to others

chmod 751 /test.txt

Check the directory permission for dev folder

ls -ld /dev

Check the permission of the file test1.txt

ls -l /test1.txt

Changing Permission of files

Add the read permission to the Owner group of the file test.txt file

chmod u+r /test.txt

Add the read write permission to Group of file name called test2.txt

chmod g+rw /test2.txt

Remove the read permission from the group Others of the file name called test.txt

 chmod o-r /test.txt

Changing the ownership

Syntax: chown <user name > <File/Directory Name>

Changing the ownership to a new user named mbubur of the file name called test.txt

chown mbubur

Changing the Group ownership

Syntax: chgrp <group name> <file / directory name >

Change the group ownership to mbubur user of the file called test.txt

chgrp mbubur /test.txt

Access Control List (ACL)

A list of permissions attached to an object that specifies which users or groups are granted access to that object and what actions they are allowed to perform. Access control lists are commonly used in computer security to control access to files, folders, and other resources.

Use of ACL:

In computer security, an ACL can be used to control access to files, folders, and other resources. For example, a system administrator might create an ACL that grants read access to a certain file for a particular group of users, while denying access to all other users.

For checking ACL permission

Syntax: getfacl <file / directory name >

Check the ACL for Directory named devops

getfacl /devops

Set ACL permission to the user mbubur to the group devops

setfacl -m u:mbubur:rwx /devops

Remove ACL permission for the user mbubur from devops group

setfacl -x u:mbubur: /devops

Set the ACL permission for the Group called devops

setfacl -m g:testgrp:rwx /devops

Remove the ACL permission for the Group called devops

setfacl -x g:testgrp: /devops

Remove all permission

setfacl -b /devops
0
Subscribe to my newsletter

Read articles from Mahbubur R. directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mahbubur R.
Mahbubur R.