
Ubuntu 26.04 LTS “Resolute Raccoon” is the first Ubuntu release where Rust is not just an optional developer tool — it runs core system commands like sudo, ls, cp, and mv out of the box. If you work on this system and want to build your own Rust projects, you need to set up the developer toolchain separately. This guide walks you through two proven methods to install Rust on Ubuntu 26.04, configure Cargo, verify your environment, and write real working code.
Whether you are a developer building CLI tools or a sysadmin automating server tasks, the entire setup takes under ten minutes.
Prerequisites
Before you begin this Ubuntu 26.04 setup, confirm the following:
- Operating system: Ubuntu 26.04 LTS (Resolute Raccoon), desktop or server
- User privileges: A non-root user with
sudoaccess (do NOT run this as root) - Internet connection: Required to download packages and Rust crates from crates.io
- Terminal access: Basic comfort with the Linux command line
- Disk space: At least 2 GB free for the toolchain, compiled binaries, and crate cache
- Tested versions: Rust 1.93.1 (apt method), Rust 1.94.1 (rustup method), Cargo 1.94.1
Why non-root? Running rustup as root installs the toolchain into
/root/.cargo. When you later runcargoas a regular user, it cannot find the binaries. This creates permission errors that are annoying to untangle. Always install as your regular user.
Why Rust Matters on Ubuntu 26.04
Ubuntu 26.04 ships with sudo-rs and rust-coreutils as default system packages. This means commands you run every day — ls, cp, mv, cat, sudo — are already compiled from Rust code.
You can confirm this on a fresh Ubuntu 26.04 install:
dpkg -l rust-coreutils sudo-rs
Expected output:
ii rust-coreutils 0.7.0-0ubuntu1 amd64 Universal coreutils, written in Rust
ii sudo-rs 0.2.13-0ubuntu1 amd64 Rust-based sudo and su implementations
This shift happened because Rust eliminates entire categories of memory safety bugs — buffer overflows, use-after-free errors, and null pointer dereferences — that have historically affected C-based system tools. Ubuntu 26.04 is betting on Rust at the OS level, which makes it the ideal platform to start writing Rust code yourself.
Choosing Your Installation Method
Ubuntu 26.04 gives you two ways to install Rust. Each suits a different use case.
| apt (Ubuntu Repos) | rustup (Recommended) | |
|---|---|---|
| Rust version | 1.93.1 | 1.94.1 (latest stable) |
| Channel switching | No | Yes (stable/beta/nightly) |
| Cross-compilation targets | Limited | Full support |
| Update mechanism | apt upgrade |
rustup update |
| Best for | Quick builds, CI scripts | Active development |
The short answer: use rustup if you are writing Rust code. Use apt only if you need a one-time build in a CI environment or do not want to manage toolchains manually.
Step 1: Update Your System
Before installing anything, sync your package index and apply any pending upgrades.
sudo apt update && sudo apt upgrade -y
What this does: apt update refreshes the local package metadata from Ubuntu’s repositories. apt upgrade applies any security patches or library updates that are pending.
Why this matters: If your package index is stale, apt might resolve dependencies against outdated metadata. This can cause version mismatches or fail silently mid-install. A two-second update saves you from debugging avoidable errors later.
Step 2: Install Build Dependencies
This step applies to both methods, but it is especially critical for the rustup path. Install the system libraries the Rust compiler depends on:
sudo apt install -y build-essential pkg-config libssl-dev curl
What each package does and why you need it:
build-essentialpulls ingcc,g++, andmake. Rust’s compiler calls the system C linker (cc) to produce the final binary. Without it, everycargo buildfails withlinker 'cc' not found, even on pure Rust projects.pkg-confighelps the Rust build system locate system libraries at compile time. Many popular crates query it to find OpenSSL, zlib, and other native libraries.libssl-devprovides the OpenSSL development headers. Crates likereqwestandopenssl-syslink against OpenSSL. Without the headers, their build scripts fail with a cryptic “Could not find directory of OpenSSL installation” error.curlis the tool used to download the rustup installer in the next step.
Verify curl is ready:
curl --version
Step 3: Install Rust on Ubuntu 26.04 (Two Methods)
Method A: Install via rustup (Recommended for Developers)
rustup is the official Rust toolchain installer maintained by the Rust project. It manages compiler versions, lets you switch between stable/beta/nightly, and handles cross-compilation targets in one tool.
Download and run the installer:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Why those flags matter:
--proto '=https'restricts the request to HTTPS only, blocking any attempt to redirect through HTTP.--tlsv1.2enforces a minimum TLS version, preventing downgrade attacks against the installer pipe. This is a hardening practice the Rust project itself documents.
When prompted, press 1 to select the default installation. You will see output like this:
info: profile set to default
info: default host triple is x86_64-unknown-linux-gnu
info: latest update on 2026-03-26 for version 1.94.1 (e408947bf 2026-03-25)
info: downloading 6 components
info: default toolchain set to stable-x86_64-unknown-linux-gnu
stable-x86_64-unknown-linux-gnu installed - rustc 1.94.1 (e408947bf 2026-03-25)
Rust is installed now. Great!
Now load the Rust environment into your current shell session:
source "$HOME/.cargo/env"
Why this step exists: The rustup installer appends $HOME/.cargo/bin to your PATH inside .bashrc. That change only takes effect in new terminal sessions. Sourcing the env file makes rustc and cargo available right now, without logging out and back in. Future shell sessions will have Rust in PATH automatically.
Method B: Install Rust via apt (Quick Builds Only)
If you need Rust only for a single build or a CI pipeline, the Ubuntu repository version is the fastest path:
sudo apt install -y rustc cargo
This installs Rust 1.93.1 — Ubuntu 26.04’s packaged version at launch. It is a recent, stable version, just not the absolute latest.
The limitation to know: You cannot switch between stable, beta, and nightly channels with this method. If you outgrow it later, remove it cleanly before switching to rustup:
sudo apt remove -y rustc cargo
Important: Do not have both apt Rust and rustup active at the same time. Your PATH determines which
rustcruns, and version conflicts produce confusing behavior that is difficult to diagnose.
Step 4: Verify the Rust Installation
Run all three version checks:
rustc --version
cargo --version
rustup --version
Expected output for the rustup method:
rustc 1.94.1 (e408947bf 2026-03-25)
cargo 1.94.1 (29ea6fb6a 2026-03-24)
rustup 1.29.0 (28d1352db 2026-03-05)
Now run the full toolchain diagnostic:
rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/youruser/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (active, default)
active toolchain
----------------
name: stable-x86_64-unknown-linux-gnu
installed targets:
x86_64-unknown-linux-gnu
Why rustup show and not just rustc --version? The version flag confirms the binary exists. rustup show tells you the complete toolchain state — active channel, host triple, and installed cross-compilation targets. This is the verification a sysadmin runs before handing a machine to a development team.
Step 5: Compile Your First Rust Program
Create a project directory and write a minimal Rust program:
mkdir -p ~/rust-projects
cat > ~/rust-projects/hello.rs << 'RUSTEOF'
fn main() {
println!("Hello from Rust on Ubuntu 26.04!");
}
RUSTEOF
Compile and run it directly with rustc:
rustc ~/rust-projects/hello.rs -o ~/rust-projects/hello
~/rust-projects/hello
Expected output:
Hello from Rust on Ubuntu 26.04!
Why compile with rustc first, before using Cargo? This step isolates the compiler itself. If this fails, you know the problem is the rustc binary — not your Cargo.toml, project structure, or dependencies. It is the same logic as pinging a server before running a full health check.
Step 6: Create and Build a Real Project with Cargo
Direct rustc compilation works for single files. Real Rust development uses Cargo — Rust’s build system and package manager — for everything else.
Create a new binary project:
cd ~/rust-projects
cargo new myapp
cd myapp
Cargo scaffolds this structure:
myapp/
├── Cargo.toml ← dependency manifest
├── src/
│ └── main.rs ← entry point
└── .gitignore
The generated Cargo.toml uses Rust 2024 edition by default (introduced in Rust 1.85+):
[package]
name = "myapp"
version = "0.1.0"
edition = "2024"
[dependencies]
Build and run the default Hello World:
cargo run
Compiling myapp v0.1.0 (/home/youruser/rust-projects/myapp)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.43s
Running `target/debug/myapp`
Hello, world!
The key Cargo commands you will use daily:
| Command | What it does | Why use it |
|---|---|---|
cargo build |
Compiles a debug build | Fast compilation, includes debug symbols |
cargo build --release |
Compiles an optimized build | ~12x smaller binary, faster runtime |
cargo run |
Builds and runs in one step | Saves time during active development |
cargo test |
Runs all tests | Discovers #[test] functions automatically |
cargo fmt |
Formats code to official style | Keeps code consistent with the Rust ecosystem |
cargo clippy |
Runs the official Rust linter | Catches performance issues and unidiomatic patterns |
Build a Release Binary
When you are ready to deploy, build with the --release flag:
cargo build --release
ls -lh target/debug/myapp target/release/myapp
-rwxrwxr-x 47M target/debug/myapp
-rwxrwxr-x 3.8M target/release/myapp
The debug binary is 47 MB because it carries full debug symbols. The release binary is 3.8 MB. Ship the release build to production; keep debug for local work.
Step 7: Manage Toolchains and Stay Updated with rustup
Update to the Latest Rust Version
Rust ships a new stable release every six weeks. Staying current is a single command:
rustup update
This downloads and installs the new toolchain while keeping your existing projects intact. For the apt method, updates come through the normal sudo apt upgrade cycle.
Why update regularly? Each Rust release brings compiler improvements, new standard library features, and compiler bug fixes. Running a stale toolchain on a production build server means you miss six weeks of improvements with every skipped update.
Install the Nightly Toolchain (Optional)
Some frameworks require unstable compiler features only available on nightly:
rustup install nightly
rustup default nightly
Use nightly knowingly. Features can change or be removed between releases. For production builds, stay on stable.
Add a Cross-Compilation Target for ARM64
To build Rust binaries for ARM64 servers like AWS Graviton, Raspberry Pi, or Apple Silicon VMs:
rustup target add aarch64-unknown-linux-gnu
sudo apt install -y gcc-aarch64-linux-gnu
cargo build --release --target aarch64-unknown-linux-gnu
Why this works cleanly with rustup: The target triple tells the Rust compiler exactly which architecture, OS, and ABI to compile for. Rustup downloads a prebuilt standard library for that target, and GCC provides the linker. You produce a native ARM binary from an x86 Ubuntu machine with no Docker and no remote build server required.
Troubleshooting: Common Errors on Ubuntu 26.04
Error 1: linker 'cc' not found
error: linker `cc` not found
= note: No such file or directory (os error 2)
Cause: build-essential was not installed before running rustup.
Fix:
sudo apt install -y build-essential
Why it happens: Rust’s compiler delegates the final binary linking step to the system C linker. Without GCC installed, there is no cc binary to call, even for pure Rust projects.
Error 2: failed to run custom build command for openssl-sys
Could not find directory of OpenSSL installation
Cause: Missing pkg-config or libssl-dev.
Fix:
sudo apt install -y pkg-config libssl-dev
Alternative (pure Rust TLS, no OpenSSL needed): In Cargo.toml, switch reqwest to use rustls:
reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-features = false }
This eliminates the OpenSSL dependency entirely.
Error 3: apt Rust and rustup Version Conflict
Symptom: rustc --version shows 1.93.1 even after installing rustup 1.94.1.
Cause: Both installations exist and the apt version appears earlier in PATH.
Fix:
sudo apt remove -y rustc cargo
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
Error 4: First cargo build Takes 2 to 3 Minutes
Cause: This is expected on first build. Cargo downloads the crates.io index and compiles all dependencies from source. A project using reqwest + tokio resolves around 176 crates.
What to do: Wait it out. Subsequent builds reuse the compiled cache and finish in seconds. If you hit memory pressure, add 1 to 2 GB of swap — Rust compilation is memory-intensive, especially crates like syn and proc-macro2.
Error 5: rustup: command not found After Installation
Cause: The current shell session has not loaded the updated PATH yet.
Fix:
source "$HOME/.cargo/env"
Or open a new terminal window. All future sessions will have Rust in PATH automatically.
Uninstalling Rust from Ubuntu 26.04
Remove a rustup Installation
rustup self uninstall
This removes rustup, all installed toolchains, $HOME/.cargo, and $HOME/.rustup in one step. Your project source code is untouched, and the PATH entries in .bashrc are cleaned up automatically.
Remove an apt Installation
sudo apt remove -y rustc cargo
sudo apt autoremove -y
Why autoremove? The rustc and cargo packages pull in dependency packages that nothing else on your system needs. autoremove clears them so they do not sit idle on disk.
[su_box title=”VPS Manage Service Offer” style=”bubbles” box_color=”#000000″ radius=”10″]If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal![/su_box]