How to Install & Use doas: A Minimalist Alternative To sudo

On many Linux systems, you can perform tasks as root by running commands with sudo. The OpenBSD project has developed a minimalist alternative, doas.

So how do you use Doas to run Linux commands as a different user and will it ever be replaced? sudo?

What is doas?

doas is a utility that allows standard users to perform tasks as root in the same way sudo does. It was approved by the OpenBSD project as a minimalist alternative to. developed sudo, and this makes the program much smaller than sudo.

Although it was developed as part of OpenBSD, a portable version is available that works with other Unix-like systems, including Linux.

How to install doas

doas is available in most official distribution repositories and you can easily install it using your distribution’s package manager. To install Doas on Debian-based distributions like Ubuntu:

sudo apt install doas

Note that the package is only in the Ubuntu 21.04 repository and not the 20.04 LTS version.

To install it on Arch, just use pacman:

sudo pacman -S opendoas

on Fedora and CentOS use DNF to install doas:

sudo dnf install opendoas

Configure Doas

doas needs a little more setup than sudo because most distros still don’t come with it by default, but the configuration is a lot easier to understand than sudo. All you have to do is edit that /etc/doas.conf File as root.

Here is a example of doas, which is the behavior of. to imitate sudo, and lets you run each command as root. Using doas also gives you a grace period in which you don’t have to enter your password for several minutes after running successive doas commands.

permit persist username as root

the Username in the above command is the user you want to enable. Many systems have users in a specific group like “admin”or” wheel “that can use sudo. You can also duplicate this with doas by prefixing the group names with a colon.

permit persist :wheel as root

You can also specify Linux commands with doas. Suppose you want only a specific user to be able to run APT to update the system. the cmd Option you can specify a list of individual commands and no passport allows you to execute root commands without a password.

permit nopass user cmd apt apt-get as root

Using Doas

You use doas on the command line exactly as you would run it sudo:

doas apt update

How about sudo?

Despite the arrival of Doas, sudo will be around for a while. Even though sudo has a kinky configuration file, it offers a lot of fine-grained control. In addition, doas is not yet available in all distribution repositories. You will likely need to use sudo until either more repositories add it or the distributions start replacing sudo with doas as the standard management program.

Apart from doas and sudo, there are several other programs you can install to run commands as another user. Many Linux distributions, including Arch Linux, come with su as the default utility for switching between users.

Related Posts