How to Install Rust on Ubuntu 26.04

Rust is a multi-paradigm, general-purpose programming language that emphasizes performance, type safety, and concurrency. It enforces memory safety—ensuring that all references point to valid memory—without requiring the use of a garbage collector or reference counting present in other memory-safe languages.

Install Rust

Install Rust using the rustup command line tool:

Run the following command to download and start the installer:

curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh

You’ll see output similar to:

Welcome to Rust!

This will download and install the official compiler for the Rust programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup home directory, located at:
/root/.rustup

The Cargo home directory is located at:
/root/.cargo

The cargo, rustc, rustup and other commands will be added to Cargo's bin directory:
/root/.cargo/bin

This path will then be added to your PATH environment variable by modifying:
/root/.profile
/root/.bashrc

You can uninstall at any time with rustup self uninstall.

Current installation options:
1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation

Choose option 1 to proceed.

>1

Once installation completes, you'll see something like:

 info: default toolchain set to stable-x86_64-unknown-linux-gnu

  stable-x86_64-unknown-linux-gnu installed - rustc 1.95.0 (59807616e 2026-04-14)

Rust is installed now. Great!

To get started you may need to restart your current shell.

Add Rust to your PATH:

source "$HOME/.cargo/env"

Verify the Installation

Check the installed Rust version:

rustc --version

Expected output:

rustc 1.95.0

Installing a Compiler and Build Tools

Update the package index:

apt update && apt upgrade -y

Install required development tools:

apt install build-essential -y

Creating, Compiling, and Running a Test Program

Create a project directory:

mkdir -p ~/rustprojects/testdir
cd ~/rustprojects/testdir

Create a file named test.rs:

nano test.rs

Paste the following code:

fn main() {
    println!("Congratulations! You have installed your Rust program and it works.");
}

Save and close the file. Then compile it:

rustc test.rs

Run the program:

./test

Expected output:

Congratulations! You have installed your Rust program and it works.

Updating Rust

To update Rust in the future:

rustup update

Output:

info: syncing channel updates for stable-x86_64-unknown-linux-gnu

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.95.0 (59807616e 2026-04-14)

info: checking for self-update (current version: 1.29.0)
info: cleaning up downloads & tmp directories

🎉 You’ve successfully installed and tested Rust on Ubuntu 26.04.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS