Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This 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.


  Search this Thread
Old 07-01-2002, 04:27 PM   #1
Registered: Jan 2001
Location: Switzerland
Distribution: Gentoo
Posts: 376

Rep: Reputation: 30

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
Old 07-01-2002, 04:38 PM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 256Reputation: 256Reputation: 256
break it down like this in a nutshell:

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.

Last edited by trickykid; 07-01-2002 at 04:42 PM.
Old 07-01-2002, 05:19 PM   #3
LQ Addict
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 56
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
001 is 1
so chmod 401 will yeild these permissions
Got it?
Danm, I feel like a prof in a college :-)

Last edited by neo77777; 07-01-2002 at 05:20 PM.
Old 07-01-2002, 09:10 PM   #4
LQ Addict
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
The chmod numbers are represented in the octal number system. That's why you won't see a single digit larger than 7.
Old 07-02-2002, 12:25 AM   #5
LQ Addict
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 56
Yeah you are right, I was too into professor/student stuff
My bad.
Old 07-02-2002, 07:04 AM   #6
Registered: Jan 2001
Location: Switzerland
Distribution: Gentoo
Posts: 376

Original Poster
Rep: Reputation: 30

Thank you all for the detailed answers - it's easier than I would have thought - and thinking of it in binary makes it very easy
Thank you all


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
I have messed up system directory ownerships Mike Gibson Linux - Newbie 13 02-23-2005 12:10 PM
Unix ownerships got messed(very urgent please).. mahamkali Linux - Security 1 01-02-2005 02:50 AM
Vsftpd Folder ownerships - Is this secure? Korff Linux - Security 2 06-06-2003 02:05 PM
File ownerships/groups plisken Linux - General 3 03-04-2003 06:18 PM
Reverting back the defaul Ownerships anand Linux - Security 1 05-04-2001 05:47 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration