Day 12 #90DaysOfDevops
Aspiring Devops engineer eager to make an impact.
For day 12, i learnt how to control file and directory permissions. To guarantee the safety of files, selected users are granted permissions to read, write & execute files. Files and directories permissions status are specified for the file owner, particular group of users and for all other users.
The three levels of permissions are:
r - Permission to read. This grants permission to view files.
w - Permission to write. This grants permission to view and edit files
x - permission to execute. This grants permission to execute files ( not necessary to view and edit).
There are two methods used to change file permissions which are the numeral method and the UGO method.
The numeral method uses binary system (as all things computer). it uses the octal system 0-7 to specify the permissions rwx.
octal number 1 (001) signifies --x which means only the execute command is permitted for the user to use.
2 (010) signifies -w- which means only the write command is permitted for the user to use.
3 (011) signifies -wx which means only the write and execute commands are permitted for the user to use.
4 (100) signifies r-- which means only the read command is permitted for the user to use.
5 (101) signifies r-x which means only the read and execute commands are permitted for the user to use.
6 (110) signifies rw- which means only the read and write commands are permitted for the user to use.
7 (111) signifies rwx which means all the commands are permitted for the user to use.
using 777 signifies all the commands are availble for the users, groups of users and others.
e.g To change a file permission of a file named odunayo which have permissions -rw-rw-r-- to include an execute command for the file owner while the group and others have only the rw permissions, the command goes thus chmod 766 odunayo which changes the file permissions to -rwx-rw-rw.
The other method is the UGO method. U stands for user, G stands for group of users, O stands for others. The UGO syntax is very simple. It makes use of 3 operators, - (remove a permission), + (add a permission), = (sets a permission).
Enter the chmod command and then the users you want to chnage permsissions for.
So, if you want to remove the write permission from the user that uses the file odunayo, you could run this command chmod u-w odunayo.
These are what i learnt today and tried my hands with trying different combinations especially with the numeral method.
Cheers to day 12 and cheers to many more days.