How to Install Rustup on Linux ?

How to Install Rustup on Linux ?

A Rust project needs a compiler before you can build it on Linux. Rustup is Rust’s installer and toolchain manager, which sets up the compiler and lets you choose a toolchain.

I’ll show how to install Rustup and check that the Rust tools are available.

TL;DR

Install Rustup with Rust’s official shell installer, choose the stable default, then load Cargo’s bin directory into your shell’s PATH.

  • Installer: curl –proto ‘=https’ –tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Initialize the current POSIX-style shell with . “$HOME/.cargo/env” if the installer did not update PATH.
  • Check rustup show, rustc –version and cargo –version.

What is Rustup?

Rustup is the official installer and toolchain manager for Rust. A toolchain is the selected Rust compiler and its supporting components, including the standard library and Cargo.

Rustup installs a default toolchain and lets you add or switch between release channels. Stable is the normal choice for application development.

Beta tracks the next release, while nightly contains daily development builds and can be needed for features that have not reached stable. These channels are separate toolchains, not separate Rust languages.

Cargo is the command-line tool used to build Rust projects and manage their dependencies. Rustup supplies Cargo and rustc through the active toolchain, so selecting a toolchain changes which compiler and tools your shell invokes.

How to install Rustup on Linux step by step

The official Rust installation page recommends Rustup for Linux and other Unix-like systems. You need an internet connection to download the installer and toolchain. A C linker is also needed to build many programs, though it is separate from Rustup.

Step 1: Run the official Rust installer

Open a terminal and run the command below. It uses curl to fetch the installer script over HTTPS with TLS 1.2 or newer, then passes that script to sh.

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

The installer presents choices for the default installation, customization or cancellation. The default installs the stable toolchain. Read the displayed options before choosing, especially on a machine where a Rust installation already exists.

The installer completed and reported the stable toolchain status, then printed instructions for adding Cargo’s bin directory to PATH. The terminal capture shows that result.

Terminal output from the Rustup installer
Rustup installer confirmation and its PATH setup instruction.

The installer may modify shell startup files, but that change does not necessarily affect terminals that are already open. Do not repeat the installation just because the current shell has not loaded the updated environment.

Step 2: Load Cargo’s bin directory into PATH

Rustup places its command-line tools in $HOME/.cargo/bin. PATH is the list of directories a shell searches when you type a command. If the installer asks you to source the environment file, or a new terminal cannot find rustup, load that file in the current shell.

. "$HOME/.cargo/env"

The dot command reads the environment file into the current shell process. That matters because a separate shell command cannot change the parent terminal’s PATH. Bash and Zsh both use this POSIX shell syntax.

For another terminal session, close and reopen the terminal or use the startup-file instructions printed by the installer for your shell. Fish and other shells may need their own configuration command, so use the installer’s matching instruction rather than copying a Bash-specific line.

Step 3: Verify Rustup, rustc and Cargo

Run the version checks and ask Rustup which toolchain is active. These commands confirm that the shell can resolve each program and show which Rust compiler toolchain is selected.

rustup --version
rustc --version
cargo --version
rustup show active-toolchain

Successful version output contains version numbers that change as Rust releases updates. Do not compare them with a fixed tutorial screenshot. The active-toolchain line should name a toolchain such as stable for your host architecture.

Rustc is the compiler, while Cargo handles project builds and dependencies. Rustup’s own version is separate from the compiler version, so seeing different numbers for rustup and rustc is expected.

What to check after installing Rustup

Once the commands work, leave stable as the default unless a project asks for another toolchain. Rustup can maintain several channels and select one for a project without replacing the whole installation.

ToolchainUse it whenInstall command
stableBuilding ordinary Rust projectsrustup toolchain install stable
betaChecking the next Rust releaserustup toolchain install beta
nightlyA project requires nightly-only featuresrustup toolchain install nightly

Installing another channel does not make it the default. Use rustup default stable to choose the default explicitly. A project can also use a toolchain override, so check inside the project directory if its compiler differs from the global default.

Update the Rust toolchain

