Question: I was asked in an interview why it is that 777 is assigned to take all permissions for a file. Why not 555? He said that there is reason for everything. So, what is the reason for 777? Why not any other number? Is there any significance in this number?

Answer: 
Reading file permission means `4`, writing file permission means `2` and executing file permission means `1`.

So the total of this is `7`.

Now what is 777: first `7` is for file owner that means file owner have read, right and execute permission. 

2nd `7` is for the group to which the file belongs, it means group also have all the read, write and execute permission.

And 3rd `7` is for others permission

If you give the file permission `555` then the file `owner, group and others` have only `read` and `execute` permission `not write` permission because read permission means 4 and execute means 1 so total gets `5`
In not so many words as the top answer:

Each file has 3 permissions options: read, write, and execute. You can choose none of these, one of these, two of these, or all of these:

C(3,0) + C(3,1) + C(3,2) + C(3,3) = 8

1 + 3 + 3 + 1 = 8

So, altogether, there are 8 combinations; 8 options for permissions. Counting from 0, the last number is 7 (from 0 to 7). So, represented by numbers, here are all the options:

```
0 - nothing
1 - execute
2 - write
4 - read
3 - execute + write (1 + 2)
5 - execute + read (1 + 4)
6 - write + read (2 + 4)
7 - execute + write + read (1 + 2 + 4)

```

There are three numbers because the order goes [user permissions][group permissions][others permissions]

So, 777 means that all three groups have read, write, and execute permissions.

---

**Also (indirectly related so you don't necessarily have to read this part), because I think its relevance is important:**
*Why is `read` number 4 instead of number 3?*

```
0 - nothing
1 - execute
2 - write
3 - read
4 - execute + read (1 + 3)
5 - write + read (2 + 3)
6 - execute + write + read (3 + 2 + 1)
7 - ????? no way to get this with the 3 basic options (and we are missing execute + write)

```

The only way to get unique combinations for all of the possibilities is to go by powers of 2 for the basic options. 20 = 1 (execute), 21 = 2 (write), 22 = 4 (read), and if there were a 4th basic option it would be numbered 23 = 8. Note that `write` is not listed until all combinations of previous options have been listed (which is just one option, since it is just `execute`). `read` is not listed until all combinations of previous options have been listed (again one, since there is only one combination with two options - `execute` + `write`). `execute` + `write` + `read` is not listed until all previous combinations have been listed, which is 3, since there are now two choices from three permissions. The list would continue in this manner, no matter how many basic options there were. For the sake of example, with 4 basic options (note that we also know there will be 16 combinations total since there are 4 options and 24 = 16):

```
0 - nothing
1 - execute
2 - write
4 - read
3 - execute + write (1 + 2)
5 - execute + read (1 + 4)
6 - write + read (2 + 4)
7 - execute + write + read (1 + 2 + 4)
8 - love
9 - execute + love (1 + 8)
10 - write + love (2 + 8)
11 - execute + write + love (1 + 2 + 8)
12 - read + love (4 + 8)
13 - execute + read + love (1 + 4 + 8)
14 - write + read + love (2 + 4 + 8)
15 - execute + write + read + love (1 + 2 + 4 + 8)

```