[Skip to content](#main)

[→](/)

[![Avunu](/brand/avunu-logo.svg)![Avunu](/brand/avunu-logo-light.svg)](/)[Services](/services/)[Consulting](/services/consulting/)[ERP](/services/erp/)[Odoo](/services/erp/odoo/)[ERPNext](/services/erp/erpnext/)[Custom software](/services/custom-software/)[Devices & IoT](/services/devices-iot/)[Websites](/services/websites/)[Infrastructure](/services/infrastructure/)[Partners](/partners/)

[Work](/work/)[Open source](/open-source/)[Knowledge base](/kb/)[About](/about/)

[About Avunu](/about/)[Team](/about/team/)[Insights](/insights/)[Contact](/contact/)

[Client portal](https://erp.avunu.net/projects)[Start a project](/start/)

- [Services](/services/)[Consulting](/services/consulting/)
- [ERP](/services/erp/)
- [Odoo](/services/erp/odoo/)
- [ERPNext](/services/erp/erpnext/)
- [Custom software](/services/custom-software/)
- [Devices & IoT](/services/devices-iot/)
- [Websites](/services/websites/)
- [Infrastructure](/services/infrastructure/)
- [Partners](/partners/)

[Work](/work/)[Open source](/open-source/)[Knowledge base](/kb/)[About](/about/)

- [About Avunu](/about/)
- [Team](/about/team/)
- [Insights](/insights/)
- [Contact](/contact/)

[Client portal](https://erp.avunu.net/projects)[Start a project](/start/)

[Knowledge base](/kb/)[Linux](/kb/linux/)Switch Commands with update-alternatives and sudo-rs

Search the knowledge basePress/

ESC

Jump to

[Browse the knowledge base](/kb/)[Frappe](/kb/frappe/)[ERPNext](/kb/erpnext/)[Odoo](/kb/odoo/)[WordPress](/kb/wordpress/)[NixOS](/kb/nixos/)[Email](/kb/email/)[Linux](/kb/linux/)[Databases](/kb/databases/)[Containers](/kb/containers/)[Proxmox](/kb/proxmox/)[Git & Dev Tools](/kb/git-and-dev-tools/)

↵select↑↓navigateescclose

Search the knowledge base

[Skip to the article](#kb-article)[Linux](/kb/linux/)9 articles

- [Overview](/kb/linux/)
- [Clean Up Stale nginx Unix Sockets with a systemd Drop-in](/kb/linux/nginx-socket-cleanup-drop-in/)
- [Intel GPU Kernel Parameters](/kb/linux/intel-gpu-kernel-parameters/)
- [Media Conversion Recipes](/kb/linux/media-conversion-recipes/)
- [Mount a Drive with a systemd Mount Unit](/kb/linux/systemd-mount-units/)
- [Release Stuck Messages in the Postal Mail Server Queue](/kb/linux/postal-release-queued-messages/)
- [Set Up a WireGuard VPN Host](/kb/linux/wireguard-host-setup/)
- [Shell One-Liners](/kb/linux/shell-one-liners/)
- [Swap Configuration](/kb/linux/swap-configuration/)
- [Switch Commands with update-alternatives and sudo-rs](/kb/linux/sudo-rs-and-update-alternatives/)

Other sections[Frappe](/kb/frappe/)[ERPNext](/kb/erpnext/)[Odoo](/kb/odoo/)[WordPress](/kb/wordpress/)[NixOS](/kb/nixos/)[Email](/kb/email/)[Databases](/kb/databases/)[Containers](/kb/containers/)[Proxmox](/kb/proxmox/)[Git & Dev Tools](/kb/git-and-dev-tools/)

In Linux: 9 articles

[Overview](/kb/linux/)[Clean Up Stale nginx Unix Sockets with a systemd Drop-in](/kb/linux/nginx-socket-cleanup-drop-in/)[Intel GPU Kernel Parameters](/kb/linux/intel-gpu-kernel-parameters/)[Media Conversion Recipes](/kb/linux/media-conversion-recipes/)[Mount a Drive with a systemd Mount Unit](/kb/linux/systemd-mount-units/)[Release Stuck Messages in the Postal Mail Server Queue](/kb/linux/postal-release-queued-messages/)[Set Up a WireGuard VPN Host](/kb/linux/wireguard-host-setup/)[Shell One-Liners](/kb/linux/shell-one-liners/)[Swap Configuration](/kb/linux/swap-configuration/)[Switch Commands with update-alternatives and sudo-rs](/kb/linux/sudo-rs-and-update-alternatives/)

Other sections[Frappe](/kb/frappe/)[ERPNext](/kb/erpnext/)[Odoo](/kb/odoo/)[WordPress](/kb/wordpress/)[NixOS](/kb/nixos/)[Email](/kb/email/)[Databases](/kb/databases/)[Containers](/kb/containers/)[Proxmox](/kb/proxmox/)[Git & Dev Tools](/kb/git-and-dev-tools/)

LinuxSwitch Commands with update-alternatives and sudo-rs

Use update-alternatives to choose between command implementations on Ubuntu, including switching between sudo-rs and the original sudo.

UpdatedOct 1, 2026

Applies toUbuntu 24.04Ubuntu 26.04sudo-rs 0.2

Tagsubuntusudosudo-rsupdate-alternativesphp

Reading time3 min

On this page[Manage Alternatives](#manage-alternatives)[Register Your Own Binary](#register-your-own-binary)[sudo-rs on Ubuntu 25.10 and Later](#sudo-rs-on-ubuntu-2510-and-later)[Install sudo-rs on Ubuntu 24.04](#install-sudo-rs-on-ubuntu-2404)

Debian and Ubuntu use `update-alternatives` to choose which program answers to a generic command name like `php`, `editor`, or `sudo`. This page covers the general commands, then the most common use on current Ubuntu: switching between `sudo-rs`, the Rust rewrite of sudo, and the original sudo. Run the commands as root.

## Manage Alternatives

List the installed providers of a command and see which one is selected:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">update-alternatives</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--display</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E"><</span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">NAM</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">E</span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">></span>
```

Choose interactively, or select a specific path:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">update-alternatives</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--config</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E"><</span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">NAM</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">E</span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">></span>
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">update-alternatives</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--set</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E"><</span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">NAM</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">E</span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">></span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E"><</span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">PAT</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">H</span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">></span>
```

Go back to automatic mode, where the provider with the highest priority wins:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">update-alternatives</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--auto</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E"><</span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">NAM</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">E</span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">></span>
```

## Register Your Own Binary

Add a program that wasn't installed by a package, for example a PHP build installed under `/opt` or a LiteSpeed `lsphp` binary, as a provider of `php`:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">update-alternatives</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--install</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">/usr/bin/php</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">php</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E"><</span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">PHP_BINAR</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">Y</span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">></span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">84</span>
```

The arguments are the generic link, the alternative's name, the real binary, and a priority. Higher priorities win in automatic mode, and using the version number as the priority (like `84` for PHP 8.4) keeps that predictable. Check the result with `php -v`.

## sudo-rs on Ubuntu 25.10 and Later

Starting with Ubuntu 25.10, and in Ubuntu 26.04 LTS, `sudo-rs` is the default `sudo`. The original implementation is still available as `sudo.ws`, and both are registered as alternatives:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">update-alternatives</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--display</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">sudo</span>
```

```text
sudo - auto mode
  link best version is /usr/lib/cargo/bin/sudo
...
/usr/bin/sudo.ws - priority 40
/usr/lib/cargo/bin/sudo - priority 50
```

Switch to the original sudo, for example if a `sudoers` rule depends on behavior that sudo-rs doesn't support:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">update-alternatives</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--set</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">sudo</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">/usr/bin/sudo.ws</span>
```

Switch back to sudo-rs:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">update-alternatives</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--auto</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">sudo</span>
```

Check which one is active with `sudo -V | head -1`.

Note

sudo-rs reads the same `/etc/sudoers` and `/etc/sudoers.d/` files, but it supports a smaller set of features. The difference you're most likely to hit is wildcards inside command arguments (such as `systemctl restart app-*`), which sudo-rs doesn't match. Test your rules with `sudo -l -U <USER>` after switching.

## Install sudo-rs on Ubuntu 24.04

Ubuntu 24.04 LTS still uses the original sudo by default, but sudo-rs is available in the `universe` repository. It installs alongside sudo as `sudo-rs`, so you can try it without replacing anything:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">apt</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">install</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">sudo-rs</span>
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">sudo-rs</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">-V</span>
```

To make it answer to `sudo`, remove the original package and register sudo-rs as an alternative:

Warning

Keep a root shell open in a second session until you've confirmed the new `sudo` works. Removing sudo with no root password set or no other way in can lock you out of the server. Use `apt remove`, not `apt purge`: purging the `sudo` package deletes `/etc/sudoers`, which sudo-rs also reads.

```
<span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">SUDO_FORCE_REMOVE</span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">=</span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">yes</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#FFA657;--shiki-light:#953800">apt</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">remove</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">sudo</span>
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">update-alternatives</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--install</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">/usr/bin/sudo</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">sudo</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">/usr/lib/cargo/bin/sudo</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">50</span>
```

`SUDO_FORCE_REMOVE=yes` overrides the sudo package's refusal to uninstall itself when root has no password. Then test as a normal user in the `sudo` group:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">sudo</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">-V</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">|</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#FFA657;--shiki-light:#953800">head</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">-1</span>
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">sudo</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">id</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">-u</span>
```

```text
sudo-rs 0.2.2
0
```

To go back, run `update-alternatives --remove sudo /usr/lib/cargo/bin/sudo` and `apt install sudo`.

Sources

- [manpages.ubuntu.com/manpages/noble/man1/update-alternatives.1.html](https://manpages.ubuntu.com/manpages/noble/man1/update-alternatives.1.html)
- [documentation.ubuntu.com/release-notes/26.04/summary-for-lts-users](https://documentation.ubuntu.com/release-notes/26.04/summary-for-lts-users/)
- [github.com/trifectatechfoundation/sudo-rs](https://github.com/trifectatechfoundation/sudo-rs)

Need help with Linux servers?

Our notes can take you a long way, but sometimes you'd rather have someone who's done it before.

[Managed infrastructure](/services/infrastructure/)

[← PreviousSwap Configuration](/kb/linux/swap-configuration/)

CC0This article is in the public domain ([CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/)), code samples included. Use it however helps you.

On this page

- [Manage Alternatives](#manage-alternatives)
- [Register Your Own Binary](#register-your-own-binary)
- [sudo-rs on Ubuntu 25.10 and Later](#sudo-rs-on-ubuntu-2510-and-later)
- [Install sudo-rs on Ubuntu 24.04](#install-sudo-rs-on-ubuntu-2404)

[Back to top↑](#top)

Services

- [ERP implementation](/services/erp/)
- [Odoo](/services/erp/odoo/)
- [ERPNext](/services/erp/erpnext/)
- [Custom software](/services/custom-software/)
- [Devices & IoT](/services/devices-iot/)
- [Websites](/services/websites/)
- [Infrastructure](/services/infrastructure/)

Resources

- [Our work](/work/)
- [Open source](/open-source/)
- [Knowledge base](/kb/)
- [Insights](/insights/)

Company

- [About](/about/)
- [Team](/about/team/)
- [Partners](/partners/)
- [Contact](/contact/)

Clients

- [Project portal](https://erp.avunu.net/projects)
- [Invoices](https://erp.avunu.net/)
- [Support](https://erp.avunu.net/)

[![Avunu](/brand/avunu-logo-light.svg)](/)[\<av-icon data-jx-static>\<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor" stroke="none" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">\<path d="M20.400 20.500h-3.600v-5.600c0-1.300 0-3-1.800-3s-2.100 1.400-2.100 2.900v5.700H9.400V9h3.400v1.600c.5-.9 1.600-1.900 3.400-1.900 3.600 0 4.300 2.400 4.300 5.500v6.300zM5.300 7.400a2.100 2.100 0 1 1 0-4.100 2.100 2.100 0 0 1 0 4.100zm1.800 13.100H3.600V9h3.500v11.500zM22.200 0H1.800C.8 0 0 .8 0 1.700v20.600c0 .9.800 1.700 1.800 1.700h20.400c1 0 1.800-.8 1.800-1.700V1.700C24 .8 23.200 0 22.200 0z">\</path>\</svg>\</av-icon>](https://www.linkedin.com/company/avunu)[\<av-icon data-jx-static>\<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor" stroke="none" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">\<path d="M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1 1.8 2.8 1.3 3.5 1 .1-.8.4-1.3.7-1.6-2.7-.3-5.5-1.3-5.5-5.9 0-1.3.5-2.4 1.2-3.2-.1-.3-.5-1.5.1-3.2 0 0 1-.3 3.3 1.2a11.500 11.500 0 0 1 6 0c2.300-1.500 3.300-1.200 3.300-1.200.6 1.700.2 2.900.1 3.200.8.8 1.200 1.900 1.200 3.200 0 4.600-2.800 5.600-5.500 5.900.4.400.8 1.100.8 2.200v3.300c0 .3.2.7.8.6A12 12 0 0 0 12 .3">\</path>\</svg>\</av-icon>](https://github.com/Avunu)[Client portal](https://erp.avunu.net/projects)[Start a project](/start/)

Avunu LLC · 948 East Philadelphia Street, York, PA 17403 · (717) 814-8540Knowledge base articles are in the public domain[Privacy](/privacy/)[Terms](/terms/)
