Linux+ numerical file permissions
-
Hi!
I am in the process of learning file permissions for the Linux+ Certification. Specifically, I am looking at the numerical notation for file permissions. A thought occurred to me as to why the numbers 1-7 represent what they do.
I'll bet you have already explained this concept somewhere in your videos but here it is:
0 - None
1 - Execute
2 - Write
3 - Write and Execute
4 - Read
5 - Read and Execute
6 - Read and Write
7 - Read, Write and ExecuteHere are the values that you mentioned for numerical notation. Are these numbers in 3 binary sets?
ie.
6 - read and write
110 ( which is 6 in Binary)4 - read
100Does it make sense to think of the numeric file permissions in the form of binary numbers in which each value represents (read, write, execute) --> (111)?
Thank you!
-
@rima-wilson ,
Each number you mention correlates to 4 binary bits (0000 - 1111) technically, even so the highest order bit is rarely used (0000).As far as permissions go, the single digits are normally combined to give the proper permissions for a file: so instead of just seeing a single file listed with a 7, you'll see something more along the lines of 3 digits like 755 or 555 etc.
if you access a terminal and type
ld -l
ronnie@SiteA-01 ~ $ ls -l total 32 drwxr-xr-x 2 ronnie ronnie 4096 Jun 3 14:57 Desktop drwxr-xr-x 2 ronnie ronnie 4096 Jun 8 20:12 Documents drwxr-xr-x 2 ronnie ronnie 4096 Jun 8 21:29 Downloads drwxr-xr-x 2 ronnie ronnie 4096 Jun 2 17:17 Music drwxr-xr-x 2 ronnie ronnie 4096 Jun 2 17:17 Pictures drwxr-xr-x 2 ronnie ronnie 4096 Jun 2 17:17 Public drwxr-xr-x 2 ronnie ronnie 4096 Jun 2 17:17 Templates drwxr-xr-x 2 ronnie ronnie 4096 Jun 2 17:17 Videos ronnie@SiteA-01 ~ $
The string you see at the beginning: drwxr-xr-x is a symbolic notation of the octal notation you're referring.
the d would be for the directory the 1st set of 'rwx' = 7. This is what the OWNER can do, the 2nd tells us the permissions of the group member r-x = 5 and 3rd tells us what everyone else can do : r-x = 5 = overall giving an octal code of 755 for the directory.So yes it makes sense to find that correlation. I'm not sure if you'll find any real practical matter, even if you're changing permissions, you're changing the octal and not necessarily needing to change it in binary.
Cordially,
Ronnie Wong
Host, ITProTV -
I see, Thank you Ronnie! And thanks for the amazingly helpful content you all put out!