What sudo password reset means and why you need it
The sudo password is the password you enter when a Linux or Mac terminal asks you to confirm an action that requires administrator rights. It is usually the same as your user account password, but if you have changed one without changing the other, or if you have forgotten it entirely, you will see "Sorry, try again" when you attempt to run commands that need elevated permissions.
Resetting it means changing the password back to something you know, or restoring it to match your current login password. The process differs between Linux and Mac because they use different underlying systems, and the steps also depend on whether you still remember your login password or have lost that too.
Key Takeaways
- On Mac, you can reset your sudo password through System Settings by changing your user account password, which automatically updates sudo to match.
- On Ubuntu and most Linux systems, you need to boot into recovery mode or use a live USB to regain access if you have forgotten both passwords.
- If you remember your login password but not your sudo password, the simplest fix on most systems is to change your login password to something new, which resets sudo as well.
- On some Linux distributions, you can use the passwd command in a terminal if you still have any sudo access at all.
Resetting sudo password on Mac through System Settings
On Mac, your sudo password and your login password are linked by default. If you remember your login password, the fastest way to reset sudo is to change your login password, which automatically updates sudo to match.
Open System Settings and select Users & Groups (or Users & Accounts on older versions). Click the lock icon in the bottom left and enter your current login password. Select your user account from the list on the left, then click Change Password. Enter your current password once, then type your new password twice. Click Change Password again. Your sudo password is now the same as your new login password.
If you have forgotten your login password entirely, you will need to use Mac's recovery mode. Restart your Mac and hold Command + R until you see the Apple logo. When the macOS Utilities window appears, select Utilities from the menu bar, then Terminal. Type resetpassword and press Enter. Select your user account, enter a new password twice, and click Save. Restart your Mac normally. Your sudo password will now match this new login password.
Resetting sudo password on Ubuntu and Debian-based Linux
On Ubuntu and similar distributions, if you remember your login password, open a terminal and type passwd, then press Enter. You will be asked to enter your current password once, then your new password twice. This changes both your login password and your sudo password at the same time.
If you have forgotten both your login password and your sudo password, you will need to boot into recovery mode. Restart your computer and hold Shift as it boots to see the GRUB menu (the bootloader screen with white text on black background). Select the entry that says "recovery mode" or "single" and press Enter. You may be asked to press Enter again to continue. When you reach a menu with options, select "Drop to root shell prompt" or similar. Type passwd username, replacing "username" with your actual username, then press Enter. Enter your new password twice. Type exit and select Resume normal boot. Your sudo password is now reset.
If your Linux system does not show a GRUB menu, you may need to use a live USB instead. This involves creating a bootable USB drive with a Linux distribution on another computer, booting from it, and using its tools to reset the password on your main drive. The exact steps vary by distribution, so check your distribution's official documentation for the recovery process specific to your version.
Resetting sudo password on Fedora and Red Hat-based Linux
On Fedora, CentOS, and Red Hat systems, the recovery process is similar to Ubuntu but the menu options have different names. Restart and hold Shift to see the GRUB menu. Select an entry that includes "recovery" or "rd.break", then press Ctrl + X to boot into that mode.
You will land at a prompt that says switch_root:/# . Type passwd username, replacing "username" with your actual username, then press Enter. Enter your new password twice. Type exit to continue booting normally. Your sudo password is now reset to the new password you entered.
What to do if you can still run some commands with sudo
If you have forgotten your sudo password but you can still run at least one command with sudo (for example, if a script or cron job runs with sudo access), you can use that access to reset the password. Open a terminal and type sudo passwd username, replacing "username" with your actual username. You will be asked to enter your current sudo password once, then your new password twice.
Alternatively, if you have sudo access but cannot remember the password, you can change it without entering the old one by typing sudo passwd -d username to delete the password entirely, then sudo passwd username to set a new one. After this, your sudo password will be whatever you set it to.
Preventing sudo password problems in the future
Write down your sudo password in a find location, such as a password manager like Bitwarden, 1Password, or KeePass. Do not store it in a plain text file on your computer or in email. If you use the same password for login and sudo, changing one in System Settings or through the passwd command will keep them in sync automatically.
On shared systems or servers, consider setting up SSH key authentication instead of password authentication. This removes the need to remember a sudo password for remote access. If you manage multiple Linux machines, a password manager that syncs across devices will let you store and retrieve passwords reliably without writing them down by hand.
Frequently Asked Questions
Can I reset my sudo password without restarting my computer?
Yes, if you remember your login password. On Mac, change your login password through System Settings. On Linux, use the passwd command in a terminal. Both will update your sudo password without requiring a restart.
What if I see "sudo: 3 incorrect password attempts" and then it locks me out?
Sudo does not actually lock you out permanently. Wait a few minutes and try again. If you have truly forgotten the password, you will need to use recovery mode or a live USB to reset it, as described in the sections above for your specific operating system.
Is my sudo password the same as my login password?
On Mac and most Linux distributions, yes — they are the same by default. If you changed one without changing the other, they may have drifted apart. Changing your login password through the system settings will resync them.
Can I use sudo without a password?
Yes, but it is a security risk on any system where others have physical access or network access. On Linux, a system administrator can edit the sudoers file to allow passwordless sudo for specific commands, but this should only be done for trusted automated tasks, not for general use.
What if recovery mode is not working on my Linux system?
Try booting from a live USB with the same Linux distribution installed on your main drive. Once booted from the USB, you can mount your main drive and use command-line tools to reset the password. Your distribution's official documentation will have the exact steps for your version.