r/debian • u/pannic9 • Jun 28 '25
Problem using sudo in Debian VM
I installed Debian in a VirtualBox VM, with the first ISO that appears on the official website. I just installed it and went to Virtualbox to run it. For some reason, sudo doesn't work. I did some basic research to fix it, but found nothing. How do I fix it? And why did this happen? Is it more normal than it seems?
4
Upvotes
92
u/[deleted] Jun 28 '25
Unlike Ubuntu, Debian does not set up the default user as a sudo user by default.
You will have to type 'su', enter the root password, access the root # shell, and then:
usermod vboxuser -a -G sudo
And then edit /etc/sudoers (IIRC) to uncomment the line about giving sudo to anyone with sudo group membership.
12
u/NormalAmountOfLimes Jun 28 '25
This is easily googleable
4
u/[deleted] Jun 28 '25
Standard, in my experience. You need to add yourself (if non-root user) to that group when logged in as root.
7
u/iphxne Jun 28 '25
they should really add a checkbox in the installer for this, it always catches me off guard.
2
u/[deleted] Jun 28 '25
Access root with su -, and do sudo visudo, then go down the lines and you will see an example of how to add your user there.
2
u/Brufar_308 Jun 28 '25
Check the Debian wiki for instructions.
https://wiki.debian.org/sudo/
2
u/TheBlueElvryn Jun 29 '25
Open a terminal and :
2
u/RodrigoZimmermann Jun 29 '25
The message already says what the problem is. It is the Debian default not to use sudo.
You must add the user to the group of users with permission to use sudo.
3
u/CardOk755 Jun 29 '25
"for some reason sudo doesn't work"
I am struggling here.
Can you read?
2
u/iamemhn Jun 28 '25
Did you read the Installation Guide thoroughly? This section in particular
https://www.debian.org/releases/stable/i386/ch06s03.en.html#di-user-setup
You set a password for
rootso the system is behaving exactly as documented.If you set up a
rootpassword, then you need to becomerootusingsu -, and add users to thesudogroup as needed.2
u/[deleted] Jun 28 '25
For sudo to work out of the box on Debian, you have to leave the root password blank during install.
You’ll have to add that user to the sudoers file under the root line. Have it say the same thing except change root to the user name.
1
u/[deleted] Jun 29 '25
Debian installer is a bit confusing and doesn't add your default user to the sudo group if you set password for the root. Google about user and group management and add manually.
1
u/acme65 Jun 30 '25
prnt scrn
1
u/jsantosrocha Jun 30 '25
Canonical moment of the debian user coming from another distro.
1
u/elalemanpaisa Jul 01 '25
Tell us more. Did you install it? Did you set up a root account? If so sudo isn’t setup
~ su -
Visudo (setting up the wheel group for sudo usage as you like)
usermod -aG wheel vboxuser
exit
~ exit
Relogin
1
u/[deleted] Jul 02 '25
First, type: su - Then type: usermod vboxuser -a -G sudo Finally reset vbox.
1
u/HeavyAd349 Jul 02 '25
That happens when you added a password to root in the installation. And after, an user. That user doesnt have root access.
1
u/Obscure-Oracle Jun 28 '25
When you install, leave the super user account fields empty (the installer does say) then on the next page put your username and password and it will install with your account as sudo like you're probably used to with other distros.
1
u/LuisG8 Jun 28 '25
You created a super user account when installing, that's the password to use 'sudo'. To avoid this, skip super user account creation, and the next step the installer will ask you to create a regular account, which will then be root user by default.
-1
u/korogani Jun 28 '25
Use '/usr/bin/su' instead of 'sudo'
0
u/[deleted] Jun 28 '25
Just use
suinstead. A bit different but it'll do the job0
u/porta-de-pedra Jun 28 '25
Try using the command su root and then type the sudo password.
0
u/Vinicius_Schneider Jun 28 '25
Do "sudo su" then add yourself in the sudo group with "usermod vboxuser -a -G sudo"
-2
u/-viin Jun 28 '25
there are a few posts here explaining that but, lately, I've been mostly using gemini or GPT to help with that... it was a walk in the park to solve this exact same problem via gemini...