OpenBSD does not come with sudo
by default, and normally you don't want to log in as root. When you need to perform sysadmin tasks, you change to super user by running:
$ su
OpenBSD provides doas
, a lightweight and secure replacement for sudo
. This allows you to run a command as root by doing:
$ doas command
You will want to add your user to /etc/doas.conf
:
# vi /etc/doas.conf
(Note the # sign means you must run this as root, by logging in first using su
; a $ sign means you run the command as your normal user)
Here's /etc/doas.conf
should contain (replace user123 with your own username):
permit nopass user123 as root
This permits user123 to login as root using doas
without a password.
After doing this, you can confirm it works:
$ doas whoami user123
If you find the need to constantly enter your user password for when you need to do anything as root annoying, you can have in your /etc/doas.conf
permit persist user123