Run Rustup’s update command to update installed toolchains managed by Rustup. Check the active compiler version afterward if your project depends on a particular release.

rustup update

This command updates Rustup-managed components. It does not update a separately installed system package of rustc. Avoid maintaining two competing Rust installations unless you know which one your PATH selects.

Fix “rustup: command not found”

If the installer completed but the shell reports that rustup or rustc is missing, first check whether the files exist in Cargo’s bin directory and whether that directory is in PATH.

test -x "$HOME/.cargo/bin/rustup" && printf 'rustup is installed\n'
printf '%s\n' "$PATH"
. "$HOME/.cargo/env"
rustup --version

If the first check succeeds, source the environment file and retry in that terminal. If the executable is absent, review the installer result and rerun the official installer only after checking for an existing Rust setup. A new terminal can also pick up startup-file changes that an open terminal has not read.

Install a linker if compilation asks for one

Rustup installs Rust tools, but it does not replace the platform’s native linker. The Rust Book notes that Linux users may need GCC or Clang when a build reports linker errors. Follow your distribution’s documentation for installing its compiler and linker packages.

Do not install build tools preemptively just to make Rustup run. This dependency matters when compiling a program that needs native linking, and some Rust packages also build native C code.

Uninstall a Rustup-managed toolchain

Rustup’s official installation page documents rustup self uninstall for removing a Rustup installation. It removes the toolchains and configuration managed by that Rustup installation, so use it only when you intend to remove those files.

rustup self uninstall

Do not manually delete ~/.rustup or ~/.cargo as a shortcut. Cargo’s directory can also contain installed command-line tools and configuration. If Rust came from a Linux package manager instead, remove it through that manager and check whether another Rustup installation remains on PATH.

When a project needs a particular compiler, install that channel without changing the machine-wide default. From the project directory, Rustup can also use a local toolchain file to select a version for that directory and its children.

rustup toolchain install nightly
rustup run nightly rustc --version

The first command adds nightly alongside stable. The second invokes the nightly compiler for one command without changing the default toolchain. Use the stable compiler again by running rustc normally outside a project override.

On Ubuntu and other distributions, Rustup manages the toolchain in your home directory, while a package manager may install a separate rustc and Cargo under system paths. If both are present, inspect which executable the shell finds before removing either installation.

command -v rustc
command -v cargo

If those paths point into $HOME/.cargo/bin, the shell is using the Rustup-managed commands. A path under /usr/bin commonly indicates distribution packages, so update or remove that installation with the same package manager that installed it.

For a new Rust project, Cargo can create the starter files and build them using the active toolchain. This checks the compiler and package manager together, beyond confirming that each version command responds.

cargo new hello-rust
cd hello-rust
cargo run

The generated program should compile and run through Cargo. If compilation instead reports a missing linker, install the linker and build tools documented for your Linux distribution, then run cargo again.

Conclusion: Rustup manages your Linux Rust toolchain

Rustup installs Rust and selects the toolchain that provides rustc and Cargo. The official Linux installer sets up stable by default, while PATH determines whether your shell can find those commands.

For the authoritative installation route, use the Rust installation page and the Rustup book. The Rust Book installation chapter explains the compiler setup and linker requirement.

FAQ

These answers cover common Rustup installation questions.

How do I install Rustup on Ubuntu?

Run the official Linux installer command `curl –proto ‘=https’ –tlsv1.2 -sSf https://sh.rustup.rs | sh` and follow its prompts. Then load `$HOME/.cargo/env` if needed and verify with `rustc –version`.

Is Rustup required to install Rust?

Rustup is the official recommended installer for most Linux developers because it installs and manages Rust toolchains. Distribution packages are another option, but their versions and management are separate from Rustup.

How do I install the nightly Rust toolchain?

Run `rustup toolchain install nightly` to install nightly alongside other toolchains. It does not become the default unless you select it.

How do I uninstall Rustup?

Run `rustup self uninstall` to remove a Rustup-managed installation. Review the prompt before confirming because Rustup-managed toolchains and configuration are removed.