LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 08-13-2002, 04:41 AM   #1
dai
Member
 
Registered: May 2002
Location: Wales
Distribution: Slack 8.1, Gentoo 1.3a, Red Hat 7.3, Red Hat 7.2, Manrake 8.2
Posts: 328

Rep: Reputation: 30
chmod


Hi all Im starting to get to grips with some of the bash commands now and was wondering if somebody could let me know if this assumption is correct.....

when using chmod if you specify a 7 (whether for user other users or other groups) it gives read write and execute access

a 6 would give read(4) write(2) access but no execute priveleges

a 5 would give read and execute(1)

a 4 would give read only

a 2 write only

and a 1 execute only

so chmod 751 would give the user full priveleges the other users in the same group read and execute priveleges and other groups execute only priveleges.

Am I correct in my assumptions???

Last edited by dai; 08-13-2002 at 04:51 AM.
 
Old 08-13-2002, 05:00 AM   #2
A-dummy
Member
 
Registered: Jun 2002
Location: Kanpur,India
Distribution: RH-7.0 , 7.3
Posts: 130

Rep: Reputation: 15
yeah your conclusions are correct ....change the number 7
in binary : 7=111 ....compare it with rwx (Read-Write-eXecute)...
1 at all places means all access....I hope you can now check for
rest.....
 
Old 08-13-2002, 05:08 AM   #3
dai
Member
 
Registered: May 2002
Location: Wales
Distribution: Slack 8.1, Gentoo 1.3a, Red Hat 7.3, Red Hat 7.2, Manrake 8.2
Posts: 328

Original Poster
Rep: Reputation: 30
many thanks

while on the subject of binary conversion for this command I take it that 7 is the highest decimal number you can use hence only using a 3 bit binary pattern.

Would this therefore also be valid to allow full read write xecute access to all : -

chmod 111111111 or even

chmod 1FF (Dont think this would because its based on the total value of the full string above not three seperate 111)

Last edited by dai; 08-13-2002 at 05:20 AM.
 
Old 08-13-2002, 05:15 AM   #4
A-dummy
Member
 
Registered: Jun 2002
Location: Kanpur,India
Distribution: RH-7.0 , 7.3
Posts: 130

Rep: Reputation: 15
check it for urself & tell us too
(actually i cant do right now cos in windows)
 
Old 08-13-2002, 05:17 AM   #5
dai
Member
 
Registered: May 2002
Location: Wales
Distribution: Slack 8.1, Gentoo 1.3a, Red Hat 7.3, Red Hat 7.2, Manrake 8.2
Posts: 328

Original Poster
Rep: Reputation: 30
hmmm I shall do that

it should theoretically be possible I mean Linux is capable of differrentiating between number bases isnt it???

(I cant check now coz Im in work and using Windows if anybody is in Linux and his willing to try it, let us know the outcome please)

Last edited by dai; 08-13-2002 at 05:24 AM.
 
Old 08-13-2002, 05:25 AM   #6
amp2000
Member
 
Registered: Oct 2001
Location: Dublin, Ireland
Distribution: Mandrake 9.0 mostly!
Posts: 303

Rep: Reputation: 30
Nope dosent work:
[root@localhost amp2000]# chmod 111111111 plugin131.trace
chmod: invalid mode string: `111111111'
[root@localhost amp2000]#
 
Old 08-13-2002, 05:39 AM   #7
dai
Member
 
Registered: May 2002
Location: Wales
Distribution: Slack 8.1, Gentoo 1.3a, Red Hat 7.3, Red Hat 7.2, Manrake 8.2
Posts: 328

Original Poster
Rep: Reputation: 30
many thanks amp

it may work if you specify that your working in base 2 before hand and also seperate each block of 111. I dont know if you can do that or not does anybody else, Im curious to know???

Last edited by dai; 08-13-2002 at 05:43 AM.
 
Old 08-13-2002, 07:46 AM   #8
neo77777
LQ Addict
 
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 56
Don't think about permission being a decimal number - it is octal, and the system understands octal through binaty representation, so a base 8 digit can be represented with three bits binary (2 in the power of three is 8), so this is why you have 7 as 111 (or r=1 w=1 and x=1), and 4 in base 8 you can express as 100 (r=1, no write and executable permissions - READ ONLY), and so forth. So chmod only accepts octal number or letter notation (u+x o-w and so on)
 
Old 08-13-2002, 08:06 AM   #9
dai
Member
 
Registered: May 2002
Location: Wales
Distribution: Slack 8.1, Gentoo 1.3a, Red Hat 7.3, Red Hat 7.2, Manrake 8.2
Posts: 328

Original Poster
Rep: Reputation: 30
Okay

4 in decimal = 100 in binary

100 in octal is in fact = 63

so in fact the decimal value for 100 (octal) is 63

so your saying the binary encoding used is increasing by 8 for each bit i.e.

64 8 1 <------------- decimal values for 3 bit octal

1 1 1 (r w x)
1 0 0 (r - -)
1 0 1 (r - x)
1 1 0 (r w -)

etc................................................

Last edited by dai; 08-13-2002 at 08:09 AM.
 
Old 08-13-2002, 08:37 AM   #10
neo77777
LQ Addict
 
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 56
nope , each digit in the permission pattern is octal (0 through 7) try enter 8 and see chmod complaining about it, now each one of these are represented through 3 bit binary (2 in the power of 3 gives you 8, so it means with three bit binary you can construct an octal digit from 0 to 7 in total of eight) so to say
octal 3-bit binary
0 000
1 001
2 010
3 011
--------------
7 111

So, now each digit in the permission pattern is octal representation of read, write, execution bits for a defined field - owner, group, others.
so if you put it all together
chmod 777 is translated to a binary pattern with each digit represented in 3-bit binary (3-bit - 1 bit for r, 1 bit for w and one bit for x)
chmod 111 111 111
or
chmod rwx rwx rwx

| | |___others
| |______group
|__________owner

is it clear?

Last edited by neo77777; 08-13-2002 at 08:41 AM.
 
Old 08-13-2002, 09:05 AM   #11
dai
Member
 
Registered: May 2002
Location: Wales
Distribution: Slack 8.1, Gentoo 1.3a, Red Hat 7.3, Red Hat 7.2, Manrake 8.2
Posts: 328

Original Poster
Rep: Reputation: 30
ahhhhhh I keep messing up my conversion tables doh!!!!!!!!!!!

I only realised what I was doing when I looked at the hex number F which is equal to 15 in decimal or 1111 binary.

you dont increment 1 8 64 in octal (stupid thing to do)

you increment 1 2 4 8 16 32 64 128 etc.....for all number bases

the only time you do increment 1 8 16 32 etc....is if you convert from binary into octal via decimal i.e.

1111 (binary)

becomes 15 (decimal)

which then becomes 017 (octal)

Last edited by dai; 08-13-2002 at 09:07 AM.
 
  


Reply



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
How to use Chmod Centinul Linux - Newbie 8 06-30-2005 10:44 AM
What can we do if we type chmod ugo-x /bin/chmod ?????? bunny123 Linux - Software 3 02-01-2005 08:53 PM
CHMOD in shell : chmod 777 /usr/ <---is that right? cpanelskindepot Programming 5 07-16-2004 05:37 AM
Chmod gibbylinks Linux - Newbie 1 10-23-2003 11:17 AM
chmod u+s csDraco_ Slackware 6 04-22-2003 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:28 AM.

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