root on Debian 11
I've used Debian for almost 10 years, but after installing Debian 11 I just can't get root. I'm not allowed to login as root, and sudo su doesn't work because my user account is not in the sudoers file! How is this supposed to work?
su -
BTW If you don't set a root password then the first user will automatically get sudo permissions.
Thanks for the tips, got it working now. I was trying "sudo su" and got "myuser is not in the sudoers file. This incident will be reported."
But in my frustration I didn't think of simply trying "su root".
sudo su
is such an anti-pattern and it is repeated all over again.
Don't do this to get a root shell, do sudo -i
for a proper login shell instead.
I just recently did this.
Log into root with su - root
Add the sudo privilege to the user with # adduser USER sudo
Log back to user and check $ groups
Read more here: https://wiki.debian.org/sudo/
G'luck!
su -
su root

You either need sudo set up with you in sudoers, or a root password (or both). It's unlikely to find yourself in a situation when you have neither.
If you have a root password you use su
.
If you have sudo set up you use sudo
.
In both cases you log in using your regular account first, because in many/most contexts, logging in directly as root is disabled. You can simulate a root login with su -
.
My personal preference is to use sudo, which is currently the default in new installations (ie, if you leave the root password field blank in that step of the installer). It's not too difficult to set this up after the fact.
I fell down this rabbit hole, there's a bug report with a rather vehement "won't do" response from one of the debian maintainers for not including sudo as a default package, for security reasons.
And to be fair... although I can't remember exactly what he said... logically, I went, oh shit... I guess he's right.
"su -" or "su - root" is the way... I only run into a few scripts that need to be adjusted, and ansible is easy enough to slap a "su" in the ansible.cfg

Not allowed to login as root how? If you're trying that over ssh, by default that would be disabled ... for dang good security reasons.
If you set a root password and can't login as root, e.g. on the console, then you probably set the password to something other than what you think you did.