FreeBSD doesn’t come with sudo pre-installed. Instead you are required to log in as root to make changes to the system. This is not best practise as you can do plenty of damage to your system when running as root.

With that said, for this task, you will need to be running as root.

You can easily install sudo for FreeBSD. We will go through this now. Before we start, make sure the ports tree is up to date.

portsnap fetch update

Type out the following command to change directory to the sudo port and commence the installation.

cd /usr/ports/security/sudo/ && make install clean

Leave the defaults selected, but be sure to also select insults so you get a witty message when you incorrectly enter your sudo password – then select ok.

The port will now build. Once it has completed, you will be required to add a user to the sudoers. To edit the sudoers file it is recommended to use the visudo tool. It can be ran by entering the following:


On FreeBSD, visudo uses vim as the default editor. If you haven’t used vim before it can be a little daunting. First of all we need to navigate down to find the line root ALL=(ALL) ALL. This can be done using either the J or the down arrow keys.

Once you have found that line, enter the letter twice to create a new line and activate insert mode. Add the line below, substituting username with your actual username. If you haven’t add a user yet, you can do this with the adduser command.

username ALL=(ALL) ALL

We now need to save the file and quit vim. You can do this with the following command:


You can now log in without root and superuser do, the way Todd. C. Miller intended.