Hello everyone In this Article we are going to learn How to assign permission in Linux using the numeric method in files/folder in a very simple and easy step-by-step approach
Assign permission in Linux using the numeric method
In this article, we are going to learn how we can assign permission to files/folder using the numeric method.
Read – 4 in numeric form
write – 2 in numeric form
execute – 1 in numeric form
If we want to give permission using a numeric method for /Directory. To see the default permission on /Directory. We can use # ls -ld /Directory command
- owner = rwx = To assign same in numeric method then we can do as 4+2+1 = 7
- group = r-x = To assign same in numeric method then we can do as 4+0+1 = 5
- other = r-x = To assign same in numeric method then we can do as 4+0+1 = 5
Using #chmod 755 /tutdevopsdir command we can assign the suitable permission on folders/files
Now we want to assign full permission on /tutdevopsdir
- owner = rwx = To assign same in numeric method then we can do as 4+2+1 = 7
- group = rwx = To assign same in numeric method then we can do as 4+2+1 = 7
- Other = rwx = To assign same in numeric method then we can do as 4+2+1 = 7
And the current permission on the content inside of /Directory directory is something else.
Soo we want to give the same permission on data that is inside of /Directory to their child directory and folders.
#chmod 777 -R /Directory– Where -R is for recursive to assign the same permission inside the /Directory. The same permission must be assigned to the child directory and files like the parent directory.
But if we create new files/ directory still it gets the default permission.
Now If we want to change the owner of the directory to harry with all the files/folder .
How to change owner inside the files and directory
# chown harry -R /tutdevopsdir – When we add -R option in a chown command this will helps to change the owner of the directory as well as its child directories/files.
Now If we want to change the group owner of the directory to student group with all the files/folder .
How to change group owner inside the files and directory
# chgrp harry -R /Directory – When we add -R option in a chgrp command this will helps to change the owner of the directory as well as its child directories/files.
Conclusion
If you want to learn Linux in the most simple language then please click on this link.
This is the complete knowledge of sudo command in the Linux kernel if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on DvOps Articles.