Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-13-2004, 08:37 PM   #1
Registered: Jul 2004
Posts: 256

Rep: Reputation: 30
change group

I have a user: pikachu in the group: pikachu

I created a new group: "groupadd monitor"

how do I change the user "pikachu" to group "monitor"?
Old 12-13-2004, 08:44 PM   #2
Registered: Jun 2004
Location: New Jersey, USA
Distribution: Slackware 11
Posts: 191

Rep: Reputation: 31
use the chown command. if you want to change only the group you would use:

chown file "owner":"group"
chown "owner":"group" file

i forget which order they go in but one will work. just add the group and owner name where it says without the quotes. if you dont want to change the owner just put in the same one.
Old 12-14-2004, 01:15 AM   #3
LQ Newbie
Registered: Aug 2003
Location: St. Paul, Minnesota, US
Distribution: Slackware 10
Posts: 27

Rep: Reputation: 15
buffed317's instructions are for changing what (user &) group owns a file. I don't think that's what you were after, though.

In the following examples I'll call the groups "oldgroup" and "newgroup", instead of "pikachu" and "monitor". (This is just to avoid the confusion of talking about a user and a group both named pikachu.) I'll still call the user "pikachu".

To make the user pikachu a member of group newgroup, you could try the following (but read below first):
usermod -g newgroup pikachu
A small complication is that pikachu could be a member of multiple groups. One way to check is to use this command:
groups pikachu
I believe the "usermod" command I gave above (with the lower case -g) should replace the first group listed in the output of the "groups" command.

For more information you can look in the usermod man page:
man usermod
Another way you can do it is to edit the /etc/passwd and /etc/group files directly (which is what usermod does under the covers.) Just note that a user's main/first group is kept (as a numerical ID) with the user's entry in /etc/passwd. Secondary groups, on the other hand, are indicated by adding the user to each secondary group's entry in /etc/group. (If this last paragraph makes no sense, don't worry. It's just informational, and probably not well written. :-)
Old 12-14-2004, 05:30 AM   #4
Senior Member
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
I usually just hand-edit the /etc/groups file - and add the users that way.


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 do I change a user's primary group? Akhran Linux - Newbie 4 03-19-2010 09:54 PM
how to change uid group id mfrangos79 Linux - General 1 11-07-2005 08:19 PM
howto change GROUP permissions (have read/googled for hours) arjay Debian 8 08-09-2005 11:40 AM
how to change/create group password feetyouwell Linux - Software 3 09-06-2004 10:38 PM
how to change user group ? Menestrel Linux - Newbie 7 05-21-2004 12:09 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:33 PM.

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