Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Recover a Linux Server After Losing Your Password and Sudo

Use the least invasive path to regain Linux server administration: another sudo account, Ubuntu recovery mode, trusted live media, or the release-specific RHEL boot procedure. This guide covers read-only filesystems, chroot, SELinux relabeling, Debian's disabled-root model, and post-recovery verification.
Length11 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If another local administrator can still use sudo, log in with that account and run sudo passwd USER. If no administrator can log in, use the recovery method that matches the distribution and release: Ubuntu recovery mode, trusted live or installation media, or the documented Red Hat boot-time procedure. These methods grant full root access, so use them only on a server you own or are authorized to administer.

Before changing anything, identify the distribution, release, storage layout, encryption status, and whether you can reach the machine’s console and boot loader. A command that is correct for RHEL 7 may be wrong for RHEL 9, Ubuntu, or Debian.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the least invasive recovery path

Start at the top of this list and stop as soon as you have a working administrator account.

Path Use it when What it changes Main constraint
Another sudo-capable account A second local administrator can log in Resets the affected password and can restore group membership Requires a working account and valid sudo policy
Ubuntu recovery mode The server reaches GRUB but no administrator can log in Opens a root shell from the installed system The recovery root filesystem may start read-only
Trusted live or installation media The installed system will not provide a usable recovery shell Mounts the installed filesystem and repairs it through chroot Requires console access and correctly identified partitions
RHEL boot-time recovery No root login or sudo-capable account remains on Red Hat Enterprise Linux Edits the boot entry and resets credentials before normal startup The procedure differs between RHEL releases

Also check whether the root filesystem is encrypted, whether GRUB is password-protected, whether Secure Boot restricts external media, and whether a cloud provider controls the console. If any of those conditions blocks local recovery, use the provider’s documented rescue workflow rather than improvising.

#1 Best Overall
Kali Linux 2026.2 Bootable USB – Penetration Testing & Ethical Hacking Live OS Installer
  • Portable Kali Linux: Carry the power of Kali Linux on a bootable USB drive for seamless cybersecurity.
  • Live Environment: Pre-configured to boot directly into a 'Live' Kali Linux environment without installation, enabling instant access.
  • Versatile Compatibility: Designed to work with most modern computers and laptops, providing a flexible platform for various tasks.
  • Secure and Encrypted: Kali Linux offers robust security features, encryption tools, and a vast array of penetration testing utilities.
  • Current Version: Kali 2026.2 uses kernel 6.19 and includes GNOME 50 and KDE Plasma 6.6 updates. We will update with newer stable versions of Kali as they are released.

Recovery preparation and safety checks

Confirm authorization and preserve data

Boot-loader and live-media recovery intentionally bypass normal login controls. Confirm that you own the machine or have written authorization to administer it. If the system is unstable, copy critical data from rescue mode before editing account files. Do not experiment on the only copy of a production filesystem.

Record the system identity

  • Distribution and release, such as Ubuntu, Debian, RHEL 7, or RHEL 9.
  • Whether the machine uses BIOS or UEFI and whether GRUB is visible during reboot.
  • Root, /boot, and EFI partition layout; use lsblk -f from a shell or live environment instead of guessing device names.
  • Whether full-disk encryption asks for a passphrase before the operating system starts.
  • Whether the server is physically reachable or relies on a remote console supplied by a hosting provider.

Keep a recovery shell disciplined

In a root shell, every command runs with unrestricted privileges. Type the target username and device path carefully, avoid recursive deletion, and do not overwrite /etc/sudoers with an editor that can leave it syntactically invalid. Use visudo when changing sudo policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When another administrator still has sudo

