0

I have created a group for developers, to give them access to: /var/lib/dev, a folder which already have some folders and files inside.

The commands I've introduced are:

$ sudo useradd -d /var/dev -M -r devmaster

So, devmaster is a new system user with primary group devmaster. That can be checked out with id:

$ id devmaster
uid=998(devmaster) gid=998(devmaster) groups=998(devmaster)

Then, I changed permissions (using chmod/chown) as follows:

$ cd /var
$ sudo chown -R root:devmaster dev
$ sudo chmod -R o-wrx dev
$ sudo chmod -R g+wrx dev

And finally (my username here is just justme):

$ sudo usermod -G devmaster justme
$ id justme
uid=1000(justme) gid=1000(justme)
groups=1000(justme),998(devmaster)

$ ls -lh
// Omitted
drwxrwx---  3 root devmaster 4,0K dic 12 19:48 dev
// Omitted

But if I try to go into the directory:

$ cd dev
-bash: cd: dev: Permission denied

What's wrong with me?

2

Your problem is you didn't restart your session after giving yourself a new group membership. Yes, id justme tells you that when justme logs in in future, he'll (you'll) have group membership of devmaster. But that doesn't affect his (your) current shell sessions, as id -a would have told you.

Log out and log in again, check you've acquired the new group membership with id -a, then see if you can cd /var/dev (or /var/lib/dev, your question is ambiguous).

  • Yes, that was what happend. – Peregring-lk Dec 13 '15 at 23:11
0

The thing finally was that, although I don't really know why, I had to logout and login again to test the results, which works as except, except that:

$ sudo usermod -G devmaster justme

needed the -a option:

$ sudo usermod -a -G devmaster justme

Because if not, the secondary groups are completly replaced by devmaster, instead of being concatenated with any group asigned before, and since justme was the original administrative account, I was out of groups sudo, adm, cdrom, plugdev and other 5 groups.

So, I wasn't capable of using sudo, and, since there wasn't any other user account in the system, I had to reboot the machine, restart in safe mode and open a root shell to add myself to the sudo group and to the other lost groups.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.