LinuxQuestions.org
Review your favorite Linux distribution.
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 08-14-2017, 07:59 AM   #1
sigint-ninja
Member
 
Registered: Feb 2011
Location: Republic Of Ireland
Distribution: Debian,Centos,Slackware
Posts: 508

Rep: Reputation: 29
removing a user from a group


i know i can add a user to a group by either modifying /etc/group
or using usermod -aG user group

how do you remove a user from a group? i know i can modify /etc/group

but is there a neat command to do this?
thanks
 
Old 08-14-2017, 08:05 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Code:
deluser the-user group-to-remove-from
It is basically the same syntax as
Code:
adduser the-user group-to-add-to
jlinkels

Last edited by jlinkels; 08-14-2017 at 08:06 AM.
 
1 members found this post helpful.
Old 08-14-2017, 09:39 AM   #3
dejank
Member
 
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
That is one way to do it. Other would be to use gpasswd on systems not blessed with adduser and friends:

Code:
gpasswd -d user group

Last edited by dejank; 08-14-2017 at 09:40 AM.
 
1 members found this post helpful.
Old 08-14-2017, 11:12 AM   #4
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Or you could (carefully) edit /etc/group
 
Old 08-14-2017, 11:54 AM   #5
dejank
Member
 
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
Quote:
Originally Posted by JeremyBoden View Post
Or you could (carefully) edit /etc/group
For that option, use vigr, it is safer to edit /etc/group with that. Unless you really know what you are doing.
 
2 members found this post helpful.
Old 08-14-2017, 11:37 PM   #6
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Lightbulb

Quote:
Originally Posted by dejank View Post
That is one way to do it. Other would be to use gpasswd on systems not blessed with adduser and friends:

Code:
gpasswd -d user group
didn't know about this gpasswd command..hehehe..

I type man gpasswd on RH, and here is it:

Quote:
Usage: gpasswd [option] GROUP

Options:
-a, --add USER add USER to GROUP
-d, --delete USER remove USER from GROUP
-r, --remove-password remove the GROUP's password
-R, --restrict restrict access to GROUP to its members
-M, --members USER,... set the list of members of GROUP
-A, --administrators ADMIN,...
set the list of administrators for GROUP
Except for the -A and -M options, the options cannot be combined.
 
Old 08-15-2017, 04:35 AM   #7
sigint-ninja
Member
 
Registered: Feb 2011
Location: Republic Of Ireland
Distribution: Debian,Centos,Slackware
Posts: 508

Original Poster
Rep: Reputation: 29
thanks for all the replies

off to linux practice!!!
 
  


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
[SOLVED] How to add a user to a group with a command without removing from another group? erik2282 Linux - Newbie 2 07-12-2017 09:49 AM
User is a Part of a Group But Group Details Do Not Show the User devUnix Linux - Server 6 08-08-2013 07:02 AM
[SOLVED] Problem while removing file by group user soumyacs Linux - Newbie 3 08-28-2012 05:24 PM
Group permissions: user can't access 770 directory even though a member of group jm34003 Linux - Security 13 05-16-2012 02:03 PM
Removing Vol-Group BadKharma Fedora 4 09-29-2007 11:31 AM

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

All times are GMT -5. The time now is 02:48 PM.

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