User is not in the sudoers file

After the reboot I tried running sudo powertop --sample to monitor my laptops battery, but now the terminal throws an error saying user_name is not in the sudoers file.

After a brief google search, I tried running the following command as root:

usermod -a -G wheel user_name

But this didn’t work. I’m still looking for a solution on my own, but I would be very grateful if any of the more experienced users in the community could point me in the right direction.

It may be worth starting your own, separate thread. But for starters, what is the output of

groups
1 Like

Thank you for the reply! the output is:

root

Although I don’t think that should be fatal, it does seem worse than what I was expecting. So I think I will let someone with more knowledge take over.

1 Like

Alright, thanks for trying :slight_smile:

This should probably be something more like

sys network wheel $USERNAME

Can we get a feel for your user?
Is it supposed to be a regular user with admin privileges?
Is this the sole user on the system?

We might get a better idea simply looking at the passwd file;

cat /etc/passwd

(dont worry - as you can see in the file, passwords are not stored here literally)

Feel free to edit out your username or use something like

sed "s/$USER/USER/gI" /etc/passwd

We will similarly want to view the output of your sudoers file.

sudo cat /etc/sudoers

We can also give it a quick syntax/sanity check with

sudo visudo -c

There was also a .pacnew for sudoers today, albeit that it’s probably not pertinent. But at least the OP is hereby alerted to the fact that they need to merge their .pacnew(s).

Almost included it -drat- but of course it wouldnt have killed all groups.

We can at least ask for the check though.

pacdiff -o
1 Like

Can we get a feel for your user?
Is it supposed to be a regular user with admin privileges?
Is this the sole user on the system?

Sure thing! Yes and yes. I created it during installation a few days ago.

cat /etc/passwd output:

root:x:0:0::/root:/usr/bin/bash
nobody:x:65534:65534:Kernel Overflow User:/:/usr/bin/nologin
dbus:x:81:81:System Message Bus:/:/usr/bin/nologin
bin:x:1:1::/:/usr/bin/nologin
daemon:x:2:2::/:/usr/bin/nologin
mail:x:8:12::/var/spool/mail:/usr/bin/nologin
ftp:x:14:11::/srv/ftp:/usr/bin/nologin
http:x:33:33::/srv/http:/usr/bin/nologin
systemd-coredump:x:980:980:systemd Core Dumper:/:/usr/bin/nologin
systemd-network:x:979:979:systemd Network Management:/:/usr/bin/nologin
systemd-oom:x:978:978:systemd Userspace OOM Killer:/:/usr/bin/nologin
systemd-journal-remote:x:977:977:systemd Journal Remote:/:/usr/bin/nologin
systemd-resolve:x:976:976:systemd Resolver:/:/usr/bin/nologin
systemd-timesync:x:975:975:systemd Time Synchronization:/:/usr/bin/nologin
tss:x:974:974:tss user for tpm2:/:/usr/bin/nologin
uuidd:x:68:68::/:/usr/bin/nologin
dnsmasq:x:973:973:dnsmasq daemon:/:/usr/bin/nologin
_talkd:x:972:972:User for legacy talkd server:/:/usr/bin/nologin
polkitd:x:102:102:User for polkitd:/:/usr/bin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/usr/bin/nologin
rpcuser:x:34:34:RPC Service User:/var/lib/nfs:/usr/bin/nologin
avahi:x:969:969:Avahi mDNS/DNS-SD daemon:/:/usr/bin/nologin
colord:x:968:968:Color management daemon:/var/lib/colord:/usr/bin/nologin
cups:x:209:209:cups helper user:/:/usr/bin/nologin
flatpak:x:967:967:Flatpak system helper:/:/usr/bin/nologin
fwupd:x:966:966:Firmware update daemon:/var/lib/fwupd:/usr/bin/nologin
gdm:x:120:120:Gnome Display Manager:/var/lib/gdm:/usr/bin/nologin
geoclue:x:965:965:Geoinformation service:/var/lib/geoclue:/usr/bin/nologin
git:x:964:964:git daemon user:/:/usr/bin/git-shell
gnome-remote-desktop:x:963:963:GNOME Remote Desktop:/var/lib/gnome-remote-desktop:/usr/bin/nologin
libvirt-qemu:x:962:962:Libvirt QEMU user:/:/usr/bin/nologin
nm-openconnect:x:961:961:NetworkManager OpenConnect:/:/usr/bin/nologin
nm-openvpn:x:960:960:NetworkManager OpenVPN:/:/usr/bin/nologin
openvpn:x:959:959:OpenVPN:/:/usr/bin/nologin
passim:x:958:958:Local Caching Server:/usr/share/empty:/usr/bin/nologin
qemu:x:957:957:QEMU user:/:/usr/bin/nologin
rtkit:x:133:133:RealtimeKit:/proc:/usr/bin/nologin
saned:x:956:956:SANE daemon user:/:/usr/bin/nologin
transmission:x:169:169:Transmission BitTorrent Daemon:/var/lib/transmission:/usr/bin/nologin
usbmux:x:140:140:usbmux user:/:/usr/bin/nologin
MY_USER_NAME:x:1000:1000:MY_FULL_NAME:/home/mendez382:/bin/zsh
nvidia-persistenced:x:143:143:NVIDIA Persistence Daemon:/:/usr/bin/nologin