This is the safest and fastest route because it does not alter the boot process.

  1. Log in to the working local administrator account.
  2. Confirm the account and sudo policy with id and sudo -l.
  3. Reset the affected account: sudo passwd USER. Replace USER with the exact login name.
  4. If the root password itself is lost on RHEL 9, a non-root member of the wheel group can run sudo passwd root.
  5. If the user was removed from the administrative group, restore the distribution-appropriate membership. On Ubuntu this commonly means sudo adduser USER sudo; on Red Hat systems it commonly means sudo usermod -aG wheel USER. Check the release’s policy before applying a group change.
  6. Inspect the account’s login shell and expiry state with getent passwd USER and sudo chage -l USER.
  7. Validate any sudoers edit with sudo visudo -c, then test a new login rather than relying on an already-open session.

Do not reset a password and assume authorization is fixed: a valid password, an interactive shell, group membership, and sudo policy are separate checks.

Ubuntu: use GRUB recovery mode

Ubuntu’s documented recovery route applies when neither root nor another local administrator can log in but the machine can reboot to GRUB.

Rank #2
Beamo Linux Mint Cinnamon 22.3 64-bit Bootable USB Flash Drive - Live USB for Installing and Repairing Linux Mint
  • LINUX MINT 22.3 MEDIA - 16GB bootable USB with Linux Mint Cinnamon 22.3 for compatible x86-64 PCs.
  • LIVE OR INSTALL - On supported hardware, start the Linux Mint live environment to evaluate it or launch the installer.
  • PLATFORM BOUNDARY - Not designed to boot Apple Silicon or other ARM-based computers. Confirm CPU architecture and USB-boot support before purchase.
  • BOOT SETTINGS VARY - Boot-menu keys and UEFI settings differ by manufacturer; consult the computer maker's instructions if the USB is not listed.
  • BACK UP BEFORE INSTALLING - Disk-partition and installation choices can erase files or operating systems. Disconnect nonessential drives and preserve the USB until it is no longer needed for installation or recovery.

Open the recovery root shell

  1. Reboot the server. On many BIOS systems, hold the right Shift key to display GRUB; on many UEFI systems, press or hold Esc. Remote consoles may expose a different key sequence.
  2. Choose Advanced options for Ubuntu.
  3. Select the kernel entry ending in (recovery mode). Choose the normal kernel version unless a known kernel problem requires another entry.
  4. In the recovery menu, choose drop to root shell prompt.
  5. Recovery often mounts the installed root filesystem read-only. Remount it read-write before changing credentials: mount -rw -o remount /.

Reset the account and, if necessary, sudo access

  1. Verify the target name with cut -d: -f1 /etc/passwd or inspect the account directly with getent passwd USER.
  2. Set a new password: passwd USER.
  3. If the account should administer Ubuntu, restore its group membership with adduser USER sudo. Avoid changing the root account merely because the user’s sudo membership was lost.
  4. Check that the shell is valid, for example /bin/bash or another installed shell, and inspect /etc/shells if login still fails.
  5. For a manually edited sudo policy, run visudo -c before leaving the shell.
  6. Type reboot, then test a fresh console or SSH login after normal boot.

Ubuntu warns that this procedure gives a full root shell and can damage the system. Do not leave temporary boot edits in GRUB’s persistent configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recover with a trusted live or installation USB

Use live media when the installed system cannot reach a usable recovery shell, its boot files are damaged, or you need to copy data before repairing it. A writable Linux live USB flash drive is the usual physical medium. Use media you trust and create it from a verified image appropriate to the server’s architecture.

Identify and mount the installed system

  1. Boot the live or installation environment and open a terminal.
  2. List filesystems and labels: lsblk -f. Do not copy a device such as /dev/sda1 without confirming that it is the installed root partition.
  3. Create a mount point and mount the root filesystem, adapting the device and path to the actual layout: sudo mount /dev/ROOT_PARTITION /mnt.
  4. If the installation has a separate /boot, EFI system partition, or separate /home, mount each at its corresponding path below /mnt. An EFI partition normally belongs at /mnt/boot/efi.
  5. If the filesystem is encrypted, unlock it with the proper recovery key or passphrase before mounting. Without that key, password commands cannot reach the installed files.

Enter the installed environment with chroot

Ubuntu’s LiveCdRecovery procedure describes entering the mounted installation with chroot /mnt. For a more complete repair shell, bind the virtual filesystems first:

sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount -t proc /proc /mnt/proc
sudo mount -t sysfs /sys /mnt/sys
sudo mount --bind /run /mnt/run
sudo chroot /mnt /bin/bash

The exact mount options vary with the live environment. If a bind mount reports that the target does not exist, create the directory under /mnt or use the simpler chroot /mnt route for a password-only repair.

Repair credentials inside chroot

  1. Confirm that you are operating on the installed system with cat /etc/os-release and pwd.
  2. Reset the account: passwd USER. To reset root specifically, use passwd root.
  3. Restore the correct administrative group if needed, such as adduser USER sudo on Ubuntu or usermod -aG wheel USER on Red Hat systems.
  4. Check sudo syntax with visudo -c. If the command is unavailable in the chroot, repair the file only with a known-good editor and validate it after reboot from a normal session.
  5. On SELinux-enabled Red Hat installations, ensure relabeling is performed when the release procedure requires it; a common documented step after a boot-time password reset is touch /.autorelabel.

Exit cleanly and reboot

  1. Leave the chroot with exit.
  2. Unmount the virtual filesystems and installed partitions in reverse order. If a graphical live session keeps a directory busy, close file browsers and terminals opened inside /mnt before retrying.
  3. Reboot, remove the USB when prompted, and test the repaired account in a normal boot.

Mounting the wrong partition can make a successful password change appear ineffective because you edited another operating system. Always verify /etc/os-release inside the chroot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
EZITSOL 32GB 9-in-1 Linux Bootable USB Drive for Beginners
  • 1. 9-in-1 Linux:32GB Bootable Linux USB Flash Drive for Ubuntu 24.04 LTS, Linux Mint cinnamon 22, MX Linux xfce 23, Elementary OS 8.0, Linux Lite xfce 7.0, Manjaro kde 24(Replaced by Fedora Workstation 43), Peppermint Debian 32bit (being replaced by MX Linux 32bit) for older PC, Pop OS 22, Zorin OS core xfce 17. The versions you received might be latest than above as we update them to latest/LTS when we think necessary.
  • 2. Try or install:Before installing on your PC, you can try them one by one without touching your hard disks.
  • 3. Easy to use: These distros are easy to use and built with beginners in mind. Most of them Come with a wide range of pre-bundled software that includes office productivity suite, Web browser, instant messaging, image editing, multimedia, and email. Ensure transition to Linux World without regrets for Windows users.
  • 4. Support: Printed user guide on how to boot up and try or install Linux; please contact us for help if you have an issue. Please press "Enter" a couple of times if you see a black screen after selecting a Linux.
  • 5. Compatibility: Except for MACs,Chromebooks and ARM-based devices, works with any brand's laptop and desktop PC, legacy BIOS or UEFI booting, Requires enabling USB boot in BIOS/UEFI configuration and disabling Secure Boot is necessary for UEFI boot mode. Packing: The bootable USB drive comes in a colored PET/CPP zipper bag with instructions on how to get started. The box pictured is not included.

Red Hat Enterprise Linux 9

RHEL 9 documents a special boot-time mode for the case where root login is unavailable and no non-root account can use sudo. The broad sequence is consistent, but kernel parameters and initramfs behavior can vary by minor release, so use the RHEL 9 procedure matching the installed release.

General sequence

  1. Reboot and interrupt GRUB.
  2. Highlight the normal kernel entry and press e to edit it temporarily.
  3. Append the recovery parameter specified by the RHEL 9 documentation for that release to the Linux kernel command line.
  4. Boot the edited entry with the key combination shown by GRUB, commonly Ctrl+X or F10. The edit applies only to this boot.
  5. At the initramfs or special-mode shell, remount the installed system read-write as directed by the release procedure, enter it with chroot when required, and run passwd root or passwd USER.
  6. Preserve SELinux labeling. RHEL procedures commonly require touch /.autorelabel before rebooting after a password reset.
  7. Exit the shell and reboot. Remove the temporary kernel edit; it is not a permanent GRUB setting.

