There's more...

Permissions can be set with chmod using numbers also, known as Octal representation. We can edit permissions for the owner, group, and others, all at the same time using this method. The syntax of the command is as follows:

chmod xxx file/directory

Here, xxx refers to a three-digit number from 1-7. The first digit refers to the owner's permission, the second represents group, and the third digit refers to the permissions of others.

When we use octal representation r, w, and x permissions have specific number values:

  • r = 4
  • w = 2
  • x = 1

So, if we want to add permission to read and execute, it will be calculated as follows:

  • r-x = 4+0+1 = 5

Similarly, permission to read, write, and execute is calculated as follows:

  • rwx = 4+2+1 = 7

And if we wish to give only read permission, it will be this:

  • r-- = 4+0+0 = 4

So, now, if we run the given command, it gives the permission as calculated:

chmod 754 file1.txt

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.28.48