Thursday, July 30, 2009

Unix permission question?

I am still having a little trouble with file permissions in *unix. Can someone explain how this question works. I understand the owner, group and other portion of file permissions. I also understand the Octal system 0-7.





What are the octal representations of two files with the permissions set to: rwxr-x-r-- and rw-r-xr-x ? What are the resulting permissions for the octal values 756 and 623?

Unix permission question?
Ok, it goes like this: r=4, w=2, x=1





In binary system, 4=100, 2=010, 1=001 - hence the corresponding positions of r,w and x characters.





rwxr-x-r-- is 111 101 100 = 754 = 4+2+1, 4+1, 4


rw-r-xr-x is 110 101 101 = 655 = 4+2, 4+1, 4+1





756 is rwxr-xr--


623 is r-x-x--wx





In practice, you'll very rarely have to deal with exotic modes like 623 or 756.





Most of the time it's things like 777, 660, 755, 644 that will become automatic after you spend some time working with them.


No comments:

Post a Comment