LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   add user to group (https://www.linuxquestions.org/questions/linux-newbie-8/add-user-to-group-215018/)

brandnewbie 08-08-2004 12:23 PM

add user to group
 
Hi everyone, newbie here.

I'm trying to add an existing user (don) to an existing group (admins). User don is currently a member of existing group 'dev' as well as 'don'.

I first tried the command

useradd don admins

but when I executed 'groups don', all I got was

don : don dev

So for some reason don wasn't added to admins

I then tried

usermod -Gadmins don

and, when I did 'groups don', all I got was

don : don admins

so it lost group 'dev'!

Your help please? Thanks.

twantrd 08-08-2004 12:33 PM

you can just edit /etc/group and add the user to the group you want. That's it.

-twantrd

b0uncer 08-08-2004 12:36 PM

Quote:

useradd don admins
I think this only would create a new user called "don" (and perhaps one too called "admins"?), since you only give two parametres to useradd, and looking at the manpage, parametres given without any option chars (like -G) mean login names. so that wouldn't help..

Quote:

usermod -Gadmins don
this is a nasty command, I've noticed...you will have to list each and every group name you wish the user be part of that you are editing. so basically you just put your user into two groups, "admins" and "don", and removed from all the others. if you use this command, first check out into which groups the user belongs already, and then list them all plus the ones you want to add...

I think the easiest way of editing groups is simply to use a text editor (nano, joe, jed etc.) and edit the actual groups file: /etc/group

just open the file, locate the right line and edit it (look the other lines for help on syntax)

EDIT: twantrd, sorry...seems like you were quick enough to answer while I was writing.. :)

brandnewbie 08-08-2004 04:53 PM

Of course, editing the /etc/group file would be the easiest solution. Thanks!


All times are GMT -5. The time now is 09:27 AM.