How do I add a user to the "sudo" group?
Solution 1
sudo usermod -aG sudo <username>
The a
is very important. Without it they'll be removed from all other groups. You will need to either restart your shell/terminal or log out and back in for this to take effect.
See also:
Solution 2
You can either use the user management GUI for it (same place where you create users), or use sudo adduser <username> sudo
in the command line.
Solution 3
You can also use a graphical interface. Click on the gear on the top right of the panel, then select "System Settings" and then "User Accounts"
You need to click the little unlock button to be able to edit things in this window. Then click on the person's account and select the proper dropdown for "Account Type"
Solution 4
Its really simple if you are using Unity as your desktop environment.
If you have created a user already then you can simply change it from Standard to Administrator, else make sure that you selected Administrator when creating a new one.
Don't forget to unlock before trying to change it
Solution 5
sudo gpasswd -a $USER sudo
Related videos on Youtube
Comments
-
coffee-grinder over 1 year
In
/etc/sudoers
I see this:# Allow members of group sudo to execute any command after they have # provided their password # (Note that later entries override this, so you might need to move # it further down) %sudo ALL=(ALL) ALL
So how do I add a user to that
sudo
group?-
Adam F almost 7 yearsIs anyone else here trying to get sudo to work with no password on ubuntu 17?
-
Fabby almost 6 years@AdamF look here. Next time ask a new question if you want a speedier response. ;-)
-
Fabby almost 6 yearsCoffe-grinder: would you mind changing your acceptance to the most highly upvoted answer as that's a better way to do it? (no password at all)
-
-
Todd Baur about 12 yearsThis is also referred to in the ubuntu documentation on RootSudo albeit they refer to the admin group instead of the sudo group
-
Andrea Corbellini over 11 years+1: this is the most easy-to-remember, simple and intuitive way to add a user to a group!
-
hhh over 11 yearsVery cool looking GIF animation! +1 How did you do it? Moved the question here.
-
Bruno Pereira over 11 years
-
linello over 11 yearsI have Ubuntu 10.10 but my graphic interface is someway locked. It opens but I when buttons are pressed nothing happens. I suppose is something related to the privileges (I'm actually sudoer). How can I solve this issue?
-
Teifi over 11 yearsI did what u recommended, but terminal told me
bash: sudo: command not found
, why? -
n0pe over 11 years@Teifi, that means you probably don't have
sudo
installed or, for some weird reason, it's not in your path. What happens when you runwhich sudo
? -
daboross almost 11 yearsDid you click the 'unlock' button?
-
deed02392 almost 10 yearsNew terminals were not enough. Ended up rebooting for another reason and now it works. Probably log-out/in.
-
m3nda about 7 yearsI know
a
is for append, but i think it will be more usefull to have append as default behavior. Creating an alias is easy so that will be the way to havegroupadd group
then just append it. I did the command without -a once today as i didn't remember the-a
argument. -
Stephane over 6 yearsNice animation! I'd like to do such a gif animation to show new features of my web app ? I'm on Lubuntu 16.04...
-
akki almost 5 yearsThis gives me an error saying
Usage: adduser [options] LOGIN\n adduser -D\n adduser -D [options]\n
-
akki almost 5 yearsAlthough this is an Ubuntu forum, For CentOS I had to do
sudo usermod -aG sudo <username>
. Because there was no easy way for me to find this out. -
Code-Guru almost 3 years"The a is very important." This would have been nice to know before I rebooted my machine.