If the reset succeeds but login still fails, check the account’s shell, lock state, PAM policy, and sudo configuration from a normal boot. A root password reset does not automatically restore a deleted administrator account.

RHEL 7: installation media or rd.break

RHEL 7 documents two approaches: booting installation media and stopping early with rd.break. The latter interrupts the handoff from initramfs to systemd.

Using rd.break

  1. At GRUB, highlight the kernel entry and press e.
  2. Find the line beginning with linux or linux16 and append rd.break.
  3. Boot the temporary entry.
  4. Remount the installed root under /sysroot read-write: mount -o remount,rw /sysroot.
  5. Enter the installed system: chroot /sysroot.
  6. Reset the password with passwd root or passwd USER.
  7. For SELinux systems, mark the filesystem for relabeling with touch /.autorelabel.
  8. Run exit to leave the chroot, then exit again to leave the break shell, and reboot.

Because the kernel-line change is temporary, it disappears after reboot. If the server uses a different storage layout or an encrypted volume, unlock and mount it according to the installation’s configuration before running passwd.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Using RHEL installation media

Boot the installation disk and select its rescue option. The rescue environment may locate and mount the installed system for you, after which you can chroot into the mounted root and run the same account commands. Confirm the mount point and inspect /etc/os-release before editing.

Rank #4
EZITSOL USB for Ubuntu 24.04 & 22.04 64bit,Lubuntu 18.04 32bit | 3IN1 Bootable Linux USB flash drive/Stick,Jump Drive,Pendrive,Thumb drive
  • 3-in-1: 16GB Multiboot USB flash drive for Ubuntu 24.04 LTS 64bit & 22.04 LTS 64bit, Lubuntu 18.04 LTS 32bit. All are LTS versions, namely, Long Terrm Support Version. The versions you received might be latest than above as we update them when we think necessary.
  • Compatibility: Compatible with any brand's PC, works with both legacy BIOS and UEFI booting mode, except for Apple computers, Chromebooks and ARM-based devices.
  • Popularity:Most popular linux distributions and all come with common software includes office software, web browser, image editing, multimedia, and email except Lubuntu which is desgined to targted for very old PC.
  • Support: Print user guide and support available. please contact us for help if you have an issue.
  • Live USB or install: You can either try on USB or install on hard drive.

Older Red Hat rescue, single-user, and emergency modes

Older Red Hat documentation distinguishes three modes that are not interchangeable:

  • Rescue mode is useful for accessing files when the installed system cannot complete a normal boot.
  • Single-user mode provides a restricted administrative environment suitable for a password reset on systems that support it.
  • Emergency mode is more minimal and mounts the root filesystem read-only, so you must remount it read-write before changing anything.

Do not assume an older GRUB recipe works unchanged on a newer release. If a mode presents a read-only root, use the remount command appropriate to that environment, verify the target filesystem, and follow the release-specific Red Hat instructions.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Debian: the root account may be disabled by design

Debian commonly disables direct root login during installation and gives the first created user administrative ability through sudo. In that configuration, a lost user password or removed sudo authorization is not solved by merely setting a root password: there may be no usable root password at all.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Repair the first user’s access

Use Debian recovery mode if GRUB is available, or a trusted live medium and chroot if it is not. Reset the affected user’s password with passwd USER, then restore that user’s sudo authorization according to the installed policy. Inspect /etc/sudoers and files under /etc/sudoers.d with visudo -c. Create a root password only if your security policy specifically requires direct root access; keeping root disabled and using sudo may be the safer Debian model.

Verify the repair after normal boot

A password command can succeed while another account setting still blocks access. Perform these checks after reboot:

