Katz
Katz

Reputation: 866

Set permission using octal notation

I know that permission are set using Chmod but I am having a hard time understating how to convert an octal number into a permission.

for example

640 does this mean that the user has rw-r----x permission? Becuase 4+2=6 and 4 = w and 0 = - ?

I understand that 777 is wide open because the user has full control fo the file 4+2+1 = 7 rwx permission the group has rwx and the second group has rwx permission If I were to answer this question my answer would be. rw-r----x What am I doing wrong?

Upvotes: 0

Views: 3194

Answers (3)

Mhowell
Mhowell

Reputation: 139

Maybe a picture would be easier:

Linux File Permissions

..I would post it here but I don't have the rep

Some Examples:

  1. We want the User to be able to read, write and execute the file, the group to have read access and no access for everyone else:

chmod 740 test_dir

  1. We want the everyone to have full access to read, write and execute:

chmod 777 test_dir

Upvotes: 0

melpomene
melpomene

Reputation: 85897

There are 3 digits. The first digit is the user permissions, the second digit is the group permissions, the third digit is everyone else's permissions.

Every digit is formed by adding a subset of of 4 (read), 2 (write), 1 (execute).

Thus 6 4 0 means the user (6) is allowed to read and write (4 + 2), the group (4) is allowed to read (4), and everyone else (0) has no permissions.

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799510

x is 1, therefore the third triad is read as "1". 0 would have the third triad be ---.

Upvotes: 0

Related Questions