Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add user to group but not reflected when run "id"

Tags:

linux

unix

R creates a group called staff and I want to be able to update packages without starting R as sudo. So I added myself to staff using:

sudo usermod -G adm,dialout,cdrom,plugdev,lpadmin,admin,sambashare,staff matt

(side question is there a way to add yourself to a group without listing every other group you're a member of?)

If i check /etc/groups i see

staff:x:50:matt

and the same for /etc/shadow

staff:*::matt

however if i run groups or id i'm not a member of staff. Also, I can't make changes to anything in /usr/local/lib/R.

like image 496
matt_k Avatar asked Sep 24 '11 05:09

matt_k


People also ask

How do I add a user to an existing group?

To add an existing user account to a group on your system, use the usermod command, replacing examplegroup with the name of the group you want to add the user to and exampleusername with the name of the user you want to add.

How do I add a user to a group in Ubuntu terminal?

Ubuntu Linux add a user to group command Open the terminal application. Login to Ubuntu server using ssh. Add a new user named foo to www-data group by running useradd -g www-data foo command. Add an existing user bar to Apache's www-data group on Ubuntu using usermod -a -G www-data bar command.

How do you add a user to a group as a supplementary group?

To add a member to a supplementary group, use the usermod command to list the supplementary groups that the user is currently a member of, and the supplementary groups that the user is to become a member of. where user-name is the user name. To display who is a member of a group, use the getent command.


3 Answers

Did you log the "matt" account out and back in after running the sudo usermod command? Changes to the groups a user is in under unix only take affect at login time.

like image 192
freiheit Avatar answered Oct 06 '22 14:10

freiheit


https://superuser.com/questions/272061/reload-a-linux-users-group-assignments-without-logging-out

check that out ~

both

newgrp groupname

OR

su - username

will do the trick well ~

like image 23
kiiwii Avatar answered Oct 06 '22 15:10

kiiwii


In answer to your side question, yes you can add a user to a group without listing them all. If you run a Debian based system, you can do it with

sudo adduser matt staff

The adduser utility is just a friendly wrapper around useradd/usermod etc.

If you don't have the adduser utility, you can still do it with usermod:

sudo usermod -a -G staff matt

The -a flag means append (as opposed to overwrite).

like image 35
lxop Avatar answered Oct 06 '22 16:10

lxop