Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
186
rated 0 times [  186] [ 0]  / answers: 1 / hits: 299429  / 2 Years ago, mon, january 31, 2022, 12:08:59

I added a user account to the admin group and discovered I added wrong user. So I now have to remove the account from the admin group.



How can I remove an account from a group without deleting the user?


More From » users

 Answers
7

Portablejim's answer is accurate but dangerous -- if you typo something, your system may be unusable, especially if you alter the admin group improperly. If you must edit the groups file, use the vipw -g or vigr commands, which verify the syntax before saving. Even then, there are better ways.



From a commandline, the one you probably want to use is the following (as root):



deluser <username> <groupname>


This will remove the specified user from the specified group. You must relogin to see the effect. It will not delete the user, or the group, just the membership. There are also ways of doing it with the usermod command, but it's harder to use as you need to replace the entire list of groups for a user in order to remove a single group. The gpasswd command is also capable of doing this (as sagarchalise points out), but is mostly deprecated. As always, see the man pages for more details.


[#42002] Tuesday, February 1, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nnaisdio

Total Points: 369
Total Questions: 112
Total Answers: 108

Location: Kenya
Member since Mon, Jun 14, 2021
3 Years ago
;