How do I remove a user from a group? I'm using the usermod command but its not working.
I have a user "abc" who is a member of the groups root and other. I'm trying to remove him from the group "other" (using CLI) which is his secondary group but it's not working.
How do I do this? Is there any other command that I am supposed to use instead of usermod??
vi /etc/group
Ur doing right ... Do with usermod -g <Primary> -G <Secondry> <Username>
the above should work with out any proble..
=Hari.A.
Well, it's not working. That's why I ended up posting it here!! Let me rephrase my doubt. I don't want make the user a member of any secondary group. He should continue to be a member of the primary group but I want to delete him from his secondary group. Usermod is not working.
Again, as I'm afraid you missed it:
vi /etc/group
Hey jlliagre,
I saw that the first time you posted.
Two issues:
- I'm trying to find out if I can do it using usermod.
- I have no clue how to edit the /etc/group to remove a user from there. The entry in the file is [other::1:]
So, here I am scratching my head how to edit that and remove him from the group!!
---------- Post updated at 03:50 PM ---------- Previous update was at 03:45 PM ----------
In case if my command worked and removed the user from the group, why is it still showing the group 'other' when I say [groups user]??? I'm totally lost!!
---------- Post updated at 07:32 PM ---------- Previous update was at 03:50 PM ----------
Guys,
Thanks for your support and all the suggestions. The user "was" removed from the group but it was only updated after reboot. I think I'll give it a break before I start to think why I needed a reboot!!
---------- Post updated at 07:33 PM ---------- Previous update was at 07:32 PM ----------
Guys,
Thanks for your support and all the suggestions. The user "was" removed from the group but it was only updated after reboot. I think I'll give it a break before I start to think why I needed a reboot!!
This is odd. Changing group users in /etc/group shouldn't require a reboot. It doesn't here.
Another tip, after editing that file, run the grpck command (and pwck after editing /etc/passwd).
or try doing it in a quick and dirty way.
Remove the user, preserving the home directory. Recreate the user.
@jlliagre: I didn't edit the /etc/group file at all!! I was goofing around with the usermod command. When I opened the file the user name was not in the group.
@incredible: I am not deleting user and recreate but just removing him from a group.
Use "-G" with blank quotes on the user ID to remove them from the secondary group.
i.e.)
bash-3.00# usermod -G other user1
bash-3.00# groups user1
staff other
bash-3.00# usermod -G "" user1
bash-3.00# groups user1
staff
bash-3.00#
Yep! Thanks kharjahn.
Hi! Yes thats right i thinks you are missing /etc/group other wise go try with Chmode --help for list of multiple commands you may perform.