Lost sudo access after a Debian update, even though root is disabled

0
4
Asked By MellowCedar42 On

I'm running Debian 13.7 (Trixie) with GNOME Shell 48.7. GNOME showed a notification saying that an update was ready to install and required a restart, but it didn't identify the update. After rebooting, my account suddenly appeared to have lost sudo access. Running sudo reports that I'm not in the sudoers file, even though my account still appears in the sudo group. The root account was disabled during installation because I left its password blank, so I can't use su or log in as root. Recovery mode hasn't been useful either. How can I restore administrative access, why would disabling root be recommended if this can happen, and how can I determine which update or configuration change caused the problem?

4 Answers

Answered By SilverHollow21 On

The security recommendation is not that disabling root can never cause inconvenience; it is that having no usable root password reduces the chance of direct root logins and encourages controlled administrative commands through sudo. You should still keep a tested recovery method, such as a Debian installer USB, and make sure you know your disk layout. On a normal Debian installation, an update should not remove sudo access from the first user, so an unexpected change deserves investigation rather than being treated as normal behavior.

Answered By NorthVale88 On

The update history can usually be reconstructed after the fact. Check `/var/log/apt/history.log`, older rotated files such as `/var/log/apt/history.log.1`, and `/var/log/dpkg.log`. `journalctl --since 'yesterday'` can show the boot, package, and authentication events around the restart. Also inspect `/etc/group`, `/etc/gshadow`, `/etc/sudoers`, and `/etc/sudoers.d/` for a package or manual change. If the account remained in the sudo group and access started working again without a repair, a transient session or group-resolution problem is more likely than an update deliberately removing privileges.

Answered By OrbitingPine7 On

First check the exact failure and whether the account is really in the expected group. Run `id`, `groups`, `getent group sudo`, and `sudo -l`. If `sudo -l` now shows that your account may run all commands, then sudo access has already returned and the earlier failure may have been temporary. A reboot, stale group information in a running session, or a problem with name-service/group lookup can make the result look inconsistent. Log out completely and back in, then test again. Also check that `/etc/sudoers` still includes the normal Debian rule, usually `%sudo ALL=(ALL:ALL) ALL`, using `visudo` when you have access.

QuietMaple19 -

Seeing the username in `/etc/group` is useful, but `id` and `getent group sudo` are better checks because they query the system’s group database. If those disagree, investigate NSS configuration or cached identity data rather than immediately changing sudoers.

Answered By CopperLark6 On

Disabling the root password does not remove the root account or make recovery impossible. It prevents password-based authentication as root, while the first normal user is normally placed in the `sudo` group. If that account loses sudo privileges, boot a Debian installer or live USB, choose a rescue shell or open a terminal, and mount the installed system. For a typical single-partition installation, identify the partition with `lsblk`, mount it at `/mnt`, then enter it with a chroot. You may need to mount `/dev`, `/proc`, `/sys`, and `/run` first. From the chroot, run `usermod -aG sudo your_username`, verify the sudoers file with `visudo -c`, and repair it if necessary. Another option is to boot the installed system with a temporary `init=/bin/bash` kernel parameter, remount the root filesystem read-write, make the repair, and reboot, though the live USB method is generally less error-prone.

AmberWicket3 -

Before editing anything, make a backup of `/etc/passwd`, `/etc/group`, `/etc/sudoers`, and `/etc/sudoers.d`. Do not replace the whole sudoers file with a random example; use `visudo` or restore the normal group rule carefully.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.