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 –
- Owner – Person who created a file becomes its owner.
- Group – Group can contain multiple users. Everyone belongs to same access permission
- Others – This person has neither created the file, nor he belongs to a usergroup.
In linux we have only 3 basic permissions –
- Read (r OR 4)
- Write (w OR 2)
- 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.
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