Adding user to a group
- Hey guys how do you assign a user to a certain group using the terminal.
|
Quote:
usermod -a -G GROUP1[,GROUP2,...] username |
The subtlety here is that you do not add (assign) users to groups.
You add (assign) groups to users |
sudo vi /etc/group
:p |
Quote:
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? |
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. ;) |
Quote:
|
Personally I prefer using gpasswd to add users to groups e.g.
Code:
#gpasswd -a user group |
Quote:
|
:scratch: Don't know then.
|
All times are GMT -5. The time now is 08:59 PM. |