I accidentally added my user myuser
to the group root
using the command sudo usermod -a -G root myuser
. Now I want to remove myuser
from roots
, but I am unable to do so. I tried the following:
deluser myuser root
sudo gpasswd -d myuser root
but I get the message
`Removing user myuser from group root
gpasswd: user 'myuser' is not a member of 'root'
I also tried sudo vipw
, which supposedly allows me to edit the /etc/group
file, which has the following:
root:x:0:0:root:/root:/bin/bash
and sudo vipw -g
and sudo vigr
have the following:
root:x:0:
which I think indicates that myuser
is not in the root
group. However, I know myuser
is in the root
group because when I su myuser
and enter groups
, I get the following groups:
root sudo
So, how can I remove myuser
from the root
group?
UPDATE
Note that the command groups
output the following:
root sudo
whereas normally it should output
myuser root sudo
which means that something went awry when creating the myuser
account, and that root
is my primary group (first in the list). I believe this was the cause of my problem.
I believe this issue was resolved by my answer below where I think root
was my primary group, blocking my ability to remove it as a group. I think this question might be helpful for others, but if I should delete it altogether, just let me know and provide an explanation.