LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Adding user to a group (https://www.linuxquestions.org/questions/linux-newbie-8/adding-user-to-a-group-549089/)

SBN 04-26-2007 02:02 AM

Adding user to a group
 
- Hey guys how do you assign a user to a certain group using the terminal.

deadeyes 04-26-2007 02:29 AM

Quote:

Originally Posted by SBN
- Hey guys how do you assign a user to a certain group using the terminal.

"man useradd" tells you all posibilities.

usermod -a -G GROUP1[,GROUP2,...] username

pixellany 04-26-2007 07:44 AM

The subtlety here is that you do not add (assign) users to groups.
You add (assign) groups to users

Emerson 04-26-2007 07:49 AM

sudo vi /etc/group

:p

pixellany 04-27-2007 07:34 AM

Quote:

Originally Posted by Emerson
sudo vi /etc/group

:p

OK--so you are telling me that I can edit this file to add users to groups....touche

BUT!!!
I did a little experiment:
Presuming that the "groups" command gets its info from this file, I disabled my access and ran the groups command. It came back with the GIDs of all my groups, but complained that it could not get the names (because I disabled access to the group file)

So, where did the groups command find the GIDs?
And what would happen if I only edited /etc/group?

Emerson 04-27-2007 07:58 AM

All good questions.

Actually I do edit group file directly. Doing a fresh install I find it's the most convenient way. Just open one file and do it all at once, instead of running useradd multiple times. It works that way. Refreshing environment is required to validate changes. Logoff-login will do, too.
Don't know where GID's come from in your test, set in environment? You tell us. ;)

Emerson 05-04-2007 01:32 PM

Quote:

So, where did the groups command find the GIDs?
You have nscd running. Stumbled across this one today, looking for something else.

reddazz 05-04-2007 01:40 PM

Personally I prefer using gpasswd to add users to groups e.g.
Code:

#gpasswd -a user group

pixellany 05-04-2007 01:55 PM

Quote:

Originally Posted by Emerson
You have nscd running. Stumbled across this one today, looking for something else.

Nope--nothing with ps -e, nothing in synaptic, no man page

Emerson 05-04-2007 02:04 PM

:scratch: Don't know then.


All times are GMT -5. The time now is 08:59 PM.