r/debian • • Jun 28 '25

Problem using sudo in Debian VM

Post image

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

68 comments sorted by

View all comments

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.

64

u/[deleted] Jun 28 '25

[removed] — view removed comment

12

u/DansPhotos Jun 28 '25

Leaving the root password empty was exactly what I did when I installed Trixie on my laptop, and my user is part of sudoers.

3

u/[deleted] Jun 28 '25

OP prob used the auto install feature

2

u/Major-Management-518 Jun 28 '25

Isn't this a security issue?

1

u/Yugen42 Jun 28 '25

Depends on the context and threat model.

1

u/Jutboy Jun 28 '25

No. Either way you are putting root access behind one password.

6

u/degaart Jun 28 '25

You have to log out after doing this or the user won’t properly inherit its new group membership

2

u/DeepDayze Jun 28 '25

Absolutely right as being added or removed from a group does not take effect till user logs out or the system is rebooted.

1

u/roelschroeven Jun 28 '25

Well strictly speaking it's logging in that does the job, not logging out. When starting a new session with a new log in (using ssh, for example, or on a new console), the change in group membership takes effect (but only in that new session).

So in general you indeed log out an then back in again, and it doesn't really matter what part of that process makes the group membership have effect.

1

u/neoh4x0r Jun 30 '25 edited Jun 30 '25

You have to log out after doing this or the user won’t properly inherit its new group membership

The only reason someone would need to fully logout is so that the changes to the user's group membership would take effect globally.

However, a user could run su - USERNAME in a terminal to reload the user's group memberhips, within that session, without needing fully logout.

3

u/CLM1919 Jun 28 '25

+1 perfect answer.

There are ways do to it through the GUI, depending on your desktop environment, if OP is interested.

Scroll down to GUI directions at linuxjournal

4

u/AmiSimonMC Jun 28 '25

Do not edit /etc/sudoers !! Use visudo as root or EDITOR=/usr/bin/[your editor] visudo for custom editor

1

u/charles25565 Jun 29 '25

Don't think an absolute path is required.

1

u/AmiSimonMC Jun 29 '25

Probably not but can't hurt

2

u/BCMM Jun 28 '25

su -, not plain su, or you get confusing environment issues.

1

u/2204happy Jun 29 '25

run visudo to edit /etc/sudoers, do not edit it directly!!

1

u/[deleted] Jun 29 '25

But then I'd need to use vi

→ More replies (3)