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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
12-20-2007, 09:15 PM
|
#1
|
Member
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 185
Rep:
|
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.
|
|
|
12-20-2007, 09:29 PM
|
#2
|
Member
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896
Rep:
|
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.
|
|
|
12-20-2007, 09:45 PM
|
#3
|
Member
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 185
Original Poster
Rep:
|
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 #?
|
|
|
12-20-2007, 09:58 PM
|
#4
|
Member
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896
Rep:
|
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.
|
|
|
12-20-2007, 10:03 PM
|
#5
|
Member
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 185
Original Poster
Rep:
|
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.
|
|
|
12-21-2007, 03:08 AM
|
#6
|
Member
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 185
Original Poster
Rep:
|
Anyone? Can anyone help me here?
|
|
|
12-21-2007, 04:59 AM
|
#7
|
Moderator
Registered: May 2001
Posts: 29,417
|
The simple answer is you can't because users need execute rights on a directory for read and write rights to make sense.
|
|
|
All times are GMT -5. The time now is 03:41 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|