LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-19-2006, 07:59 AM   #1
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 522

Rep: Reputation: 31
how to add an existing user to a new group?


Hi!
Is there a special command to add an existing user to a new created group? Or is editing per hand /etc/group with vigr the only solution?

Thanks.
 
Old 04-19-2006, 08:07 AM   #2
Xian
Member
 
Registered: Feb 2004
Location: 33.31N -111.97W
Distribution: SuSE
Posts: 918

Rep: Reputation: 31
$ su
# gpasswd -a <username> <group>
 
Old 04-19-2006, 08:07 AM   #3
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 73
You can use the usermod command.
 
Old 04-19-2006, 08:12 AM   #4
BobNutfield
Senior Member
 
Registered: Dec 2005
Location: United Kingdom
Distribution: Fedora , Ubuntu, Slackware-Current
Posts: 1,477

Rep: Reputation: 51
Try:

[QUOTE$ usermod -g (group) (username)[/QUOTE]

I believe this should assign a group to a user or change the user from their original group.

Hope this helps

Bob
 
Old 04-19-2006, 08:13 AM   #5
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 522

Original Poster
Rep: Reputation: 31
Thanks a lot!
I just created 1 group and created 2 users with useradd -g mynewgroup usersname
but when I do cat /etc/group I only have:
Quote:
newgroup:x:513:
but the usersnames don't appear. Why?
 
Old 04-19-2006, 08:21 AM   #6
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 73
A users default group does not usually show up in /etc/group. Run "id username" to find out the default group and other info.
 
Old 04-19-2006, 08:22 AM   #7
puntjuh
Member
 
Registered: Apr 2006
Location: holland
Distribution: Gentoo / debian / suse / mint
Posts: 558

Rep: Reputation: 41
Doesn't usermod -g only set the initial group of the user ?

I believe the command to add a group to a user is: usermod -Gcdrom puntjuh (just an example group then username)
 
Old 04-19-2006, 08:29 AM   #8
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 522

Original Poster
Rep: Reputation: 31
Thanks a lot!
 
Old 04-19-2006, 08:31 AM   #9
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 73
Quote:
Originally Posted by puntjuh
Doesn't usermod -g only set the initial group of the user ?

I believe the command to add a group to a user is: usermod -Gcdrom puntjuh (just an example group then username)
You are right -g sets or changes the initial group. "-G comma,sperated,existing,groups,newgroup" keeps the user in their existing non primary groups and adds them to a new one.
 
  


Reply

Tags
group


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to list user in Linux box, add an user to a group! steady_lfcfan Linux - Newbie 12 01-27-2013 01:14 PM
Adding new group to existing user ALF Linux - Software 7 05-08-2006 09:35 PM
add user to the group ashley75 Linux - General 4 03-30-2005 02:42 PM
how do i add user to a group jogurt666 Linux - General 2 04-02-2004 10:05 PM
add root user to the existing group ashley75 Linux - General 4 09-25-2003 09:40 PM


All times are GMT -5. The time now is 07:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration