How to enable sudo on FreeBSD 12?

Windows Articles

New Office app arrives: free and renewed

Microsoft goes one step further. This time positive. This week the Redmond people launched the new Office app for Windows 10. The...

How to install Gradle on Ubuntu 20.04?

Hi, folks. In this post dedicated to Java, you will learn how to install Gradle on Ubuntu 20.04 Gradle...

Linux 5.8 Released

A few days ago, Luis Torvalds was discussing to release Linux 5.8-rc8 or he releases Linux 5.8 as stable. In the end,...

How to install the MIUI 12 Control Center on any Android Device

Mi Control Center is a third-party application that allows you to install the MIUI 12 Control Center on your Android device. It...

Make your life easier with this top 5 shortcuts with the Windows key

Windows has many access tricks that make it easy to use. Usually, common users are unaware of most of them. The shortcuts...
angeloma
angeloma
Senior Writer and partner

Hello, friends in this post I will show you how to enable sudo in FreeBSD 12. We like Linux but also FreeBSD for its robustness and for being another valid alternative for servers.

What is sudo?

In a PC that runs some Linux distribution or FreeBSD, there are different users. Each of them has defined roles and permits. For example, to install a package in FreeBSD it is necessary to do it with root user privileges. Then, not all users can do all things.

The sudo program is part of the GNU suite. It is a small application that allows the execution of commands with the security privileges of another user. Normally, this “other” user is root.

By FreeBSD security policy, this program is not enabled for your regular user. And the truth is that if you use FreeBSD on your personal computer we can enable it and it would not be a problem. However, if you install FreeBSD to be used on a server, you should not do it.

In any case, sudo allows you to execute commands that your user can not. In addition, the commands that are applied with sudo are not registered in the system log.

Enabling sudo on FreeBSD 12

We already know that sudo is not installed by default on FreeBSD, but it is available from the official repositories. So first log in as root on FreeBSD.

After you have opened the terminal session as the root user, install sudo with the following command:

:~$ pkg install sudo
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
	sudo: 1.8.31
Number of packages to be installed: 1
The process will require 3 MiB more space.
730 KiB to be downloaded.
Proceed with this action? [y/N]:

1.- Install sudo on FreeBSD 12
1.- Install sudo on FreeBSD 12

Once you have installed sudo, you need to add your user to the list of users who can run sudo.

To do this, first install the nano text editor which is easier to use than vi.

:~$ pkg install nano

And now we have to edit the sudo configuration file.

:~$ nano /usr/local/etc/sudoers

Now under the line:

root ALL=(ALL) ALL

Add the next line:

angelo ALL=(ALL) ALL

In this case, angelo is my username. Replace it with yours.

2.- Enabling sudo on FreeBSD 12
2.- Enabling sudo on FreeBSD 12

Save your changes with CTRL + O and close the editor with CTRL + X.

Now you can log out as root and log in with your regular user.

The first time you run a command with sudo, such as updating the system, you will see something like this:

3.- testing sudo
3.- testing sudo

Just enter your password and the command will be executed.

Remember that sudo opens a security hole. So normally it is not recommended to use it on servers. But still, it can be very useful to keep it in mind.

And that’s it, now you can use sudo in FreeBSD 12.

Conclusion

Many times we need to execute various commands as the root user to perform operations on our Unix-based systems. However, we do not always have access to the root user and thanks to sudo we can do it. On the other hand, sudo is not always enabled in production environments.

Now you know how to enable sudo in FreeBSD 12.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

New Office app arrives: free and renewed

Microsoft goes one step further. This time positive. This week the Redmond people launched the new Office app for Windows 10. The...

How to install Gradle on Ubuntu 20.04?

Hi, folks. In this post dedicated to Java, you will learn how to install Gradle on Ubuntu 20.04 Gradle...

Linux 5.8 Released

A few days ago, Luis Torvalds was discussing to release Linux 5.8-rc8 or he releases Linux 5.8 as stable. In the end,...

How to install the MIUI 12 Control Center on any Android Device

Mi Control Center is a third-party application that allows you to install the MIUI 12 Control Center on your Android device. It...

Make your life easier with this top 5 shortcuts with the Windows key

Windows has many access tricks that make it easy to use. Usually, common users are unaware of most of them. The shortcuts...