Bizarre steps required to get sudo as user?

HatAM

New Member
Joined
Jan 9, 2025
Messages
7
Reaction score
2
Credits
79
Hi all,

Apologies for the series of noob questions.
My question is: what am I doing wrong in making my user able to access sudo?

Context:
I've just wiped my solver box and put a fresh Debian install on it. created userA during the install process.

I then wanted to make that user a sudoer. No matter.
su -
usermod -aG sudo userA % add userA to the sudo group
groups userA % confirm userA has sudo listed as a group it belongs to

visudo
sudo ALL=(ALL:ALL) ALL %change to uncommented

su - userA % change back to userA

sudo whoami
> userA is not in the sudoers file.

I have confirmed that userA is in the sudo group. I've rechecked the visudo line uncommenting.

Eventually I have got it working by putting in an explicit rule using visudo:
userA ALL=(ALL:ALL) ALL

Which has worked but seems bizarre that it was required. Is there something that I'm missing? I'm surprised this is difficult on a virgin system with all default install (apart from Cinammon being the desktop environment).
 


Normally you have log all the way out, and log back in for sudo to take effect.

Also you can try

sudo -l to see the sudo permissions.
 
run this in Terminal...post the result

Code:
apt install sudo
 
It's well known that Debian does not come with user in the sudo group. So you have to add it. By simply editing the sudoer file as root. But looks like you got it. So enjoy!
 
There is a reason why the /etc/sudoers file exists. Just being in the sudo group alone shouldn't be enough. Each user should be listed on at a time in the sudoers file. You will need to log out and back in for the group modification to take effect. You can be careful now, or wish you had been later.

Signed,

Matthew Campbell
 
run this in Terminal...post the result

Code:
apt install sudo
Haha nah didn't get me this time. I did try this before I posted :P

It's well known that Debian does not come with user in the sudo group. So you have to add it. By simply editing the sudoer file as root. But looks like you got it. So enjoy!
Interesting! There you go. Last time I was daily-ing Debian was circa a decade ago so perhaps I've forgotten but I can't remember ever having to manually enter the UserA ALL(ALL:ALL) ALL distinct line

Anyway - sounds like that's the go now?
What's the point of the group permissions if you have to add each user one at a time?
 

Your syntax is a little off. Also groups usually start with a %.
If the user is in the sudoers, you don't have to add him to a sudo group.

Most distro's have sudo group already called wheel.
I skimmed this but couldn't see where I'd gone wrong with the syntax.

It sounds like you've got to enter a user specific line in the visudo command window anyway? It's not enough to just have the group permissions?
 
I don't know when the coice was made in debian but here's how it works if you during install provide a root password then the user is not added to sudoers file. If you do not provide a root password the user/s are added to the sudoers file. It' been like that since at least version 10 I believe. In any event It's a fairly simple matter to add a user to the file. Enjoy debian it's a good solid distro.
 

Staff online

Members online


Top