File Permission in linux


As we know that linux is multi-user operating system and many user can access simultaneously. Although lot of security feature available in linux. But file permission gives tremendous power to linux based system. So basically it is a way by witch we can restrict to users to access any file and directory.

To understand the concept we need to understand the basic. Inside linux we have three types of users or owners –

  1. Owner – Person who created a file becomes its owner. 
  2. Group – Group can contain multiple users. Everyone belongs to same access permission
  3. Others – This person has neither created the file, nor he belongs to a usergroup.

In linux we have only 3 basic permissions –

  1. Read (r OR 4)
  2. Write (w OR 2)
  3. Execute (x OR 1)

We have two notation to permit file. First is by character and the second is by numeric value. Here Read can be denoted as r or 4.

Basic implementation of linux permission

Now you can see in in image how we can approach to giving the permissions. We have chmod command to give permission to any file.

# First way
chmod <permission> <file>

# Second way 
chmod <who>=<permission> <file>

# Third way 
chmod <who>+/-<permission> <file>

Now take an example

# Current file permission is rwxrwxrwx

# Now we need to change permission and only owner can read, write and execute file

chmod rwx------ readme.txt
chmod g= readme.txt
chmod o= readme.txt

chmod go-rwx readme.txt

You May Also Like

About the Author: admin