LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   removing a user from a group (https://www.linuxquestions.org/questions/linux-newbie-8/removing-a-user-from-a-group-4175611929/)

sigint-ninja 08-14-2017 07:59 AM

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

jlinkels 08-14-2017 08:05 AM

Code:

deluser the-user group-to-remove-from
It is basically the same syntax as
Code:

adduser the-user group-to-add-to
jlinkels

dejank 08-14-2017 09:39 AM

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

JeremyBoden 08-14-2017 11:12 AM

Or you could (carefully) edit /etc/group

dejank 08-14-2017 11:54 AM

Quote:

Originally Posted by JeremyBoden (Post 5748182)
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.

JJJCR 08-14-2017 11:37 PM

Quote:

Originally Posted by dejank (Post 5748142)
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.

sigint-ninja 08-15-2017 04:35 AM

thanks for all the replies

off to linux practice!!!


All times are GMT -5. The time now is 01:55 PM.