Ubuntu’s own Rust packages are fine for stable, system-managed builds, but crates, editor tooling, and upstream examples move faster than Ubuntu’s APT branch on most LTS releases. That gap matters when you install Rust on Ubuntu for active development work. Rust gives you the compiler, while Cargo handles new projects, dependencies, builds, and tests from the same terminal workflow.
Ubuntu 26.04, 24.04, and 22.04 all support the distro packages and the official rustup installer. The current APT candidates resolve to Rust 1.92.x on Ubuntu 26.04 and 1.75.x on Ubuntu 24.04 and 22.04, while rustup tracks Rust 1.94.x across every supported release. Both methods install Cargo automatically, so you do not need a separate Cargo-only setup.
Install Rust on Ubuntu
Refresh APT metadata first, then choose whether Ubuntu or rustup should manage the toolchain on this system.
sudo apt update
These commands use
sudofor system-wide package management. If your account does not have sudo access yet, run the commands as root or follow the guide to add a new user to sudoers on Ubuntu.
Rust is available through Ubuntu’s own packages and through the official upstream toolchain manager. APT keeps the compiler under Ubuntu’s package database, while rustup tracks the current stable release and makes it easier to add nightly toolchains, editor components, and extra targets later.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| rustup (Recommended) | rustup.rs | Current stable | rustup update | Active development, current upstream docs, beta or nightly toolchains, editor tooling |
| Ubuntu APT | Ubuntu packages | Ubuntu 26.04: 1.92.x; Ubuntu 24.04 and 22.04: 1.75.x | APT-managed | System packages, conservative host maintenance, distro packaging parity |
For most developers, rustup is the better fit because it stays aligned with the current stable release and the official Rust documentation. Ubuntu 26.04 and 24.04 also package rustup itself, but those package versions lag the upstream manager and Ubuntu 22.04 does not ship rustup at all, so the official installer script remains the only rustup path that works consistently across all supported Ubuntu LTS releases.
Install Rust with rustup on Ubuntu
Use rustup when you want the current stable compiler, upstream documentation that matches your local toolchain, or the option to add nightly builds later without replacing Ubuntu packages by hand.
Install the prerequisite packages first. Standard Ubuntu desktops often already have ca-certificates and the curl command, but server, minimal, and custom images are the ones most likely to need the full set.
sudo apt install curl ca-certificates build-essential pkg-config
build-essential provides GCC, G++, and Make for crates that still compile native code during a build. pkg-config helps those crates find installed libraries such as OpenSSL or SQLite. If one of your projects also expects a generator step, install CMake on Ubuntu separately.
Run the official installer next:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
The --proto and --tlsv1.2 checks keep the download on HTTPS. The sh -s -- -y portion passes -y to the installer, so it accepts the default stable toolchain without waiting for an interactive menu. If you want to customize the profile or default toolchain, rerun the same command without -y.
Load Rust into the current shell so you can use it right away:
source "$HOME/.cargo/env"
The current shell needs this step once. New terminal sessions pick Rust up automatically after installation because rustup writes the same environment line into your shell startup configuration.
Then verify the toolchain:
rustc --version && cargo --version
rustc 1.94.0 (4a4ef493e 2026-03-02) cargo 1.94.0 (85eff7c80 2026-01-15)
rustup tracks the current stable release, so newer installs will show newer version numbers than this example. On the current supported Ubuntu LTS releases, rustup resolved to Rust 1.94.0.
Install Rust from Ubuntu APT
Choose the APT method when you want Ubuntu to manage Rust through normal package maintenance and you do not need the newest compiler branch on day one.
If a minimal or custom Ubuntu 22.04 system returns Unable to locate package cargo, the missing piece is usually the Universe component. Enable it first with the guide to enable Universe and Multiverse on Ubuntu, then rerun the install command.
sudo apt install rustc cargo
Check the versions Ubuntu installed:
rustc --version && cargo --version
rustc 1.92.0 (ded5c06cf 2025-12-08) (built from a source tarball) cargo 1.92.0 (344c4567c 2025-10-21) (built from a source tarball)
Ubuntu 24.04 and 22.04 currently return rustc 1.75.0 and cargo 1.75.0, even though APT metadata uses longer Ubuntu package revision strings. That smaller version gap on Ubuntu 26.04 makes the repository method more attractive there than on the older LTS releases.
Build a Test Rust Project on Ubuntu
A quick project build proves more than a version check because it exercises Cargo, the compiler, and the local linker in one pass.
cargo new hello-rust --bin
cd hello-rust
cargo run --quiet
Hello, world!
Use cargo run --release when you want an optimized build instead of the default developer profile. If you want version control in the same workflow, install and upgrade Git on Ubuntu before you start committing Rust projects.
Add Rust Development Tools on Ubuntu
The default rustup profile already installs clippy and rustfmt. Add rust-analyzer when you want LSP-style completions, jump-to-definition support, and inline diagnostics in editors such as install Visual Studio Code on Ubuntu.
rustup component add rust-analyzer
Confirm the core development components are present:
This uses grep -E to filter the installed component list down to the Rust tools most editors care about. The grep command guide covers the pattern syntax in more detail.
rustup component list --installed | grep -E 'rust-analyzer|clippy|rustfmt'
clippy-x86_64-unknown-linux-gnu rust-analyzer-x86_64-unknown-linux-gnu rustfmt-x86_64-unknown-linux-gnu
If you stay on Ubuntu APT and only need the formatter plus the linter, install those packaged tools separately:
sudo apt install rustfmt rust-clippy
Ubuntu currently packages rustfmt and rust-clippy, but it does not package rust-analyzer for the supported Ubuntu LTS releases. That keeps rustup as the practical path for editor integration on Ubuntu today.
Manage Rust Updates and Toolchains on Ubuntu
Rust maintenance depends on how you installed it, so use the matching update path instead of mixing rustup and APT commands.
Update Rust installed with rustup on Ubuntu
rustup refreshes every installed toolchain in one pass:
rustup update
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: checking for self-update (current version: 1.29.0) info: cleaning up downloads & tmp directories stable-x86_64-unknown-linux-gnu unchanged - rustc 1.94.0 (4a4ef493e 2026-03-02)
Update Rust installed with Ubuntu APT
If you chose Ubuntu’s packages, upgrade only Rust and Cargo when you want a narrower change set than a full system upgrade:
sudo apt install --only-upgrade rustc cargo
Check rustc --version && cargo --version afterwards if you want to confirm that Ubuntu moved you to a newer packaged branch.
Install a nightly Rust toolchain on Ubuntu
The nightly toolchain is useful when a crate depends on unstable features or you want to test the next compiler line without replacing stable:
rustup toolchain install nightly
List the toolchains now available on your system:
rustup toolchain list
stable-x86_64-unknown-linux-gnu (active, default) nightly-x86_64-unknown-linux-gnu
Use cargo +nightly build later when a single project needs nightly, and leave stable as the default for everything else.
Fix Common Rust Issues on Ubuntu
Most fresh-install problems come down to shell PATH loading, mixed package methods, or missing CA certificates on stripped-down images.
Fix Rust command not found on Ubuntu
If the current shell still prints bash: rustup: command not found, bash: rustc: command not found, or bash: cargo: command not found right after a rustup install, check whether Rust’s binary directory is already on your PATH.
echo "$PATH" | tr ':' '\n' | grep -Fx "$HOME/.cargo/bin"
/home/your-user/.cargo/bin
If that command returns nothing, load the environment file in the current shell:
source "$HOME/.cargo/env"
Then verify the toolchain again:
rustc --version && cargo --version
rustc 1.94.0 (4a4ef493e 2026-03-02) cargo 1.94.0 (85eff7c80 2026-01-15)
Fix APT and rustup version conflicts on Ubuntu
When both installation methods are present, the shell can keep using Ubuntu’s older /usr/bin/rustc even after rustup installs a newer toolchain under ~/.cargo/bin. If you want a broader refresher on PATH resolution, see the which command guide.
which rustc && rustup show active-toolchain
/home/your-user/.cargo/bin/rustc stable-x86_64-unknown-linux-gnu (default)
If which rustc prints /usr/bin/rustc instead, Ubuntu’s APT packages are still winning. Remove the APT packages and reload the shell if you want rustup to stay in control:
sudo apt remove rustc cargo && source "$HOME/.cargo/env"
Fix rustup SSL certificate errors on Ubuntu
If the installer cannot validate HTTPS, Ubuntu is usually missing current CA certificates.
curl: (60) SSL certificate problem: unable to get local issuer certificate
Reinstall the certificate bundle first:
sudo apt install --reinstall ca-certificates
Then confirm the installer URL returns a normal HTTPS response:
curl -fsSI https://sh.rustup.rs | head -n 1
HTTP/2 200
Remove Rust from Ubuntu
Use the removal path that matches the method you installed. rustup and APT manage different files, so one command does not fully clean up the other.
Remove Rust installed with rustup on Ubuntu
This command removes the rustup-managed toolchains, the Cargo home, and the shell startup lines rustup added. The -y flag skips the confirmation prompt.
rustup self uninstall -y
info: removing rustup home info: removing cargo home info: removing rustup binaries info: rustup is uninstalled
rustup leaves project directories such as ~/hello-rust alone, so remove those separately if you no longer want them. It does remove the . "$HOME/.cargo/env" line from the shell startup files it changed during installation.
Verify that the toolchain directories are gone:
for path in ~/.cargo ~/.rustup; do
[ -e "$path" ] && echo "still present: $path" || echo "removed: $path"
done
removed: /home/your-user/.cargo removed: /home/your-user/.rustup
Remove Rust installed from Ubuntu APT
APT users can remove the compiler and package manager with the standard package command:
sudo apt remove rustc cargo
If APT now marks compiler dependencies as unused and you no longer need them for other projects, review the cleanup list before confirming the next step:
sudo apt autoremove
Confirm that Ubuntu no longer sees those packages as installed:
apt-cache policy rustc
apt-cache policy cargo
rustc: Installed: (none) Candidate: 1.92.0ubuntu1 cargo: Installed: (none) Candidate: 1.92.0ubuntu1
On Ubuntu 24.04 and 22.04, the same verification block still shows Installed: (none), but the candidate lines point to the 1.75.x branch instead. On Ubuntu 22.04, the cargo candidate comes from Universe rather than Main.
Rust on Ubuntu FAQ
Use rustup when you want the current stable compiler, upstream documentation that matches your local toolchain, or beta and nightly toolchains later. Use Ubuntu APT when you prefer distro-managed packages and can live with the older Rust branch your Ubuntu release currently ships.
No. Both documented paths install Cargo automatically. Ubuntu APT installs cargo alongside rustc, and the default rustup profile includes Cargo as part of the stable toolchain.
Ubuntu 26.04 and 24.04 package rustup, but those repository versions trail the upstream manager and Ubuntu 22.04 does not package rustup at all. The official installer script from sh.rustup.rs is still the only rustup path that works consistently across all supported Ubuntu LTS releases.
No. The upstream Rust project does not publish an Ubuntu-specific .deb installer. The official Linux path is rustup, while the packaged Ubuntu alternative is the distro’s own APT version of rustc and cargo.
Yes. The Rust toolchain itself is command-line software, so the same install commands work on Ubuntu desktop, server, and minimal systems. Server and minimal images are simply the ones most likely to need packages like curl, ca-certificates, or the Universe component before the install succeeds.
Conclusion
Rust is installed on Ubuntu with either the distro packages or the current stable toolchain from rustup. Start versioning your crates with install and upgrade Git on Ubuntu, pair editor support with install Visual Studio Code on Ubuntu, and keep The Rust Book nearby as you move from hello-world binaries to larger services.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>