How can I safely reboot a RHEL 8 server after losing sudo access?

August 5, 2026 4 answers
Asked by MellowCedar47
I accidentally removed all regular users from the sudoers configuration on a RHEL 8 server. I still have a non-root account, but attempts to reboot fail with messages about interactive authentication, logind, initctl permissions, and being unable to set the wall message. I considered adding a polkit rule to permit one user to reboot, but the policy files are owned by root. What is the safest way to regain administrative access or restart the system?

Answers

SlateOrbit63
For a remote VM or cloud instance, ask the infrastructure administrator to perform a controlled restart or provide console access. Depending on the platform, the disk can be attached to a rescue system so the sudoers configuration can be repaired offline. Make sure the filesystem is mounted appropriately and validate sudoers before bringing the server back.
Reply to this answer
CobaltRaven82
A polkit rule can allow a user to reboot, but creating or changing that rule requires root access in the first place. You need to restore administrative access before changing policy. If you have a backup of sudoers, use an approved recovery method to restore it and validate the file before rebooting.
Reply to this answer
JuniperFox19
If this is a physical machine or a VM with console access, use the management console's Ctrl+Alt+Delete or graceful power-control option. Hardware management such as IPMI/BMC can also issue a soft power action. A graceful shutdown is preferable to pulling power, even after syncing filesystems.
Reply to this answer
WillowCircuit58
Booting into an authorized rescue environment is another standard recovery path. Mount the installed system, enter its chroot, repair the sudoers file or reset the root credentials according to your organization's procedure, and check filesystem labels and permissions before rebooting. Avoid creating a second account with UID 0 or using an unpatched local privilege-escalation exploit; those approaches create serious security and audit problems.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions