LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 03-24-2013, 04:48 AM   #1
mangesh_ram
LQ Newbie
 
Registered: Mar 2013
Posts: 1

Rep: Reputation: Disabled
How to remove a user from a group?


what is the command for del user from group
 
Old 03-24-2013, 04:54 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
groupmod -R someone
 
Old 03-24-2013, 04:54 AM   #3
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Hi

Look up usermod
 
Old 03-24-2013, 04:55 AM   #4
DinoFly
Member
 
Registered: Nov 2007
Distribution: Fedora, CentOS,
Posts: 72

Rep: Reputation: Disabled
There are different ways of removing users from a group.

Command usermod
Using option -g, --gid GROUP will set the primary group of user to "groupname",
Using option -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] it will put suplementary groups to the user, if the user is currently a member of a group which is not listed, the user will be removed from the group.

or simply by editing the file: /etc/group which specifies the groups and its users
 
Old 03-24-2013, 06:26 AM   #5
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
you can simply
Quote:
#usermod -G group username
e , and that will make the person be in two groups only,his own private group and the group you just specified.If there are more than just two groups then use the -a command and list the groups you want the person to ONLY be in.
Quote:
#usermod -a -G group1,group2,group3,group4 username

Last edited by cbtshare; 03-24-2013 at 03:15 PM.
 
Old 03-24-2013, 07:00 AM   #6
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by cbtshare View Post
you can simply
Code:
#usermod -G group username
e , and that will make the person be in two groups only,his own private group and the group you just specified.If there are more than just two groups then use the -a command and list the groups you want the person to ONLY be in.
It will remove all groups for the user, except the one specified in the command. Its not a good option, becuase user may have many other important secondary groups.

So, instead use deluser command as:
Code:
~# deluser <username> <groupname>
OR
~$ sudo deluser <username> <groupname>

Last edited by shivaa; 03-24-2013 at 07:05 AM.
 
Old 03-24-2013, 09:43 AM   #7
fpmurphy
Member
 
Registered: Jan 2009
Location: /dev/ph
Distribution: Fedora, Ubuntu, Redhat, Centos
Posts: 299

Rep: Reputation: 62
Simplest way is to directly edit the /etc/group file.
 
Old 03-24-2013, 10:59 AM   #8
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by fpmurphy View Post
Simplest way is to directly edit the /etc/group file.
No. It's not at all recommended to edit configuration files directly when you have an option of direct commands to do this.

@mangesh_ram:
Don't directly edit the config. file. You have certain commands to edit the groups of a user, so simply use those command.

Last edited by shivaa; 03-24-2013 at 11:02 AM. Reason: Typo
 
Old 03-24-2013, 01:19 PM   #9
DinoFly
Member
 
Registered: Nov 2007
Distribution: Fedora, CentOS,
Posts: 72

Rep: Reputation: Disabled
Quote:
Originally Posted by shivaa View Post
No. It's not at all recommended to edit configuration files directly when you have an option of direct commands to do this.

@mangesh_ram:
Don't directly edit the config. file. You have certain commands to edit the groups of a user, so simply use those command.
I wonder why you say so? Does the system keep track of users in groups in other files or it is only /etc/group file? If it is only file that keeps track of those supplementary groups than it is no harm if you edit it, but sure edit it correctly, because if I am not mistaken the commands do exactly that. Sure I am speaking of local users and local groups not for AAA through network.

Please correct me if I am wrong.
 
Old 03-24-2013, 01:23 PM   #10
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
@DinoFly:
You are right, there's no harm if file is edited correctly. But there're chances of mistakes, and why one should edit the file directly when he has commands to do so? Commands were created for this purpose and we should stick to commands.
 
Old 03-24-2013, 03:08 PM   #11
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
Quote:
Originally Posted by shivaa View Post
It will remove all groups for the user, except the one specified in the command. Its not a good option, becuase user may have many other important secondary groups.
I dont think you took the time to read my post in its entirety,feel free to do so at your convenience.
 
  


Reply



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 remove particular user from group ? rockstar05 Linux - Server 3 01-05-2012 04:23 PM
Remove user from root group JJJCR Linux - Newbie 5 09-05-2011 08:36 PM
groupdel: cannot remove user's primary group. leiw Linux - General 1 03-28-2007 10:12 PM
How to remove user from their secondary group? Akhran Linux - Newbie 2 09-13-2006 04:09 AM
remove a user from group in fedora core 3 bnarenderraju Fedora 7 07-20-2005 09:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:16 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration