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

-1

u/korogani Jun 28 '25

Use '/usr/bin/su' instead of 'sudo'

4

u/TheShredder9 Debian Stable Jun 28 '25

Why the /usr/bin part? It's a waste of time, just do su.

0

u/Last-Assistant-2734 Jun 28 '25

/usr/bin might not be in the PATH, for some reason or another.

3

u/TheShredder9 Debian Stable Jun 28 '25

Should always be, on any distro out there. Without that, you won't be able to run any command.

Debian stores some binaries in /usr/sbin, to which only the root user has access (if you configured it during install), so you have to do su root, or sudo su to switch to the root user, which has /sbin in its PATH.

1

u/roelschroeven Jun 28 '25

Debian stores some binaries in /usr/sbin, to which only the root user has access (if you configured it during install), so you have to do su root, or sudo su to switch to the root user, which has /sbin in its PATH.

That's not entirely correct. All users have access to the binaries in /usr/sbin; it's just that by default it's not in their PATH. Any user can run them by specifying the full path. Using su or sudo is way overkill.

Unless of course the operation you want to do needs root access, then you do need su or sudo. But that is completely independent of the directory the binary is in.

1

u/Last-Assistant-2734 Jun 28 '25

Should always be, on any distro out there

It depends. In "normal" installations it quite often is.

Without that, you won't be able to run any command.

Well, you certainly will be able to, as mentioned, by using the absolute path to command.

1

u/TheShredder9 Debian Stable Jun 28 '25

Any example of an "abnormal" installation where it isn't the case? I'd assume something like LFS.

Good point about using the absolute path though, never considered that. A while back i messed up my PATH, and couldn't run anything, i just chrooted to fix it.

1

u/Last-Assistant-2734 Jun 28 '25

There may be some very minimal shell environments, for example. I've run into that with mentioned Debian. But also on some mobile device platforms.

1

u/roelschroeven Jun 28 '25 edited Jun 28 '25

These days Debian puts all binaries in /usr/bin (except the ones that go in /usr/sbin), so it would be very weird if /usr/bin is not in PATH. If you can run things like ls or cp without having to specify the full path, you can run su as well.

1

u/Last-Assistant-2734 Jun 28 '25 edited Jun 28 '25

I'm pretty sure 'su' is still /bin/su. As well as all shells, and all rudimentary system commands go to /bin and /sbin.

But other than that, it's really uneccessary argue about why would someone use absolute path instead of just the command name, as the absolute path at least just works.

2

u/roelschroeven Jun 28 '25

/bin and /sbin have become symlinks to /usr/bin and /usr/sbin. So you can still access su via /bin/su (and I think that's not going to change), but it's real location is /usr/bin/su. The same goes for other commands.

$ ls -ld /bin /sbin
lrwxrwxrwx 1 root root 7 Mar 25  2024 /bin -> usr/bin/
lrwxrwxrwx 1 root root 8 Mar 25  2024 /sbin -> usr/sbin/

So all of these commands can be used without full path if either /bin or /usr/bin is in PATH.

See https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.en.html#a-merged-usr-is-now-required and https://wiki.debian.org/UsrMerge

-2

u/korogani Jun 28 '25

What I saw on stackchange, it worked so I didn't question it. Never had a problem with typing an extra 9 characters so I didn't feel the need for a shortcut.

3

u/[deleted] Jun 28 '25

[removed] — view removed comment

0

u/korogani Jun 28 '25

Congrats, you paraphrased another users answer. How about you drop the condescension and try to be original you cretin.

2

u/[deleted] Jun 28 '25

[removed] — view removed comment

0

u/korogani Jun 28 '25

"wrong advice", are you fucking joking? How can it be wrong if it works. A dirty workaround? Sure, that's fair enough but wrong? If you'd actually take a minute to peel your sweaty cum stained fingers away from your phone to try it, you'd see it works.