This post will guide you how to install sudo command under FreeBSD operating system. How do I use sudo command to execute the command that need root privilege.
The FreeBSD system does support sudo, but it is not installed by default after you installed FreeBSD system. So you need to install the sudo package.
If the FreeBSD version is lower than 10, then you just need to run the following command:
#pkg_add –r sudo
If the FreeBSD version is greater than or equal to 10, you need to use the pkg install command to install sudo command, type:
# pkg install sudo
Then you need to add the new user to the sudoers file, this file is the default configuration file for sudo, and it is located in /usr/local/etc/sudoers. And you need to use the command visudo to open the configuration file. Type:
# visudo
Add the below line for a specified username: osetc
osetc ALL=(ALL) All
Save and close the file.
Then if you want to have limit root privilege for osetc user, you just need to run:
$ sudo –s