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?

  • Is anyone else here trying to get sudo to work with no password on ubuntu 17? – Adam F May 4 '17 at 17:27
  • @AdamF look here. Next time ask a new question if you want a speedier response. ;-) – Fabby May 3 at 22:27
  • Coffe-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) – Fabby May 3 at 22:28
up vote 227 down vote accepted
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:

  • I did what u recommended, but terminal told me bash: sudo: command not found, why? – Teifi Jan 21 '13 at 12:23
  • @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 run which sudo? – n0pe Jan 22 '13 at 16:33
  • New terminals were not enough. Ended up rebooting for another reason and now it works. Probably log-out/in. – deed02392 Jul 8 '14 at 15:35
  • You just saved my day. Thanks! – Yenthe Aug 18 '15 at 15:07
  • I 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 have groupadd group then just append it. I did the command without -a once today as i didn't remember the -a argument. – erm3nda Apr 12 '17 at 18:59

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.

  • 1
    This is also referred to in the ubuntu documentation on RootSudo albeit they refer to the admin group instead of the sudo group – icc97 Mar 5 '12 at 8:27
  • 7
    +1: this is the most easy-to-remember, simple and intuitive way to add a user to a group! – Andrea Corbellini Dec 28 '12 at 17:14

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"

enter image description here

  • I 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? – linello Jan 18 '13 at 9:49
  • Did you click the 'unlock' button? – daboross Jun 10 '13 at 2:22
  • Nice animation! I'd like to do such a gif animation to show new features of my web app ? I'm on Lubuntu 16.04... – Stephane Sep 21 '17 at 14:41

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

enter image description here

sudo gpasswd -a $USER sudo

I am late to the party, but this answer might help someone that uses Ubuntu inside a Docker container.

I recently created a Docker container based on Ubuntu 16.04.1.

By default, the Docker Ubuntu image is a stripped down version of Ubuntu, which does not have a vast majority of common tools including sudo.

Besides, by default, the user is logged in to the Docker container as root.

Therefore, I started the container with the docker run command, and installed the 'sudo' package:

root@default:/# apt-get install sudo

Running the command adduser myuser sudo reported error adduser: The user 'myuser' does not exist.. After reading this answer, I first ran the command to create the user:

root@default:/# adduser myuser

Then ran the following command:

root@default:/# adduser myuser sudo
Adding user `myuser' to group `sudo' ...
Adding user myuser to group sudo
Done.

The user myuser was successfully added to the sudo group.

Use usermod. Add the sudo permission with the following command:

usermod -aG sudo <your username>

Please note that you'll have to use the root account to do this or use another account that has sudo permissions. If you don't have access to another account for some reason and you don't know the root password, you'll need an Ubuntu (or another Linux distro) live CD and then you'll need to chroot into your Ubuntu filesystem and run the above command from inside the chroot.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.