<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Sudo on KnightLi Blog</title>
        <link>https://www.knightli.com/en/tags/sudo/</link>
        <description>Recent content in Sudo on KnightLi Blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Fri, 01 May 2026 19:27:08 +0800</lastBuildDate><atom:link href="https://www.knightli.com/en/tags/sudo/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>sudo vs sudo-rs: What the Rust Version of sudo Changes</title>
        <link>https://www.knightli.com/en/2026/05/01/sudo-vs-sudo-rs-rust-linux-command/</link>
        <pubDate>Fri, 01 May 2026 19:27:08 +0800</pubDate>
        
        <guid>https://www.knightli.com/en/2026/05/01/sudo-vs-sudo-rs-rust-linux-command/</guid>
        <description>&lt;p&gt;&lt;code&gt;sudo&lt;/code&gt; is one of the most familiar commands for Linux users.
It allows a normal user to temporarily run commands with higher privileges within an authorized scope, such as installing software, changing system configuration, or restarting services.&lt;/p&gt;
&lt;p&gt;Recently, &lt;code&gt;sudo-rs&lt;/code&gt; has attracted more attention because Ubuntu 25.10 starts using the Rust implementation &lt;code&gt;sudo-rs&lt;/code&gt; by default to replace classic sudo.
For ordinary users, the command on the surface is still &lt;code&gt;sudo&lt;/code&gt;.
The real change is underneath: the implementation being executed may already be the Rust version of sudo.&lt;/p&gt;
&lt;p&gt;This raises two natural questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is something wrong with classic sudo?&lt;/li&gt;
&lt;li&gt;Will sudo-rs affect daily use and server configuration?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The short answer is: ordinary desktop users basically do not need to worry; if you maintain servers, have written complex sudoers rules, or rely on special sudo behavior, you should test carefully.&lt;/p&gt;
&lt;h2 id=&#34;what-is-sudo-rs&#34;&gt;What Is sudo-rs?
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;sudo-rs&lt;/code&gt; is an implementation of sudo / su written in Rust.
Its goal is not to create a completely different new command, but to reimplement the main features of classic sudo while using Rust&amp;rsquo;s memory-safety properties to reduce common security risks.&lt;/p&gt;
&lt;p&gt;Classic sudo is mainly written in C. It has a long history and a very complete feature set.
That maturity brings stability, but it also brings maintenance burden.
Much of the code comes from very early Unix/Linux use cases, with many compatibility paths, extensions, and edge-case handlers added over time.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sudo-rs&lt;/code&gt; chooses to reimplement it for several reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;reduce memory-safety issues with Rust;&lt;/li&gt;
&lt;li&gt;use a more modern code structure to lower maintenance difficulty;&lt;/li&gt;
&lt;li&gt;remove some historical features and risky default behaviors;&lt;/li&gt;
&lt;li&gt;attract new contributors familiar with Rust;&lt;/li&gt;
&lt;li&gt;provide a more auditable foundation for future privilege-elevation tools.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;However, &lt;code&gt;sudo-rs&lt;/code&gt; is not a 100% compatible replacement for classic sudo.
It is still under development. Some traditional features have not been implemented yet, and others may never be implemented.&lt;/p&gt;
&lt;h2 id=&#34;what-ordinary-users-will-notice&#34;&gt;What Ordinary Users Will Notice
&lt;/h2&gt;&lt;p&gt;For ordinary users, very little changes.&lt;/p&gt;
&lt;p&gt;You still use it like this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Or:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo systemctl restart nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;In Ubuntu 25.10, &lt;code&gt;sudo&lt;/code&gt; points to &lt;code&gt;sudo-rs&lt;/code&gt;.
Users do not need to change commands to &lt;code&gt;sudo-rs&lt;/code&gt;, and common &lt;code&gt;sudo&lt;/code&gt; calls in scripts will not immediately fail because of a command-name change.&lt;/p&gt;
&lt;p&gt;The most visible change is password input feedback.
&lt;code&gt;sudo-rs&lt;/code&gt; shows asterisks by default when you type the password.
Classic sudo can also be configured to behave this way, but many distributions default to showing no characters.&lt;/p&gt;
&lt;p&gt;Some error and warning messages may also use different wording.
For example, password failures, permission problems, and incompatible configuration may show prompts that are not exactly the same as before.
This has little impact on human users, but scripts that parse sudo&amp;rsquo;s error output should be checked.&lt;/p&gt;
&lt;h2 id=&#34;what-administrators-should-watch&#34;&gt;What Administrators Should Watch
&lt;/h2&gt;&lt;p&gt;System administrators and advanced users are the ones who need to pay attention.&lt;/p&gt;
&lt;p&gt;The classic sudo ecosystem is large, and many servers have complex sudoers configurations.
These configurations may include command-argument matching, environment-variable control, logging, email notifications, PAM behavior, and host-group policies.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sudo-rs&lt;/code&gt; currently has some differences from classic sudo.
For example, the original article notes that &lt;code&gt;sudo-rs&lt;/code&gt; does not include classic sudo&amp;rsquo;s sendmail support.
Some environments used sendmail to send notifications about sudo usage, and those setups will need another approach when migrating.&lt;/p&gt;
&lt;p&gt;For authentication, &lt;code&gt;sudo-rs&lt;/code&gt; uses PAM.
This means behaviors such as resource limits and umask should be configured more through PAM, rather than relying entirely on the sudoers file.
If you previously handled many details in sudoers, verify that those rules still work before switching.&lt;/p&gt;
&lt;p&gt;Another important change is wildcard support in command argument positions.
&lt;code&gt;sudo-rs&lt;/code&gt; does not support wildcards in command argument positions, in order to avoid common sudoers configuration mistakes.
This is good for security, but it may affect existing rules.&lt;/p&gt;
&lt;h2 id=&#34;how-ubuntu-handles-sudo-and-sudo-rs&#34;&gt;How Ubuntu Handles sudo and sudo-rs
&lt;/h2&gt;&lt;p&gt;Starting with Ubuntu 25.10, the system uses &lt;code&gt;sudo-rs&lt;/code&gt; by default.
Users continue typing &lt;code&gt;sudo&lt;/code&gt;, while the Rust implementation runs underneath.&lt;/p&gt;
&lt;p&gt;Classic sudo has not disappeared immediately.
During Ubuntu&amp;rsquo;s transition, classic sudo is still kept as &lt;code&gt;sudo-ws&lt;/code&gt;.
If you truly need the traditional implementation, you can use &lt;code&gt;sudo-ws&lt;/code&gt;, or switch the default sudo through the alternatives system.&lt;/p&gt;
&lt;p&gt;The switching command looks like this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo update-alternatives --config sudo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;That said, ordinary users should not actively switch back to classic sudo.
If you have not customized sudoers and do not rely on special behavior, following the distribution default is simpler.&lt;/p&gt;
&lt;p&gt;If you want to test on older Ubuntu versions, &lt;code&gt;sudo-rs&lt;/code&gt; has been available from the universe repository since Ubuntu 24.04.
Other distributions may also provide packages, but command names and integration methods may differ.&lt;/p&gt;
&lt;h2 id=&#34;why-sudo-rs-uses-rust&#34;&gt;Why sudo-rs Uses Rust
&lt;/h2&gt;&lt;p&gt;sudo is a high-privilege tool.
If this kind of tool has a vulnerability, the consequences can be much more serious than with ordinary commands.
Historically, sudo has had several privilege-escalation vulnerabilities.&lt;/p&gt;
&lt;p&gt;Rust&amp;rsquo;s advantage is memory safety.
Through ownership, borrow checking, and the type system, it reduces common problems such as dangling pointers, out-of-bounds access, and use-after-free.
This does not guarantee that the program is absolutely safe, but it can reduce a class of vulnerabilities common in C/C++ projects.&lt;/p&gt;
&lt;p&gt;For a tool like sudo, which sits in a security-sensitive position for a long time, rewriting it in a safer language has practical meaning.
It is not just &amp;ldquo;Rust for Rust&amp;rsquo;s sake&amp;rdquo;; it is an attempt to reduce maintenance and audit cost.&lt;/p&gt;
&lt;p&gt;Of course, language cannot solve every security problem.
Permission-check logic, configuration parsing, PAM interaction, environment-variable handling, logging, and user experience still require careful design and long-term testing.&lt;/p&gt;
&lt;h2 id=&#34;sudo-rs-is-not-the-only-alternative&#34;&gt;sudo-rs Is Not the Only Alternative
&lt;/h2&gt;&lt;p&gt;There have always been other alternatives in the sudo ecosystem.&lt;/p&gt;
&lt;p&gt;One common example is &lt;code&gt;doas&lt;/code&gt;.
It comes from OpenBSD and is designed to be simpler, with a smaller configuration surface.
Some users prefer it because it is not as complex as sudo.&lt;/p&gt;
&lt;p&gt;There are also some Rust or systemd-related alternatives, such as RootAsRole and systemd&amp;rsquo;s &lt;code&gt;run0&lt;/code&gt;.
However, these tools do not have exactly the same goals or target scenarios.&lt;/p&gt;
&lt;p&gt;For most Linux distributions, sudo is still the default choice.
The significance of &lt;code&gt;sudo-rs&lt;/code&gt; is that it tries to keep user habits unchanged while replacing the underlying implementation with a more modern codebase.&lt;/p&gt;
&lt;h2 id=&#34;what-to-check-before-migrating&#34;&gt;What to Check Before Migrating
&lt;/h2&gt;&lt;p&gt;If you are just a personal desktop user, follow the distribution default.&lt;/p&gt;
&lt;p&gt;If you maintain servers or workstations, check the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Whether there are complex &lt;code&gt;/etc/sudoers&lt;/code&gt; or &lt;code&gt;/etc/sudoers.d/&lt;/code&gt; rules.&lt;/li&gt;
&lt;li&gt;Whether command-argument wildcards are used.&lt;/li&gt;
&lt;li&gt;Whether sudo email notifications are relied on.&lt;/li&gt;
&lt;li&gt;Whether scripts parse sudo&amp;rsquo;s error output.&lt;/li&gt;
&lt;li&gt;Whether sudoers controls umask, resource limits, or environment variables.&lt;/li&gt;
&lt;li&gt;Whether LDAP, PAM, SSSD, or other authentication integrations are used.&lt;/li&gt;
&lt;li&gt;Whether automation/deployment scripts assume classic sudo behavior.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can first verify on a test machine:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo -l
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Then run key maintenance commands and confirm that permissions, environment variables, and logging behavior match expectations.&lt;/p&gt;
&lt;h2 id=&#34;should-you-switch-to-sudo-rs-manually&#34;&gt;Should You Switch to sudo-rs Manually?
&lt;/h2&gt;&lt;p&gt;If your distribution has already switched by default, ordinary users can accept it directly.
If you are using a server or production environment, do not manually replace sudo just for experimentation.&lt;/p&gt;
&lt;p&gt;A safer process is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;install &lt;code&gt;sudo-rs&lt;/code&gt; in a test environment;&lt;/li&gt;
&lt;li&gt;verify existing sudoers configuration item by item;&lt;/li&gt;
&lt;li&gt;check PAM, logging, auditing, and automation scripts;&lt;/li&gt;
&lt;li&gt;confirm the rollback path;&lt;/li&gt;
&lt;li&gt;migrate after the distribution provides stable integration.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This kind of tool sits on the privilege chain, so it is not enough to judge it by whether a few commands can run.
The real test is boundary conditions and failure cases.&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;sudo-rs&lt;/code&gt; is a Rust implementation of classic sudo, aiming to support sudo&amp;rsquo;s core features with a more modern and safer codebase.
Ubuntu 25.10 enabling it by default shows that major distributions are starting to push this direction seriously.&lt;/p&gt;
&lt;p&gt;For ordinary users, the change is small.
You still type &lt;code&gt;sudo&lt;/code&gt;; only the underlying implementation may have become &lt;code&gt;sudo-rs&lt;/code&gt;.
At most, you may notice password asterisks or slightly different error messages.&lt;/p&gt;
&lt;p&gt;For system administrators, compatibility is the key issue.
If the system has complex sudoers rules, sendmail notifications, PAM integration, argument wildcards, or scripts that depend on sudo output, test before upgrading.&lt;/p&gt;
&lt;p&gt;Rewriting in Rust is not a magic cure, but for a security-sensitive tool like sudo, reducing memory-safety risk and maintenance complexity is a direction worth taking seriously.&lt;/p&gt;
&lt;p&gt;References:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://itsfoss.com/sudo-vs-sudo-rs/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;It&amp;rsquo;s FOSS: sudo vs sudo-rs: What You Need to Know&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/trifectatechfoundation/sudo-rs&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;sudo-rs GitHub project&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        </item>
        
    </channel>
</rss>
