1

I know how to set read/write/execute with three numbers from the Arch wiki's file permissions page. I also know that chmod 7777 will set the setuid, setgid, and sticky bits to true. But which number controls these bits? Is it the first or the last number? Which value is set to true when a 1, 2, or 4 is passed as this value?

Edit: I have added this information to the Arch wiki for future reference.

My question is much smaller in scope than the proposed duplicate.

2
  • That question has a much larger scope than this one, I do not think they are similar enough to be duplicates. Also, that question does not come up when searching for this post's title. Commented Mar 16, 2017 at 21:46
  • 1
    the idea behind a duplicate is that your question's wording helps lead people to the answers that already exist Commented Mar 16, 2017 at 23:58

1 Answer 1

8

From the chmod man page:

A numeric mode is from one to four octal digits (0-7), derived by adding up the bits with values 4, 2, and 1. Any omitted digits are assumed to be leading zeros. The first digit selects the set user ID (4) and set group ID (2) and sticky (1) attributes. The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1); the third selects permissions for other users in the file’s group, with the same values; and the fourth for other users not in the file’s group, with the same values.

2
  • 1
    Thank you! So, just to verify, chmod 2777 would set everything except setuid and sticky? Commented Mar 16, 2017 at 21:27
  • That is correct! Commented Mar 16, 2017 at 21:28

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.