4

This question already has an answer here:

In Ubuntu I can do this in order to add a new group and user:

groupadd group123
useradd -m -s /bin/bash -g group123 user123
usermod -a -G sudo,www-data user123

I was able to do this in FreeBsd:

sudo pw groupadd group123
sudo pw useradd user123 -m -s /bin/tcsh -g group123

But this has failed:

sudo pw usermod -a -G sudo,www-data user123

because the group sudo didn't exist. Why not? doesn't "sudo pw" imply that it must? If not, how to properly add it?

marked as duplicate by Gilles, Jeff Schaller, Archemar, Stephen Kitt, Anthony Geoghegan Apr 21 '17 at 9:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    the sudo group doesn't have to exist, no. it's a convenience for entering sudo rules. Does your sudoers file refer to %sudo for rules? – Jeff Schaller Apr 19 '17 at 17:17
  • 2
    FreeBSD has a great documentation which covers this: freebsd.org/doc/handbook/users-synopsis.html – Valentin Bajrami Apr 19 '17 at 17:22
  • @JeffSchaller, how to find out that? – Dorion Apr 20 '17 at 1:32
  • @val0x00ff, hence, how to fix it? – Dorion Apr 20 '17 at 1:33
  • 1
    Then IMHO you're solving the wrong problem. Your sudoers file is granting privileges based on something else. Adding a sudo group probably won't solve this particular problem. – Jeff Schaller Apr 20 '17 at 1:47
5

There is no default group named "sudo" on FreeBSD. There is no connection between the command "sudo" and the presence of a group named "sudo".

You can see which groups you have on your system using:

$ cat /etc/group

It is common on many Linux distributions (including Ubuntu) to have a group named "sudo". On FreeBSD it is most common to use the groups "wheel" or "operators" for the same purpose.

The sudo program reads a configuration file. This file determines which users and groups are allowed to do what.

If sudo was installed with the pkg package installer then you find the sudo configuration file here:

/usr/local/etc/sudoers

The interesting part of the configuration file are the following lines:

## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL

## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

## Uncomment to allow members of group sudo to execute any command
# %sudo ALL=(ALL) ALL

My guess is that someone set your system up to allow sudo for the group "wheel" and added your user to that group. The group "sudo" does simply not exist and you cannot add anyone to a non-existing group.

You should either add the user to the "wheel" group (or whatever defined in /usr/local/etc/sudoers) - or you should create the group "sudo" and make sure it is not commented out in /usr/local/etc/sudoers

Further reading in section 13.14. Shared Administration with Sudo in the FreeBSD Handbook. The man pages for the command sudo and the configuration file for the full monty.

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