Score:1

How to add user to sudoers really?

hr flag

Ubuntu 20.04. I have created 2nd user and try to do:

sudo su [sudo] password for xoleg: xoleg is not in the sudoers file. This incident will be reported. xoleg@oleg-HP-2004:~$

Then my other user added this 2nd user

>usermod -aG sudo xoleg

and yet this

>nano /etc/sudoers

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
# added this
username ALl=(ALL) NOPASSWD:/bin/mkdir,/bin/rmdir

after it again to xoleg session

>sudo su
[sudo] password for xoleg: 
xoleg is not in the sudoers file.  This incident will be reported.

Where am I wrong? how to fix it?

Raffa avatar
jp flag
Have you logged out and back in after adding the user to the group?
ZedZip avatar
hr flag
No, should this new added user logout/login?
Raffa avatar
jp flag
Yes, ... Please see https://askubuntu.com/a/1468587
Score:1
km flag
CMB

This solution worked for me in Ubuntu 22.04. To get sudo access, switch to root first using:

su root

Enter your password when prompted, and then add user to sudo:

adduser username sudo

Enter your user name in place of username above, now switch back to current user again:

su username

That's all. Try to run sudo again with your user. I hope this solves your problem.

ru flag
Once you do the `su` and `adduser` just have the user log out and log in again, it'll solve the `sudo` problem. Because that's the proper way to refresh perms.
CMB avatar
km flag
CMB
Yes, that also works. But if someone does not want to logout and login again then just `su username` works fine.
ru flag
That's disadvised, until you exit out of `su root` because then you can just run `exit` and end up at a root prompt again. It's *extremely* insecure, so you need to make sure the user exits *after* they are done with root, then they can run `su username` and enter their password otherwise they're in a `root` prompt easily via the execution trees and you *do not* want users to stay in root prompts.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.