Step 1: Boot your Linux system into recovery mode.
To do so, restart your system and press and hold the SHIFT key while booting. You will see the grub boot menu. Choose "Advanced options for Ubuntu" from the boot menu list.
In the next screen, choose "recovery mode" option and hit ENTER.
Next, choose "Drop to root shell prompt" option and hit ENTER key.
You're now in recovery mode as root user.
Step 2: Mount root file system in read/write mode. To do so, type the following command to mount root (/) file system in read/write mode.
$ mount -o remount,rw /
Step 3: Now, add the user that you removed from the sudo group.
In my case, I am adding the user called 'john' to the sudo group using the following command:
$ adduser john sudo
Step 4: Then, type exit to return back to the recovery menu. Select Resume to start your Ubuntu system.
Press ENTER to continue to log-in normal mode.
Step 5: Now check if the sudo privileges have been restored.
$ sudo -l -U sk
sudo
unless: (1) you're using a different account that was created later (2) you removedsudo
permissions from the first account – matigo Feb 06 '23 at 00:38groups <your login ID>
. What does it say? Issudo
one of the groups listed? – Ray Feb 06 '23 at 01:04