How To Install And Use sudo In FreeBSD?

How To Install And Use sudo In FreeBSD?

   

This post was last updated on August 1st, 2020 at 10:28 am

The sudo (superuser do) is a program for Unix like operating systems. It allows a user to run a command or program with the privilege of another user, by default superuser. 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: pkg and ports collection. Pkg is used to install packages from prebuilt binaries while ports collection is a much more customizable option, a user 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 superuser 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 users or users group to execute the program that requires the privilege of another user. By editing, this file sudo can be configured to require a password.

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

visudo /usr/local/etc/sudoers

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

Execute the given commands as root or with superuser privileges.

pw groupmod group_name -m user_name

For example to add a user lalit to wheel group use –

pw groupmod wheel -m lalit

or to add a user lalit into sudo group use-

pw groupmod sudo -m lalit

Now the user 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 superuser privilege, so you can run the given command to install a package –

sudo pkg install nano

This will ask you to enter your password, 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.

Previous [ubuntu] Samsung Display issues
Next [ubuntu] Init Failure & Segmentation Fault

About author

You might also like

Linux Topics 1Comments

How to Fix Windows And Linux Showing Different Time In A Dual Boot System

This post was last updated on August 3rd, 2020 at 02:34 pmThere are many users who use a dual boot computer. Dual-booting Linux with Windows operating system has various advantages

FreeBSD Topics 0 Comments

[FreeBSD] How to allow Root access on FreeBSD over ssh protocol

This post was last updated on July 21st, 2020 at 01:18 pmBy default FreeBSD does not allow root access over ssh protocol. So if you need to log on to

FreeBSD Topics 0 Comments

[FreeBSD] How to Install FreeBSD OS, Step by step guide using a virtual machine

This post was last updated on July 21st, 2020 at 01:15 pmTake a deep breathe and be sure that you have at least an hour of time. We have to

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply