Rust is a modern systems programming language empowering developers to build fast, memory-safe, and concurrent software without relying on a garbage collector. Consistently voted among the most loved languages in global developer surveys, Rust powers operating system kernels, WebAssembly modules, CLI utilities, network proxies, and high-performance backend microservices.
Installing Rust using Rustup (the official Rust toolchain installer) provides access to rustc (the compiler), cargo (the package manager and build system), and clippy (the linter).
Whether setting up a development workstation on Ubuntu 24.04 LTS (Noble Numbat), 22.04 LTS, macOS, or Windows, here is the complete 2026 installation guide.
Last updated: July 24, 2026
Key Takeaways
- Always install Rust via `rustup` rather than Linux distribution package managers (`apt`), as `rustup` manages official release channels (stable, beta, nightly).
- A C compiler (such as `gcc` or `clang`) and build dependencies must be installed on your operating system to support linker operations.
- Cargo is Rust's official package manager, build tool, and dependency resolver: handling compilation, testing, and documentation generation.
- After running the Rustup installation script, refresh your terminal environment using `source '$HOME/.cargo/env'`.
What are the system prerequisites for installing Rust?
Before executing the Rust installation script, install the required C compiler and linker build tools for your platform:
On Ubuntu / Debian / Linux Mint
Open terminal (Ctrl+Alt+T) and install build-essential and development libraries:
sudo apt update
sudo apt install -y build-essential gcc pkg-config libssl-dev curlOn macOS
Install Command Line Tools for Xcode via terminal:
xcode-select --installOn Windows
Download and install the Visual Studio Community build tools with the Desktop development with C++ workload selected, or install WSL2 (Windows Subsystem for Linux).
How do you install Rust and Cargo via Rustup?
The official recommended installer for Rust across all operating systems is Rustup.
Step 1: Run the Official Rustup Installation Script
Execute the following secure HTTPS shell command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shStep 2: Choose Installation Options
The installer displays a summary of target architecture and directory paths:
1) Proceed with standard installation (default - recommended)
2) Customize installation
3) Cancel installationType 1 and press Enter to complete the standard installation.
Step 3: Configure Environment Variables
Rustup installs binaries into $HOME/.cargo/bin. Source the environment configuration into your current terminal session:
source "$HOME/.cargo/env"To ensure cargo and rustc load automatically in future terminal windows, append the PATH entry to your shell configuration (~/.bashrc or ~/.zshrc):
echo 'source "$HOME/.cargo/env"' >> ~/.bashrcStep 4: Verify Installation
Confirm that the Rust compiler (rustc), package manager (cargo), and toolchain manager (rustup) are active:
rustc --version
cargo --version
rustup --versionExpected output example: rustc 1.8x.x (hash date)
How do you manage Rust toolchains and updates?
rustup allows switching between release channels and target platforms without touching system files.
1. Updating Rust to the Latest Stable Version
Rust releases stable updates every 6 weeks. To update your compiler and tools:
rustup update2. Installing and Switching Toolchains (Nightly / Beta)
If a project requires experimental features or nightly compiler flags:
# Install nightly toolchain
rustup toolchain install nightly
# Set default toolchain to nightly
rustup default nightly
# Switch back to stable toolchain
rustup default stable3. Adding Cross-Compilation Targets (WebAssembly / Musl)
To compile statically linked binaries using musl or build WebAssembly modules:
# Add musl target for static Linux binaries
rustup target add x86_64-unknown-linux-musl
# Add WebAssembly target
rustup target add wasm32-unknown-unknownHow do you create and run your first Rust project with Cargo?
Cargo streamlines creating, building, running, and testing Rust applications.
Step 1: Initialize a New Binary Project
Navigate to your workspace directory and create a project:
cargo new hello_rust
cd hello_rustThis creates a standard project layout:
Cargo.toml: Manifest file containing metadata and crate dependencies.src/main.rs: Source file containing the entry pointfn main().
Step 2: Review project code
Inspect src/main.rs:
fn main() {
println!("Hello, World!");
}Step 3: Compile and Execute with Cargo
Build and run your application in development mode:
cargo runOutput:
Compiling hello_rust v0.1.0 (/path/to/hello_rust)
Finished dev [unoptimized + debuginfo] target(s) in 0.42s
Running `target/debug/hello_rust`
Hello, World!Step 4: Build a Production Release Binary
When deploying to production, compile with optimizations enabled:
cargo build --releaseThe optimized executable will be located in target/release/hello_rust.
During active development, run cargo check instead of cargo build. cargo check verifies syntax and type correctness without generating machine code binaries: running 2x to 5x faster.
Frequently Asked Questions (PAA)
Why shouldn’t I install Rust using sudo apt install rustc?
Linux distribution repositories package specific, static Rust versions that lag behind current compiler releases. Installing via rustup ensures you get the latest stable tools and can update seamlessly.
Is Cargo included when installing Rust via Rustup?
Yes. Rustup automatically installs rustc (the compiler), cargo (the package manager), rust-std (the standard library), and rust-docs (local documentation).
How do I uninstall Rust completely?
To remove Rustup, Cargo, and all installed toolchains from your computer, run:
rustup self uninstallWhere are Cargo dependencies (crates) stored locally?
Cargo caches downloaded dependencies from Crates.io inside $HOME/.cargo/registry/ and $HOME/.cargo/git/.
Read Next
- How to Install Git on Ubuntu, macOS, and Windows
- How to Install VS Code on Ubuntu, macOS, and Windows
- How to Install Go (Golang) on Ubuntu & Linux
Related Articles
Deepen your understanding with these curated continuations.

How to Install Go (Golang) on Ubuntu & Linux (2026)
Complete guide to downloading, installing, and configuring Go (Golang) on Ubuntu 24.04/22.04 LTS with environment PATH setup and Go modules.

How to Install Lightweight Kubernetes (K3s) on Ubuntu (2026)
Learn how to install and configure K3s lightweight Kubernetes on Ubuntu 24.04/22.04 LTS with kubectl, non-root access, and Traefik ingress.

How to Install Open-WebUI with Ollama for Local AI (2026)
Step-by-step guide to installing Open-WebUI and Ollama using Docker on Ubuntu and Linux for a private, offline ChatGPT-like AI environment.


