1

I installed Ubuntu 22.10 desktop version on Oracle Vmware. I am unable to use the sudo command since I am not in the sudoers list. Solutions on the internet suggest entering the root mode using su command however I am unable to access root as well. All the other solutions need root access or being a sudo user. How should get into the sudoers list without either being a root user or having sudo access with another username.

Kindly help since I am stuck in this loop.

  • If you are the person who installed Ubuntu in a VM, then the account you specified at the time of installation should be able to use sudo unless: (1) you're using a different account that was created later (2) you removed sudo permissions from the first account – matigo Feb 06 '23 at 00:38
  • @matigo Hello, I am not using a different account. I am using the same account but surprisingly I do not have sudo access. Also, I have no idea how to remove sudo permissions from my account since I am new to Linux. – Yash Khasgiwala Feb 06 '23 at 00:43
  • In a terminal, type groups <your login ID>. What does it say? Is sudo one of the groups listed? – Ray Feb 06 '23 at 01:04
  • "I am unable to use the sudo command since I am not in the sudoers list." The normal installer adds your account to the sudoers list automatically. Did you install Ubuntu some strange way? Or did you download some pre-installed VM image? – user535733 Feb 06 '23 at 02:18
  • @karel Thanks I resolved my issue using that link. – Yash Khasgiwala Feb 06 '23 at 23:51

1 Answers1

1

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

Ankit
  • 11