1

Recently I accidentally executed the usermod command to add a group to my user; unfortunately I forgot the -a operator, so the command removed all the other groups from my user.

After next login I recognized that I cannot sudo any more.

After research, I restored the /etc/group and /etc/gshadow files from my backup. All groups for my user got successfully restored and now look like this:

[tobias@asterix ~]$ id tobias
uid=1000(tobias) gid=1001(tobias) groups=1001(tobias),0(root),995(audio),991(lp),1000(autologin)

Now I did re-login, but still the same error message:

[tobias@asterix ~]$ sudo ls
[sudo] password for tobias: 
tobias is not in the sudoers file.  This incident will be reported.

I checked the /ect/sudoers, which on the first hand didn't get changed at all in the past, and it already does contain the following line:

root ALL=(ALL) ALL

If I am not mistaken, as my user is already part of the root group, everything should actually be fine.

Maybe somebody can give me a hint of how to completely restore the setup of my system to original behavior?

2
  • 1
    Do you make regular backups of your /etc-directory? This seems a typical backup-and-restore use case... :-#
    – agtoever
    Jan 1, 2019 at 18:35
  • I do make regular backups of my system, but did never restore anything so far except the two files mentioned above by manually copying them in bash.
    – pato
    Jan 1, 2019 at 21:08

2 Answers 2

0

The shown sudoers entry isn't for a group; it's for the "root" user. A group entry would begin with a %.

If you know the root password, use su to switch to the root user, and from there you can fix group memberships and/or add sudoers entries for yourself or whatever group.

If not, then you'll have to use recovery mode, or a live CD. (You can try booting with the kernel option "systemd.debug-shell" to get a recovery shell on Alt+F9.)

In the future, use gpasswd --add / gpasswd --delete to change your group membership instead of using usermod.

0

You are not a member of the right SUDO group, but you are a member of the unix group “root”. So, you may be able to write every file or folder with the rights ---rwx---.

So, you may be to able to create a security privilege escalation by rewriting or changing any file or folder group writable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .