The other day a good friend of mine asked me what the number equivalent of drwxr-xrwx was.

Most people who are up to their arms in Bash everyday know how to compute this – but for everyone else the Terminal App in most Debian/BSD based operating systems display the permissions in alpha – yet kind of require that you change the permissions using number notation.

To compute this, it’s actually really simple – so long as you understand binary. 

Each subset of three letters can be assigned a binary value – 4, 2, 1.  For Example:

rwx r-x rwx
111 101 111
421 401 421

Then, computing in standard binary fashion, compute the  value, in this case, 4+2+1 = 7, 4+0+1 = 5, 4+2+1 = 7.

Put these all together, add the chmod command (and, in some cases the all too awesome sudo) and we get:

$ sudo chmod 757 filename.txt

Any questions? =)

Tagged with:
 
Pro Palma Deus Unus