LINUX UNIX

[Solved – 6 Answers] UNIX – LINUX – How do you remove a user from a group

  • Which command should you use to remove a user from a group in Debian?
  • When adding a user to a group, it can be done with:
bash code
usermod -a -G group user
  • However, youcould not find a similar command (accepting a group and user as arguments) for removing the user from the group. The closest you could get is:
bash code
usermod -G all,existing,groups,except,for,group user
  • Is there a command like usermod OPTION group user with OPTION an option to make usermod (or a similar program) remove the user from group?

  • Remove user from groups using gpasswd:
bash code
sudo gpasswd -d <username> <group>
  • In this below command.The “a” option is to maintain the groups which your username currently belongs to. The “G” option is to change the group.
bash code
sudo usermod -aG <group> <username>

  • To remove members from a group:
  1. Choose the cog icon , then choose General Configuration under Confluence Administration
  2. Choose Groups in the left-hand panel
  3. Choose the group from which you want to remove the user
  4. Choose the Delete user from group icon next to the user whose group membership you want to remove

  • Edit the /etc/group file as root (i.e. gksudo gedit /etc/group) and remove the username from the line that starts with ‘admin’
bash code
...
admin:x:120:adminuser,adminuser2,userthatshouldnotbeadmin
...

becomes

bash code
...
admin:x:120:adminuser,adminuser2
...

  • From a commandline, the one you probably want to use is the following (as root):
bash code
deluser <username> <groupname>
  • This will remove the specified user from the specified group. If you want, relogin to see the effect.
READ  Use Linux And Miss CCleaner? Check Out These Alternatives

  • You can use the below command on SUSE distributions (and, apparently, no others).
bash code
usermod -R group user_name
  • where group is the group that you want to remove the user from and user_name the user that you want to remove from the group. For example,
bash code
usermod -R root imnottheroot

Css code
           # gpasswd -d user group
  • then the new group config will be assigned at the next login, at least on Debian. If the user is logged in, the effects of the command aren’t seen immediately.

About the author

Wikitechy Editor

Wikitechy Editor

Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.

X