Installing sudo on FreeBSD

After creating a new user in FreeBSD, you may want to allow them to temporarily gain super user access using the sudo command using their own password. In order to to this, you need to install the sudo command while logged in as root:

pkg update
pkg upgrade
pkg install sudo

Next, you will have to add the new user name to the sudoers file, which is located in /usr/local/etc, using the command visudo while logged on as root:


Note: Never use a regular text editor to edit this file directly. Always use the visudo command.

Scroll down to the "User privilege specification" section and look for the line that says root ALL=(ALL) ALL. Add the following line just beneath that:

username ALL=(ALL) ALL

where username is the user's actual username.

Once that user logs off and logs back in again, they will be able to execute privileged commands using sudo and their own password. See the sources below for additional details on how to grant these privileges without entering a password.

In order to allow someone to su as root, you will need to grant them access to the wheel group using the pw command as shown here.


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License