Octal numbers and permissions
You can use octal number to represent mode/permission:
Let’s see some examples which help you to undertand it more easily.
if you want to give full permmission like read,write and execute then use below octal calculation.
0+r+w+x = 0+4+2+1 = 7
Only Read and write permission use below octal values,
0+r+w+x = 0+4+2+0 = 6
Fore read and execute permission on a file in octal is
0+r+w+x = 0+4+0+1 = 5
Use above method to calculate permission for owner, group and others. Let say you want to give full permission to owner, read & execute permission to group, and read only permission to others then you need to calculate permission as follows:
User = r+w+x = 0+4+2+1 = 7
Group= r+w+x = 0+4+0+1 = 5
Others = r+w+x = 0+4+0+0 = 4
So you have given permission to file is 754.
Now we see the command which help to change the permissions of file and directories :
Chmod command : used to set up permissions for files and directories.
We have two ways to change the permissions of file :
1. Symbolic way :-
- chmod u-w test.txt [ ‘ – ‘ means remove the write permission for user ]
- chmod ugo+w test.txt [ ‘ + ‘ means add the write perm for all ]
- chmod a+w test.txt [ ‘a’ means all user , group and others ]
- chmod = test.txt [ ‘ = ‘ means clear all permissions ]
2. Octal way :-
- chmod 756 test [ ‘ 7 ‘ = 4+2+1 = user,’ 5 ‘ = 4+0+1 = Group,’ 6 ‘ = 4+2+0 = Others ].
- chmod 644 test [ 644 is default permission for files ]
This is all you need to learn about the file permissions. if you have any query regarding this post then feel free put your comments under the comment box.
Thank you 🙂