Score:1

Unable to access sudo in Ubuntu virtual machine

mc flag

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.

in flag
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
Yash Khasgiwala avatar
mc flag
@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.
cn flag
Ray
In a terminal, type `groups <your login ID>`. What does it say? Is `sudo` one of the groups listed?
user535733 avatar
cn flag
"*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?
Yash Khasgiwala avatar
az flag
@karel Thanks I resolved my issue using that link.
Score:1
kw flag

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

Yash Khasgiwala avatar
az flag
Thanks, I entered the recovery mode and edited the \etc\sudoers list and added myself in the sudoers list.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.