LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 02-25-2010, 10:58 PM   #1
sen
LQ Newbie
 
Registered: Feb 2010
Posts: 1

Rep: Reputation: 0
Setting permission for multiple users to a directory


Hi,

I'm a linux newbie and I'm having trouble breaking down permissions in linux. Here's the scenario.

I have two users: UserA & UserB with each having to ownership and access to directories myDirA and myDirB respectively.

UserA --> /source/myDirA
UserB --> /source/myDirB

I need to set the permissions so that userA can access myDirA and myDirB. There are other users and directories but they should not be able to view outside of their own directories (which is the way it is now).

I don't have groups set up for them and I'd rather not change anything else but just the permissions.

rwxr_x_r_x UserA
rwxr_x_r_x UserB

They're read/write/exec permissions are identical.

Please help.

Thanks.
 
Old 02-25-2010, 11:20 PM   #2
ashok.g
Member
 
Registered: Dec 2009
Location: Hyderabad,India
Distribution: RHEl AS 4
Posts: 215

Rep: Reputation: 32
I think you should have a group of users to have access of a file to different users.
So create a group containing the users whom you want to access the files/directories and make respective file permission changes to those.
Also, have a look at man chown on how to achieve this.

HTH
 
Old 02-25-2010, 11:20 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You need to add UserA to the same group UserB is in.
 
Old 02-25-2010, 11:26 PM   #4
saifkhan123
Member
 
Registered: Apr 2009
Distribution: Red Hat/CentOS
Posts: 108

Rep: Reputation: 19
thats easy

man, first of all, whenever you post a question on LQ, must mention you distro!

Now about your question, you should read about ACLs (Access Control Lists) on directory and files, lets say if you are using Red Hat Linux, the command is "setfacl" for setting up ACL on a particular directory,
Quote:
I need to set the permissions so that userA can access myDirA and myDirB. There are other users and directories but they should not be able to view outside of their own directories (which is the way it is now).
type this command
Code:
setfacl -m u:userA:rwx myDirB/
this command will give read-write-execute permission to the userA on directory myDirB, you can setup permission to any directory like this regardless of what permissions and ownership you have already set on your directories.

This answer was just for help, you should read about ACLs in your distro and then you can set even more complex permissions in the future.
Regards

Last edited by saifkhan123; 02-25-2010 at 11:52 PM.
 
Old 02-25-2010, 11:34 PM   #5
ashok.g
Member
 
Registered: Dec 2009
Location: Hyderabad,India
Distribution: RHEl AS 4
Posts: 215

Rep: Reputation: 32
saifkhan123,
Thats really an important information....
I tried that as below:
Code:
[root@station130 home]# setfacl -m u:Ashok:rwx srinivas/PerlEx/
setfacl: srinivas/PerlEx: Operation not supported
Actually I logged in as root and I want Ashok(a user) to access the directory srinivas/PerlEx/.
But it's not happening. Can you please help me?

Last edited by ashok.g; 02-25-2010 at 11:45 PM.
 
Old 02-26-2010, 12:05 AM   #6
saifkhan123
Member
 
Registered: Apr 2009
Distribution: Red Hat/CentOS
Posts: 108

Rep: Reputation: 19
Quote:
Originally Posted by ashok.g View Post
saifkhan123,
Thats really an important information....
I tried that as below:
Code:
[root@station130 home]# setfacl -m u:Ashok:rwx srinivas/PerlEx/
setfacl: srinivas/PerlEx: Operation not supported
Actually I logged in as root and I want Ashok(a user) to access the directory srinivas/PerlEx/.
But it's not happening. Can you please help me?
First you should check that you have ACL package installed in your machine (it should be present already, just to confirm), for this type
Code:
rpm -q acl
it should show you the installed package and version, if not install the package through yum.

Also Read ACL details here
http://www.redhat.com/docs/manuals/e...s-setting.html

hope this will help

Last edited by saifkhan123; 02-26-2010 at 12:14 AM.
 
Old 02-26-2010, 12:11 AM   #7
ashok.g
Member
 
Registered: Dec 2009
Location: Hyderabad,India
Distribution: RHEl AS 4
Posts: 215

Rep: Reputation: 32
I think I did the same as what the link you posted suggest. But why am I getting this problem "operation not supported"?
 
Old 02-26-2010, 12:16 AM   #8
saifkhan123
Member
 
Registered: Apr 2009
Distribution: Red Hat/CentOS
Posts: 108

