LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I change user rights for speciffic users? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-change-user-rights-for-speciffic-users-910717/)

venom4u31 10-28-2011 07:28 PM

How do I change user rights for speciffic users?
 
I have several users on a linux machine. I want them to have the combination I see fit for certain files REGARDLESS of what or who owns them.

For example, if I have the users alpha, beta and gamma on a machine and the file test owned (for exemple) by alpha, I want it to be able to give every single user a combination of rights of my choosing like in this example:
alpha rwx
beta r--
gamma --x

although beta or gamma do not own the file.

Please tell me how to do this recursively on a directory with lots of files inside it.

And please tell me how to do the same thing with groups.

KenJackson 10-28-2011 08:35 PM

The traditional UNIX and Linux way of controlling group access is with groups. It's true that they don't have quite the level of micromanagement that you describe because the UNIX/Linux world comes from less of a micromanagement way of thinking than some other OSes.

Implementing the group control is fairly straightforward. Create a new group, let's name it greek since the users have greek usernames, and add those users to the group.
Code:

groupadd greek
for u in alpha beta gamma; do usermod -a -G greek $u; done

Now change the group to greek for each file in and below /some/path.
Code:

chgrp -R greek /some/path

But, alas, you are posting from Windows7 with a question that plays to a Windows strength, perhaps for the purpose of showing that Windows has some virtue after all. And many would argue that ACLs are a valuable feature that Windows has had for a while.

But Linux does have ACLs now. I have no reason to use them, but I think they will let you do what you describe. There's a chacl command that also has a -r switch for recursion.

See man chacl for help.

eSelix 10-28-2011 08:44 PM

You maybe interested about ACL:
Code:

setfacl -m u:alfa:rwx,u:beta:r,u:gamma:x /path/to/file/test
You can use wildcards as usual for all files in directory and -R option for recursive operation. More info you can find in manual. The file system must support this feature. ext4 with 'acl' option works.

venom4u31 10-29-2011 03:42 AM

I think I have ext3 on my machine so chacl or setfacl won't work (I tried, they did not).

Anyway, you're telling me that I'm bound by the bureaucracy of assigning users to groups, then changing the group owners for all the files then changing the rights with chmod g=--x (for example) and repeating this procedure for every user? Group implementation may be a nice addition to linux, but it shouldn't force root to deal with it. Root should force linux to do whatever it wants (including not dealing with groups).

What I mean: Isn't there a command like this: <command> [username/userid] [rights] [files_in_question] that changes the rights for the files in question only for the mentioned users?

eSelix 10-29-2011 06:51 AM

It is supported for ext2, ext3 and raiserfs also. You can manually enable this by adding "acl" option to mount command or fstab.
Quote:

Isn't there a command like this
Yes it is. We provided that commands for you. Someone needed this feature ealier and some others created it. But it havily depends on used filesystem so not every is capable of that.

venom4u31 11-01-2011 12:14 PM

Finally I solved it!!!! The solution sounds like this:

1: make sure you have acl installed; if not,
Code:

apt-get install acl
(sudo is not necessary since wanting to install something like acl implies you are logged in as root)

2: find out the partition you want acl active on (it's found on /dev/ and it has the form hda1, hda2, sda1, sda2) and mount acl on it using this command:
Code:

mount -o remount,acl /dev/hda6
where you can replace hda6 with any other partition.

And that worked for me. The command setfacl does what I wanted to achieve and getfacl makes sure it worked.

I wrote that so future google wanderers might get intel faster. Further reference: http://www.debianhelp.co.uk/acl.htm


All times are GMT -5. The time now is 02:44 AM.