LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-20-2007, 09:15 PM   #1
vonedaddy
Member
 
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 180

Rep: Reputation: 17
File Permissions Questions / SIMPLE HELP ME!


OK I am a noob and I am trying to learn these file permissions here. I understand that the first number is YOUR permissions, the second is GROUP and the third is USERS permissions.

So here is my question, how do you define different permissions for different groups if there is only one group permission number.

For instance, lets say I have 3 groups (just to make it simple) ftptrusted, ftpusers, users.

Now I have a dir named ftphome. I want to allow ftptrusted to have full rights to the directory (rwx) and ftpusers to have read only (r). How would I go about this? If I do chmod 777 it gives everybody full rights. If I do 7 (mine permissions), 7 group permissions, 4 read only for users. How do I determine WHICH group is getting the 7 permissions.

I hope i am explaining myself right here.
 
Old 12-20-2007, 09:29 PM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 60
OK, you need to remember some binary numbers here. The full permission string consists of three groups of permissions. Like you mentioned, it's permissions for
the owner: rwx (read write execute)
the group: rwx (read write execute)
the others: rwx (read write execute)

Each triple rwx is encoded by a binary number, where 0 means that the corresponding permission is unset, and 1 means that it's set. For example,

000 corresponds to ---
001 corresponds to --x
100 corresponds to r--
101 corresponds to r-x
111 corresponds to rwx

and so on. But each triple of bits is also a number, between 0 (000) and 7 (111)
in binary notation. For example, 6 is 110 which is rw- in permission string, 5 is 101, that is r-x and so on.

And each permission triple can be encoded by a single decimal number between 0 (no permissions) to 7 (full permissions).

For example, chmod 754 will give the file:
full permissions rwx for owner, (because 7 is 111 in binary)
read and execute permissions r-x for the group (because 5 is 101 in binary)
and read permissions only r-- for the "others" (because 4 is 100 in binary).
HTH.
 
Old 12-20-2007, 09:45 PM   #3
vonedaddy
Member
 
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 180

Original Poster
Rep: Reputation: 17
Ok That is an AWESOME explanation and that helped me understand that portion of it even better.

BUT, if I have more than one group how do I know which group I am setting permissions for with the second #?
 
Old 12-20-2007, 09:58 PM   #4
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 60
You're setting permissions for the group that owns the file (or the directory). Each file belongs to a user and to a group.
Run ls -l in the directory where your file or the directory resides. For example, in my /home directory

teddy@toshiba~$ ls -l /home
total 3
drwxr-xr-x 2 root root 48 2006-08-06 21:50 ftp
drwx--x--x 38 teddy root 3168 2007-12-19 21:55 teddy

I have two subdirectories, teddy and ftp. "teddy" belongs to the user named teddy and to the group called root. ftp belongs to the user root and the group "root". The second triple in the permission strings for the subdirectories say what the members of that group can do to the directories.

You can change the group ownership of the file by running the chgrp command.
 
Old 12-20-2007, 10:03 PM   #5
vonedaddy
Member
 
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 180

Original Poster
Rep: Reputation: 17
You are the man, Thank you VERY much. I appreciate you taking the time and explaining this so well. Thanks a million!

One more question if you dont mind.

What if I wanted 2 different usergroups to have different permissions on the same dir.

For example I have an Uploads directory. Now I wanted ftptrust group to have rwx and I want the ftpusers group to have -rw.

Last edited by vonedaddy; 12-20-2007 at 10:28 PM.
 
Old 12-21-2007, 03:08 AM   #6
vonedaddy
Member
 
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 180

Original Poster
Rep: Reputation: 17
Anyone? Can anyone help me here?
 
Old 12-21-2007, 04:59 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,338
Blog Entries: 55

Rep: Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538
The simple answer is you can't because users need execute rights on a directory for read and write rights to make sense.
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Questions...Hopfully Simple Answers. caps_phisto Linux - General 3 12-21-2004 12:40 PM
File/Folder Permissions / Mounting hdd's / fstab <-- ?Questions? EThitop Linux - Newbie 2 06-19-2004 08:19 PM
simple permissions question hollywoodb Linux - Newbie 13 10-16-2003 02:47 PM
simple questions about permissions chrismiceli Linux - General 6 06-15-2003 12:00 PM
Is there a simple way to give all permissions frontier1 Linux - General 3 02-28-2003 08:55 PM


All times are GMT -5. The time now is 03:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration