Assign permission in Linux using the numeric method

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

Yellow Fishing Boat Blog Banner 86

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

Screenshot 19 1
  • 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

Screenshot 1 5

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.

Screenshot 2 5

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.

Screenshot 3 6

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.

Screenshot 4 6

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.

Screenshot 5 6

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.

Leave a Comment