Rep: Reputation: 19
Quote:
Originally Posted by ashok.g View Post
I think I did the same as what the link you posted suggest. But why am I getting this problem "operation not supported"?
read my previous reply and do the "rpm -q", also post your /etc/fstab contents, as ACLs has much to do with the mounted partitions.
 
Old 02-26-2010, 12:21 AM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Please post the results of "mount". The filesystem type needs to support ACLs and you need to add the "acl" option to it's entry in /etc/fstab. But for only two users, what you want to do is done easily by creating a group for the purpose of sharing files in a directory. That is what groups are for. When you need to use acls, is when more users need access but that access is different. Suppose you have two users who can create files. A group of users who read the files they produce but don't have permission to create files in the directory.

Last edited by jschiwal; 02-26-2010 at 12:24 AM.
 
Old 02-26-2010, 12:24 AM   #10
ashok.g
Member
 
Registered: Dec 2009
Location: Hyderabad,India
Distribution: RHEl AS 4
Posts: 215

Rep: Reputation: 32
Quote:
Originally Posted by saifkhan123 View Post
read my previous reply and do the "rpm -q", also post your /etc/fstab contents, as ACLs has much to do with the mounted partitions.
Ok here is what you have requested for.
Code:
[Ashok@station130 ~]$ rpm -q acl
acl-2.2.23-5
Code:
[Ashok@station130 ~]$ cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/1                /                       ext2    defaults        1 1
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
LABEL=SWAP-hda2         swap                    swap    defaults        0 0
Please help me!
 
Old 02-26-2010, 12:42 AM   #11
saifkhan123
Member
 
Registered: Apr 2009
Distribution: Red Hat/CentOS
Posts: 108

Rep: Reputation: 19
@ashok.g

try this
Code:
# mount -o remount,acl /home
Now try your ACL command on a directory in /home, If that does the job add ",acl" to the mount options in /etc/fstab for Mount entries.
 
Old 02-26-2010, 12:45 AM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Change the mount options of your root partition to "defaults,acl".
 
Old 02-26-2010, 01:32 AM   #13
ashok.g
Member
 
Registered: Dec 2009
Location: Hyderabad,India
Distribution: RHEl AS 4
Posts: 215

Rep: Reputation: 32
I'm getting the same output even now. Do I need to restart any services for this to happen???
 
Old 02-26-2010, 02:40 AM   #14
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
No ... ACL support should take effect automatically if you did the remount correctly. You're using ext2 ... according to my man page ext2 should support ACLs, but maybe you've got an older kernel. What distro and version are you using? I don't see why in this case, though, you would just create a group to do this as was mentioned above.
 
Old 02-26-2010, 03:01 AM   #15
ashok.g
Member
 
Registered: Dec 2009
Location: Hyderabad,India
Distribution: RHEl AS 4
Posts: 215

Rep: Reputation: 32
Quote:
Originally Posted by btmiller View Post
No ... ACL support should take effect automatically if you did the remount correctly. You're using ext2 ... according to my man page ext2 should support ACLs, but maybe you've got an older kernel. What distro and version are you using? I don't see why in this case, though, you would just create a group to do this as was mentioned above.
Actually this is not me who started this thread. But, I am just interested to know the different option (using setfacl) than the option I too mentioned(using groups).
I already mentioned my distro. For that please refer to above replies by me.
I run the command as:
Code:
[root@station130 ~]# mount -o remount,acl /home
mount: can't find /home in /etc/fstab or /etc/mtab
so I edited the /etc/fstab file by making some entry as:
Code:
none                   /home                   ext2    defaults,acl    1 1
now my total /etc/fstab looks like:
Code:
[root@station130 ~]# cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/1                /                       ext2    defaults        1 1
none                    /home                   ext2    defaults,acl    1 1
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
LABEL=SWAP-hda2         swap                    swap    defaults        0 0
I run the command again as:
Code:
[root@station130 ~]# mount -o remount,acl /home
mount: /home not mounted already, or bad option
Help me out please
 
  


Reply

Tags
acl, file, permissions, user



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
Read/write permission to ALL users on a directory and everything in it Virtuality Linux - Newbie 3 12-13-2007 08:29 PM
Setting multiple group permission terryyip Linux - General 3 03-12-2007 11:42 AM
Setting File permission to Mounted Directory nebumt Linux - General 3 01-12-2006 12:11 AM
give users permission to install software in their directory? ksgill Linux - Newbie 7 12-17-2003 11:16 AM
Setting File / Directory Permission, with sticky Primetime Linux - Newbie 3 01-06-2003 01:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:12 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