Skip to content
The Chat Archive
qwen3-235b-a22b-no-thinking· Alibaba (Qwen) LMArena Human Preference 140K

how to reset password on arch linux forget sudo password

  1. User

    how to reset password on arch linux forget sudo password

  2. Assistant

    If you've forgotten the sudo password on Arch Linux (or any Linux system), you cannot reset it directly without root access, because changing passwords requires elevated privileges. However, if you have access to the system via another user with sudo rights or physical access, you can reset the password using one of the following methods.


    🔒 Situation: You're locked out and forgot your sudo password

    ✅ Method 1: Use a Live USB to Reset Password (No Root Access)

    If you don't have any working user with sudo access, this is the most reliable method.

    Steps:

    1. Create a Live USB of Arch Linux or any other Linux distro (e.g., Ubuntu).
    2. Boot from the Live USB.
    3. Mount your installed Arch Linux partition:
      lsblk  # Identify your root partition (e.g., /dev/sda1)
      mount /dev/sda1 /mnt
      
    4. If you have separate boot partitions (like /boot or /efi), mount them too:
      mount --bind /dev /mnt/dev
      mount --bind /dev/pts /mnt/dev/pts
      mount --bind /proc /mnt/proc
      mount --bind /sys /mnt/sys
      mount --bind /run /mnt/run
      
    5. Chroot into your system:
      chroot /mnt
      
    6. Now, reset the password for your user:
      passwd your_username
      
      Or reset the root password (if needed):
      passwd root
      
    7. Exit chroot:
      exit
      
    8. Unmount everything:
      umount -R /mnt
      
    9. Reboot:
      reboot
      

    💡 Replace your_username and /dev/sda1 with actual values from your system.


    ✅ Method 2: Boot into Single-User Mode (if GRUB is accessible)

    This works only if you can edit GRUB entries at boot time and your system uses systemd.

    Steps:

    1. Restart your computer.

    2. At the GRUB menu, press e to edit the kernel boot line.

    3. Find the line starting with linux, go to the end of the line and add:

      init=/bin/bash
      

      or

      rd.break
      
    4. Press Ctrl+X or F10 to boot with the modified line.

      • If using init=/bin/bash, you'll drop into a root shell but filesystems may be read-only. Mount them with:
        mount -o remount,rw /sysroot
        chroot /sysroot
        
      • If using rd.break, continue with:
        rw init=/sysroot/bin/sh
        
        Then after boot:
        mount --remount,rw /sysroot
        chroot /sysroot
        
    5. Once inside, reset the password:

      passwd your_username
      

      or

      passwd root
      
    6. Force SELinux relabel (only necessary if you use SELinux):

      touch /.autorelabel
      
    7. Reboot:

      exec /sbin/init
      

    ✅ Method 3: Use Another Sudo User

    If there's another user with sudo access:

    1. Log in as that user.
    2. Change the forgotten password:
      sudo passwd target_username
      

    🛡️ Tips to Prevent This in the Future

    • Always keep at least one backup admin account with sudo access.
    • Consider enabling SSH access with key-based authentication for recovery.
    • Regularly back up /etc/shadow (encrypted passwords) — though not useful unless restoring).

    ❌ What You Can’t Do

    • You cannot reset the sudo password from within your current user session if you don't have sudo access.
    • You cannot brute-force the password — it’s not ethical or legal without proper authorization.

    Let me know if you need help with specific commands based on your setup (UEFI vs BIOS, encrypted drive, etc.)!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.