To me it looks very much like I will end up having to install Linux again
Of course that is an option for you, but if you have created or copied important data to the install or have settings you want to keep, you might want to protect those first.
Other than that - I don't suppose you had Timeshift installed and a snapshot taken, did you? If so, we can use that.
Next option is to do with
I do have the Ubuntu USB that I installed it from.
Here is where we can use chroot.
chroot is a process whereby we can
change our Live User to becoming the
Root user of our installed OS. It might be to change, install, fix a broken Grub bootloader, or to change other processes such as how our computer boots, and so on.
In this case, we can use it to give you back sudo privileges. So without further ado
PROCESS 1
1. First, establish what partitions your Ubuntu Cinnamon is on. For example, if you are on a computer which has UEFI/GPT you might have /dev/sda1 as your EFI System Partition (likely FAT32, 100 - 500 MiB) and your root partition for Ubuntu on /dev/sda2.
In Terminal, you can use
df or lsblk to establish these identifiers, your root partition will have a / in the output
Also get that output from
groups
and write them all down.
2. Boot/reboot your computer into the Live USB stick environment, it might involve using F12 or the key you have assigned, to get the boot menu and choose the Live USB option.
Once you get into the Live booting, choose Try Ubuntu, not the install, this will bring you to the desktop.
3. (Optional) At the Live Desktop, I always modify my Settings to increase my mouse cursor size, turn off any screensavers and Power saving options.
4. Open Terminal (from the Menu, or Ctrl-Alt-t). Your Terminal prompt will look something like
ubuntu-cinnamon@ubuntu-cinnamon:~$
Type in and Enter the following
sudo parted -ls # OR just lsblk (I use)
and establish that your Ubuntu Cinnamon matches what you had written down.
Then type in and Enter the following lines (where /dev/sdxy is what you have written for your Ubuntu root partition, and /dev/sdxz is if you are running on UEFI-GPT)
Code:
sudo mount /dev/sdxy /mnt
sudo mount /dev/sdxz /mnt/boot/efi
for i in /sys /proc /run /dev /dev/pts; do sudo mount --bind "$i" "/mnt$i"; done
OPTIONAL sudo cp /etc/resolv.conf /mnt/etc/ (did not work for me this time)
sudo chroot /mnt
5. If you are successful with the above, you will now be in your Ubuntu Cinnamon install, and the Terminal prompt will have changed to something like
root@ubuntu-cinnamon:/#
The "root" and the # are evidence that you are chrooted successfully.
Let's check that for sure.
6. Type in and enter
cat /etc/os-release
you should get something like
Code:
PRETTY_NAME="Ubuntu 23.04"
NAME="Ubuntu"
VERSION_ID="23.04"
VERSION="23.04 (Lunar Lobster)"
VERSION_CODENAME=lunar
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=lunar
LOGO=ubuntu-logo
So we are in Ubuntu Cinnamon, as Root, and can fix our sudo privileges.
PROCESS 2
7. First we will check the file /etc/sudoers and amend if necessary, and then we'll add our self to the sudo group.
Whereas with any other text file, we might use the Nano console-based text editor to edit, or the GUI-based gedit or other editor to change things, with /etc/sudoers, it is important to use
visudo
to edit the file, so we do not break it or corrupt it. If you have used Nano, you will see the similarities.
My comments have a # preceding them, they are not a command.
Make sure exists line as follows
Code:
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
... if not, add it. If added, you will need to exit the modified file, saving changes, which involves using Ctrl-x and pressing enter when it displays the file name, and Y for Yes.
8. Now we'll add ourselves to the sudo group.
Then check (and give us the output for)
groups
If it includes dave, we're good.
9. If you want to get that Recovery option, then while we are chrooted is a good time.
For permanent change you'll need to edit your /etc/default/grub file:
nano /etc/default/grub
Place a # symbol at the start of line GRUB_HIDDEN_TIMEOUT=0 to comment it out. If that line doesn't exist, then you can comment out this line instead: # GRUB_TIMEOUT_STYLE=hidden, and then change GRUB_TIMEOUT=0 to GRUB_TIMEOUT=5, for instance (I use 10 seconds), to give the grub menu a 5 second timeout before it automatically logs you in.
Also make sure that you amend, if necessary, to have
GRUB_DISABLE_RECOVERY="false"
or just place a # in front of the "true" line. Then you can always use Recovery from your Advanced Options submenu, which is easier than chroot.
Exit Nano the same way you did with visudo.
Save changes and run update-grub to apply changes.
10. To exit chroot, you can use
Ctrl-d or exit.
Then type in and enter
reboot
Let us know how you go.
Wizard