Tuesday, September 13, 2016

Transition from Ubuntu to FreeBSD - root, su, sudo

In this series of posts, I will write my own attempt to transition from Linux (Ubuntu) to BSD (FreeBSD).

In Ubuntu, the security model is to invoke sudo command whenever root privilege is required. On the contrary, one needs to login as root using su - command. In fact, only those who are in the wheels group can login as root with su command.

A user not in wheels group cannot login as root:$ su -su: Sorry

To manually add a user, say unixnme, to wheels group, one needs to edit /etc/group to read something likewheel:*:0:root,unixnme

...

operator:*:5:root,unixnme

...

Note that root is in the operator group as well. The operator group will have access to devices, so I might as well add to this group as well.

Now, the user can issue

$ su

or

$ su -

commands to login as root.

By the way, if one prefers the Ubuntu way with sudo command, it can be done.

Install sudo

# pkg install -y sudo

Add to sudoer by editing /usr/local/etc/sudoers to read something like