OpenBSD's doas on Voidlinux

Published 2020-03-20 on Anjan's Homepage

OpenBSD's doas is a minimal replacement for sudo. If you run a single user linux box, you can replace sudo with doas in order to have a simpler sudo configuration and usage experience.

First, install doas using xbps-install.

sudo xbps-install opendoas

Doas rules have the following format:

permit|deny [options] identity [as target] [cmd command [args ...]]

I like adding the persist option to my rule so that if I enter my password once, doas remembers and doesn't constantly ask me to authenticate.

Edit /etc/doas.conf and add the following line:

permit persist <YOURUSERNAME> as root

This allows <YOURUSERNAME> to run any command as root.

1 Sudoedit replacement with Doas

The rationale for sudoedit is that text editors are complex programs that could cause damage if given unchecked root access. As such, it's better to use the cp command to copy the file so that a non-root user can edit it, run your editor as a non-root user to edit the file, and on exit run cp to overwrite the original file with the user edited file. To make a sudoedit with doas, you can make a wrapper copy files around.

However, if you use emacs, you can easily create a sudoedit replacement for doas. TRAMP for emacs supports doas. As such, I add the following to my .bashrc:

    emacsclient -nw /doas::${1}

Running doasedit <filename> now allows you to edit the file like sudoedit!

2 Uninstalling sudo

On Voidlinux, sudo is part of the base-system group. If we want to remove sudo, we must tell xbps that sudo can be substituted by doas.

To substitute doas for sudo, I edited /etc/xbps.d/99-my-settings.conf and added:


See man xbps.d for more details on the virtualpkg keyword.

To remove sudo, we can now run:

doas xbps-remove sudo

3 Further Reading

Have a comment on one of my posts? Start a discussion in my public inbox by sending an email to ~anjan/ [mailing list etiquette]

Articles from blogs I follow around the net

These articles/blogs do not represent my own opinions or views.

Linux development is distributed - profoundly so

The standard introduction to git starts with an explanation of what it means to use a “distributed” version control system. It’s pointed out that every developer has a complete local copy of the repository and can work independently and offline, often contra…

via Blogs on Drew DeVault's blog September 2, 2020

Eshell versus M-x shell

I’ve used and defended Eshell for years. Sadly, Eshell has some long standing issues that I grew tired of in the long run. So I’ve decided to switch to M-x shell and see how much of my Eshell workflow I could port. Language and the underlying shell pr…

via Pierre Neidhardt's homepage June 26, 2020

Thermoelectric Stoves: Ditch the Solar Panels?

Wood stoves equipped with thermoelectric generators can produce electricity that is more sustainable, more reliable, and less costly than power from solar PV panels.

via LOW←TECH MAGAZINE May 26, 2020

Generated by openring