checking how to reset sudo and root password on Ubuntu 21.04

Aaron Rainbolt arraybolt3 at gmail.com
Fri Oct 14 20:13:29 UTC 2022


On Fri, Oct 14, 2022 at 12:43 PM Marco Fioretti <mfioretti at nexaima.net> wrote:
>
> Greetings,
>
> I recently recovered an Ubuntu 21.04 box I had set up back then, and then "leased" to a relative.
> I will upgrade it asap to 22.04 LTS, BUT, for reasons not relevant here, while doing backups and
> generally "cleaning up" that box:
>
> 1) I made a mistake, issuing a chown command in /, thus messing up, among other things,
>     ownership of critical files in /etc/, so now sudo does not work anymore

Ouch. There isn't really a good way to fix this with 100% accuracy
that I know of. A reinstall will be needed. However, you'll probably
be able to back it up without needing to boot into a live USB.

> 2) AND I forgot the root password, so I cannot just "su" and fix those ownerships manually
>
> 3) but again, I have to fix those ownerships and other stuff, and back up before upgrading.

I'd boot into recovery mode at this point. If you're on a BIOS system,
press and hold Shift during early boot until you get a GRUB screen. On
EFI systems, press Esc at just the right moment during early boot
(might be tricky to find the exact spot to do this at). When the GRUB
menu pops up, select "Advanced Option for Ubuntu", then select the
second entry (it should say "(recovery mode)" in it). You use the
arrow keys to move around and the Enter key to select an opion.

Once you're booted into recovery mode, select the "root" option to
drop to a shell, then run "mount -o remount,rw /" to gain write access
to the root drive. At this point, you can plug in an external drive,
find the external drive with lsblk, mount it to /mnt, and then use cp
or rsync to copy your important data to the external drive.

> I know I could boot a live distro and work from there but I have very slow connectivity right now,
> AND I want to refresh my skills for these situations  anyway, just to have more alternatives.
>
> So, since I CANNOT risk to mess up that box even more, I would really appreciate a confirmation
> that the root password reset procedure described here:
>
> https://unixcop.com/how-to-reset-root-password-on-ubuntu-21-04/
>
> is 10% complete and correct for Ubuntu 21.04, and if there are better ways to reset a root password at the prompt, without using
> a live distro.

No need to do any root password reset or anything. Just back up your
data and reinstall the whole OS from scratch. You won't be able to
easily fix a permissions issue like this. Sorry that you're stuck in
this mess, and good luck! We're here to help if something is still
tricky to work with.

> TIA,
> Marco
>
>
>
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

-- 
Aaron Rainbolt
Lubuntu and Ubuntu Member
https://github.com/ArrayBolt3
https://launchpad.net/~arraybolt3
@arraybolt3:matrix.org on Matrix, arraybolt3 on irc.libera.chat



More information about the ubuntu-users mailing list