How To Install And Use sudo In FreeBSD?


Gaming Laptop Series

The sudo (super do) is a program for Unix like operating systems. It allows a to run a command or program with the privilege of another , by default super. It comes preinstalled in various Linux distributions, but if you want to use it in FreeBSD then first you need to install it.

In this article, we will discuss installing and using sudo in FreeBSD.

How to install sudo in FreeBSD

There are two ways to install software packages in FreeBSD: ports collection. Pkg is used to install packages from prebuilt binaries while ports collection is a much more customizable option, a can decide how a port or package will be compiled and installed on a system.

You will have to execute the given command as root or with super privileges.

Installing sudo using pkg

Use the following command to install sudo using pkg –

pkg install sudo

Installing sudo using the ports collection

To install the sudo from the ports collection use the following commands –

cd /usr/ports/security/sudo

And then run –

make install clean

Configuring sudo

In FreeBSD /usr/local/etc/sudoers file contains a list of s or s group to execute the program that requires the privilege of another . By editing, this file sudo can be configured to require a .

Run the following command and uncomment the wheel and sudo group so that the of these groups can use sudo.

visudo /usr/local/etc/sudoers

Now you can add a to either of these groups so that it can execute a command with the privilege of another or super. To add a to a group you can use the given command in your terminal –

Execute the given commands as root or with super privileges.

pw groupmod group_name -m _name

For example to add a lalit to wheel group use –

pw groupmod wheel -m lalit

or to add a lalit into sudo group use-

pw groupmod sudo -m lalit

Now the lalit is allowed to use sudo to execute a command.

How to execute a command using sudo

To execute a command using sudo in FreeBSD use the command as given below.

sudo /path/to/command

For example, to install a software in freebsd requires super privilege, so you can run the given command to install a package –

sudo pkg install nano

This will ask you to enter your , enter it to proceed with the installation process.

Ok, that’s all for now. If you have any thoughts on this topic, you can share it with us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.