this post was submitted on 25 Dec 2023
9 points (100.0% liked)

Ubuntu Linux

290 readers
36 users here now

Linux for Human Beings.

Ubuntu is a popular Linux operating system for PC / mobile devices, etc.

Developed by Canonical & based on Debian (another older Linux OS) which is known for it's rock solid stability.

Ubuntu is trusted everywhere computing by professionals and common users alike.

https://ubuntu.com/

founded 4 years ago
MODERATORS
 

The problem: Each time I try to execute the sudo command, and type the correct password, it rejects the password.

I am at the end of my rope with internet searches, I’m close to just wiping and trying an operating system reinstall.

I am new to linux and I recently installed ubuntu 22.04.3. I haven’t been able to access the sudo command since the install. I’m currently attempting to install firewalld, but I’m going to need this command for other things as well and I’m starting to wonder if there is something wrong with my install or worse.

Many of the troubleshooting techniques I’ve come across contain a catch 22 in that they require the sudo command to solve this, which I am unable to execute.

Edit: Thanks to everyone who helped me with this issue. Update. I tried a first disk erase and install of ubuntu. During the first attempt I went through the software updates and I did a few things like changing firefox settings before attempting to change my root password. I was unable to change the root password when I attempted to.

Attempt #2. I reformatted and immediately tried to set my root password and this time it worked, and I have had no issues since. So take all of that for what it’s worth.

top 13 comments
sorted by: hot top controversial new old
[–] [email protected] 9 points 8 months ago

If you typed your password wrong too many times you may have been locked out for a certain amount of time (normally 30 mins after 3 wrong attempts). In this situation sudo will not display a different error it will still say the password is wrong. You can clear the failed attempts using the command "faillock --reset". Hopefully that solves it if not check your caps lock, and keyboard layout.

[–] [email protected] 6 points 8 months ago (2 children)

Are you sure you are inputting the right password? For instance, are you sure your keyboard layout is correct? If the keyboard layout is different, you may think you type one thing but type another.

It is also possible that you have simply misspelled the password during setup. A reinstall is the only way to fix that I think.

[–] [email protected] 5 points 8 months ago

It is also possible that you have simply misspelled the password during setup. A reinstall is the only way to fix that I think.

A reinstall is only needed if your forgot your disk encryption passphrase. See my other comment in this thread for how to reset forgotten root and/or user passwords.

[–] [email protected] 4 points 8 months ago

Unless I'm missing something, the sudo password should be the user's password, so unless they've never logged out as their user, they should've already used the password to login. I wonder if they're trying to use the root/su password instead of their own user's

[–] [email protected] 4 points 8 months ago* (last edited 8 months ago) (1 children)

You can boot into recovery mode from the boot menu, which will give you root access without any password. From there you can reset your user password with passwd.

[–] [email protected] 3 points 8 months ago* (last edited 8 months ago)

Or, if recovery mode does ask for a password...you can edit Linux's commandline arguments in the bootloader to add init=/bin/sh and then it will boot to a root shell without a password. the rootfs will be mounted read-only, so, before using passwd you need to first run mount -oremount,rw / to remount it read-write.

then run passwd (to set root's password) or passwd user (to set user's), and then run sync to ensure the changes are flushed to disk, and then sync twice more for superstitious/historical reasons, and then turn the computer off and back on. (the reboot command will not work here.)

[–] display_name1 4 points 8 months ago (1 children)

I am certain I am inputting the same password that I am using for authentication during login. Certain in the sense that I have triple checked that I am typing the correct keys on my laptop keyboard, and the password only contains lower case letters.

In terms of keyboard layout, I have confirmed I am using US. Is there a different password specific for sudo that I am missing here? I've never set the password for root, since this requires the use of sudo and I've never been able to access sudo.

[–] YoorWeb 7 points 8 months ago* (last edited 8 months ago)

sudo - use current user password

su - use root password

Does it say that the user is not "sudoer" or just rejects the pass?

[–] display_name1 2 points 8 months ago

It just says "Sorry, try again" after a failed attempt to enter the sudo password.

[–] display_name1 2 points 8 months ago

So if I boot into recovery mode, and it does end up asking me for a password again, does that imply a bad actor has changed my root password? If that's the case, will a fresh install solve my problem?

I'm very new to linux so I'm not really sure what best practices you should follow after an install. Should you immediately change your root password and install a firewall, first steps taken?

[–] [email protected] 1 points 8 months ago* (last edited 8 months ago)

Are you trying to use the root password when using "sudo" to preface a command? If so, try your own user's pw. As far as I know sudo pretty much always uses the password of the user calling it.

[–] display_name1 1 points 8 months ago

Thanks everyone I was finally able to change my root password after a reformat.

[–] [email protected] 1 points 8 months ago* (last edited 8 months ago)

it rejects the password.

it is the same password you used to log in with your user, so you have to know it. as the other reply suggested, double check your keyboard layout, caps lock, num lock, stuff like that.

check during login process that your password actually is what you think it is (by typing it into the user field) and then do the same in the terminal where you are trying the sudo