Best Value
Tails Linux Bootable USB for Private Live Use on PC
  • Dual USB-A & USB-C Bootable Drive – works with almost any laptop or desktop (UEFI & Legacy BIOS). Boot Tails directly from the USB for secure, private sessions on any computer.
  • Customizable Outside Tails – you may Add / Replace / Upgrade any other compatible bootable ISO app, installer, or utility on the USB without modifying Tails itself. You can also update Tails at any time by adding the latest Tails ISO.
  • Designed for Privacy & Anonymity – Tails routes all internet traffic through Tor for maximum online privacy and protection against tracking or surveillance. Leave No Trace – your sessions run entirely from the USB and don’t touch the host system. When you shut down, no activity or data remains on the computer.
  • Bypass Censorship & Access the Web Freely – browse and communicate securely from anywhere with built-in encryption and privacy tools. No Installation Required – run Tails LIVE directly from the USB. Perfect for journalists, researchers, or anyone who values freedom and security online.
  • Premium Hardware & Reliable Support – built with high-quality flash chips for speed and longevity. TECH STORE ON provides responsive customer support within 24 hours.
  • Log in with a new session, not an old SSH connection.
  • Confirm the account’s shell with getent passwd USER; a shell set to /usr/sbin/nologin or a nonexistent path prevents interactive login.
  • Check lock and expiry state with passwd -S USER and chage -l USER.
  • Confirm group membership with id USER. Group changes may require logging out and back in before they take effect.
  • Run sudo -l -U USER from an administrator account and validate policy syntax with visudo -c.
  • Test the exact access method you need: console login, SSH, or the service account’s noninteractive operation.
  • Review authentication logs for a rejected login, expired account, denied shell, or PAM error if the new password still fails.

When the standard procedures do not apply

Encrypted root storage

You cannot repair files inside an encrypted root volume until it is unlocked. Obtain the recovery passphrase or key from the authorized owner. Do not erase or recreate the volume in an attempt to bypass it.

GRUB protection or inaccessible console

A GRUB password, a server with no physical console, or a remote-only machine can prevent the Ubuntu and RHEL boot paths. Use the organization’s out-of-band console or the hosting provider’s documented rescue process. Provider-specific behavior is configuration-dependent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Secure Boot and external media

Secure Boot policy may reject a live image or unsigned boot component. Use a trusted, signed recovery image approved for the machine, or follow the platform’s documented enrollment and recovery procedure.

The filesystem will not mount read-write

Stop changing passwords until storage is healthy. A filesystem that remains read-only may have errors, failed hardware, or an active encryption or RAID problem. From a rescue environment, copy critical files first and run the distribution-appropriate filesystem checks only on an unmounted filesystem.

Prevent a repeat lockout

  • Keep at least two tested administrator accounts, each with individually managed credentials.
  • Store recovery keys, console access details, and the distribution release in an authorized runbook.
  • Test a recovery boot on non-production hardware so the team knows how its GRUB, encryption, and remote console behave.
  • Use a password manager or approved SSH-key process, with a documented way to revoke lost credentials.
  • Review sudo policy after staff or role changes and validate it with visudo -c.
  • Keep current backups and verify that a rescue environment can read the backup target.

Frequently Asked Questions

Can I reset a Linux password without knowing the old one?

Yes, if you have authorized root access through another sudo-capable account, the distribution’s recovery mode, or trusted live media. These methods are administrative recovery paths, not ordinary user password changes.

Why did changing the password in a live USB environment have no effect?

The installed root partition may not have been mounted, or the wrong partition may have been mounted. Inside the chroot, verify /etc/os-release and the account entry before running passwd.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What if the password works but sudo still fails?

Check the account’s group membership, sudoers syntax, shell, lock state, and expiry. On Ubuntu the administrative group is commonly sudo; on Red Hat it is commonly wheel, subject to the system’s policy.

Is a root-password reset possible on an encrypted server?

Only after the encrypted volume has been unlocked with its authorized key or passphrase. Boot recovery cannot bypass encryption.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.