10

Hi I'm trying to add myuser to sudoers after a fresh install with root account,

# adduser myuser admin 

which gives:

adduser: the group `admin' does not exist.

however this works:

# adduser myuser root

but it doesn't make myuser a sudoer.

Furthermore, /etc/sudoers does contain these lines:

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

but pretty strange -- the file /etc/group doesn't contain admin.

Should I just manually edit it and add something like:

admin:x:120:myuser
EEAA
  • 109,363
  • 18
  • 175
  • 245
valk
  • 497
  • 2
  • 9
  • 20

2 Answers2

13

use groupadd admin to add the group then you could run adduser myuser admin. However you may want to instead use usermod -G myuser,admin myuser to remove yourself from the root group. (instead of myuser,admin, list the exact list of groups your user should be a member of.

If you ever get tempted to edit /etc/group directly, please use the vigr command, which will make sure the syntax of the file is correct before committing changes.

stew
  • 9,388
  • 1
  • 30
  • 43
  • Thanks @stew! worked like a magic! one thing i had to do is to logout and then login with myuser. – valk Dec 16 '11 at 19:42
1

the sudo group should be used:

adduser myuser sudo
ozma
  • 121
  • 1
  • 5