Creating a new user is not strictly necessary, but it is highly recommended. Especially for building packages, it is the safest option to create an unprivileged user and using ‘doas’ for doing operations that require ‘root’ privileges. The code block below describes how to create a user (named ‘foo’), add them to the wheel group, and to give doas permissions to the wheel group
# Create the new user adduser foo # Add the user to the wheel group addgroup foo wheel # Give root permission to the wheel group using doas echo permit persist :wheel >> /etc/doas.conf
You are also advised to take a look at the doas configuration file and the manual page of doas.
After you are finished you can switch to the new user by running
su foo