This is all explained in 'man 1 chmod':
Quote:
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.
|
But I can try to rephrase it.
The numbers are interpreted as three bitfields (those 3 numbers; 7, 7 and 7 in your case) each containing three bits.
To figure out what those numbers mean, you have to convert them to bit representation.
For example the number 7 is '111' in binary (1*2^2+1*2^1+1) , (Equally similar to decimal representation of for example value 275 is 2*10^2+7*10^1+5 [Here the '^' means rising to power].
So, what does the bitfield '111' tells us? It means that reading, writing and executing flags are all on. So the original number serie 777 means that reading, writing and excuting are allowed for for owner, group and others.
Other example: What does mode 644 mean?
Interpreting the 6: '110' (that is 1*2^2+1*2^1+0)
Interpreting the 4: '100' (that is 1*2^2+0*2^1+0)
Now in '110' the reading and writing flags are on, but execution is not and in '100' reading is on, other flags off. So, the modeline 644 means that owner has read and write permissions and group and others have only reading permission.
And to the other way around; how to set for example permissions so that user can execute the file, group can read and execute it and others can do nothing with it?
Way 1:
Convert the idea to binary number and it to decimal
How? User: '001', group: '101', others: '000', so the mode is 150
Way 2:
Remember (or look from the manpage) that: read (4), write (2), and execute (1).
That is: set only execute:1, to set read and execute: 4+1, To set nothing: 0.
So we got the 150 again.