Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I very often read things like chmod 777 <somefile>.
Well, I understand chmod +x <somefile>, but so far, I haven't been able to figure how to compute these numbers. Is there anyone who knows?
Thank you a lot
777 : the first 7 stands for user, second one stands for groups, and the third stands for everyone or world.
Now the 7 indicates that it has a value to give rwx permissions.. so that is read, write and execute.
It is the total of each individual permission..
Read = 4
Write = 2
Execute = 1
Say you wanted a permission level of 640, that would mean that the user has Read/Write permission, the group has read permission and everyone else has no permissions.
some examples:
640 = rw-r-----
755 = rwxr-xr-x
777 = rwxrwxrwx
So basically its just adding the values for the permissions settings of each individual read, write or execute on any given group or user..
Hope this helps.. in a way. Ask if you have any questions.
If you know binary numbers representation you'll get it by snap
Computers only understand 0 or 1 (low/high, whatever you prefer, let's not get adventurous into computer science field), so 1 will be for turning the bit on and 0 to turn it off
so you have 777 (7 for owner, 7 for group and 7 for others)
lets make every digit in binary, so 7 decimal is 111 in binary
(1x2 in power of 2 plus 1x2 in power of 1 plus 1x2 in power of 0) == (4+2+1=7)
each number represents read (r) write (w) and execute (x) permissions
so 777 translates into
111 111 111
rwx rwx rwx
Lets turn off some permissions
100 000 001
r-- --- --x
lets make it decimal now
100 is 1x 2 in power of 2 + 0x 2 in power of 1 + 0x 2 in power of 0 equals 4
000 is 0
and
001 is 1
----------
so chmod 401 will yeild these permissions
Got it?
Danm, I feel like a prof in a college :-)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.