How to add user into group.
I want to add a user "smith" into marketing group using terminal.Please guide me that how can I do it ?
thanks garden |
Hello,
Have a look at the usermod command: Code:
man usermod Eric |
|
well I have use the command
[root@localhost home]# usermod -d marketing smith How can I check that in marketing group there is a smith user.Which file should I see for it ? thanks garden |
You can see users in /etc/passwd and groups in /etc/group
|
Quote:
Have you looked at the man page of usermod? Code:
-d, --home HOME_DIR Code:
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]] Code:
id <username> Code:
uid=1000(eric) gid=1000(eric) groups=1000(eric),4(adm),7(lp),21(fax),27(sudo) Eric |
well one thing confusing me that when i create a new user like xyz user I can see its name in /etc/group file as
xyz:x:501 and if I add xyz user into marketing then in /etc/group file it show marketing:x:502: The question is when a new user is just created by its entry is also shown in /etc/group file .What is the reason ? |
Hello,
When you create a new user, automatically a group with the same name gets created. This groupID (gid) gets used for example when the user creates a file. Then the default group association of that file will be that same groupID. Hope that helps. You can change that group association at any time. You can also add a user to additional groups as explained above. Sycamorex pointed you to a very good tutorial in post #3, I suggest you read it, it contains very good information. Kind regards, Eric |
thanks for your reply. I have review the site as well. Well I am showing following how I add "john" Primary group and then secondary group ?
Creating user Code:
#adduser john Code:
#passwd john Code:
#groupadd fisrgroup Code:
#usermod -d firstgroup john Code:
#groupadd secondgroup Code:
#adduser john,jill,jack,harry Code:
#groupadd secondgroup Code:
#usermod -d secondgroup john,jill,jack,harry |
useradd -G marketing smith
I think the above should work perfectly for having a secondary group for the user smith |
Quote:
Why are you sticking to -d as parameter to usermod? Haven't you read my post (#6)? Or do you have a different version of usermod that switched -G for -d? Kind regards, Eric |
The problem with the man page might be that the options -A and -R to add/remove groups from the supplementary groups list are not listed. Or is this only an undocumented openSUSE extension?
But I also don't get the OP whether the user "smith" in question already exists and should only be added to the group "marketing" or whether he must be created completely. |
All times are GMT -5. The time now is 10:11 PM. |