I changed my username to MY_USER_NAME and my full name to MY_FULL_NAME in the second to last line.

EDIT: I could not run the second command you gave me (sudo cat /etc/sudoers)with sudo, so I enabled root privileges with su root and tried again. It gave me no output.

The command sudo visudo -c gives me the following output running it as root:

/etc/sudoers: parsed OK

EDIT 2: I could not run the command below. It says command not found. I thought perhaps it is a tool that I need to install but pamac can’t find it either:

pacdiff -o

1 Like

That looks roughly correct.

Oh, the tools were split from the pacman package.
pacdiff (and some others) comes from pacman-contrib package.

Weird.

Actually I just checked - and indeed visudo finds no fault with an empty file.

Do you have the sudo package?
It should provide those files along with the tool.

Was this a relatively new install (if so - which ISO)?
And it was working previous (sudo included)?
Did your update complete successfully?

(a possible check would be in the pacman log: /var/log/pacman.log)

We can certainly begin by trying to fix sudo with

sudo pacman -Syu sudo --overwrite '/etc/sudoer*'

Or, if sudo is not working and from root/su

pacman -Syu sudo --overwrite '/etc/sudoer*'

We can similarly begin fixing groups with

sudo gpasswd -a MY_USER_NAME sys 
sudo gpasswd -a MY_USER_NAME network
sudo gpasswd -a MY_USER_NAME wheel
sudo gpasswd -a MY_USER_NAME MY_USER_NAME

(the last one is not in error - your should be a member of your group)

But that may only be the beginning.
As yet we cannot be sure of the source of the original discrepancies or how deep it goes.

Do you have the sudo package?
It should provide those files along with the tool.

Yes, doubled checked it using pacman -Qs.

Was this a relatively new install (if so - which ISO)?
And it was working previous (sudo included)?
Did your update complete successfully?

It is less than a week old. This is the GNOME ISO (stable branch). I know sudo was working before the upgrade because I ran powertop right after booting the first time, so I could monitor my laptop’s battery. The command worked as expected.

After updating the system with pamac (using the GUI method) the software center told me the update was successful, but a restart was required. I encounter the issue after that.

However, I don’t think the update was actually successful as running pacman -Syu as you instructed found quite a lot of pending updates.

Fortunately, all your questions about my ISO reminded me that I selected btrfs as my filesystem during installation!

I was able to restore my system using a snapshot of three days ago and after checking that I could use sudo normally again, I updated my system running pacman -Syu instead of using pamac. One reboot later and I’m having no issues, so I guess this is it? :laughing:

Thank you so much for taking the time to help me, you are the best!

1 Like

Glad it worked out. :slight_smile:

You still may have pacnews to manage as mentioned previously.

Heres a guide on that if needed:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.