If you are working on a multi-user operating system then permitting a file (file permission) must be necessary. As we know that Linux is a multi-user operating system and many users can access simultaneously. Although a lot of security feature available in Linux. But file permission gives tremendous power to a Linux based system. So basically it is a way by which 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 a numeric value. Here Read can be denoted as r or 4.
Now you can see in the image how we can approach to giving the permissions. We have chmod command to permit 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 the only owner can read, write and execute a file chmod rwx------ readme.txt chmod g= readme.txt chmod o= readme.txt chmod go-rwx readme.txt