How do I add a user to the "sudo" group?

657,708

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"

enter image description here

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

enter image description here

Solution 5

sudo gpasswd -a $USER sudo

Share:
657,708

Related videos on Youtube

coffee-grinder
Author by

coffee-grinder

I love StackOverflow!

Updated on September 17, 2022

Comments

  • coffee-grinder
    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
      Adam F almost 7 years
      Is anyone else here trying to get sudo to work with no password on ubuntu 17?
    • Fabby
      Fabby almost 6 years
      @AdamF look here. Next time ask a new question if you want a speedier response. ;-)
    • Fabby
      Fabby almost 6 years
      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)
  • Todd Baur
    Todd Baur about 12 years
    This is also referred to in the ubuntu documentation on RootSudo albeit they refer to the admin group instead of the sudo group
  • Andrea Corbellini
    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
    hhh over 11 years
    Very cool looking GIF animation! +1 How did you do it? Moved the question here.
  • Bruno Pereira
    Bruno Pereira over 11 years
  • linello
    linello over 11 years
    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?
  • Teifi
    Teifi over 11 years
    I did what u recommended, but terminal told me bash: sudo: command not found, why?
  • n0pe
    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 run which sudo?
  • daboross
    daboross almost 11 years
    Did you click the 'unlock' button?
  • deed02392
    deed02392 almost 10 years
    New terminals were not enough. Ended up rebooting for another reason and now it works. Probably log-out/in.
  • m3nda
    m3nda about 7 years
    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.
  • Stephane
    Stephane over 6 years
    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...
  • akki
    akki almost 5 years
    This gives me an error saying Usage: adduser [options] LOGIN\n adduser -D\n adduser -D [options]\n
  • akki
    akki almost 5 years
    Although 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
    Code-Guru almost 3 years
    "The a is very important." This would have been nice to know before I rebooted my machine.