Short answer: install Rust with rustup, the official installer: run curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh as your normal user, accept the default, then run . "$HOME/.cargo/env" and rustc --version. You also need a C compiler for linking: build-essential on Debian and Ubuntu, gcc on Rocky Linux.
sudo apt update && sudo apt install -y curl build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"
rustc --version # on 9 Nov 2026: rustc 1.99.1 (58cf8f9c3 2026-10-13)Rust 1.99.1, released on 15 October 2026, is the current stable version as of 9 November 2026; the version line above is the one in the official stable channel manifest, and a new minor release follows every six weeks. The installer flags and messages on this page come from the installer script served by sh.rustup.rs (rustup-init 1.29.3) and from rustup’s source, which we read but did not run, so no rustup or cargo output is shown. This page is about the Rust programming language, not the game.
rustup or the distribution package?
| Method | Rust version you get | Updates |
|---|---|---|
| rustup (sh.rustup.rs) | The current stable, 1.99.1 on 9 November 2026 | rustup update |
apt install rustc cargo | Debian 12: 1.63 · Debian 13: 1.85.1 (1.96.1 in trixie-backports) · Ubuntu 24.04: 1.75 · Ubuntu 26.04: 1.93.1 | With apt, within that version |
apt install rustc-1.97 cargo-1.97 | Ubuntu 24.04 noble-updates: 1.97.1, commands named rustc-1.97 and cargo-1.97 | With apt |
dnf install rust cargo | Rocky Linux 9 and 10 AppStream: 1.92.0 | With dnf |
Use rustup unless you build packages for that distribution. Crates written for the 2024 edition need Rust 1.85 or newer, so Debian 12’s 1.63 and Ubuntu 24.04’s 1.75 cannot build them at all, and Cargo refuses any package whose rust-version is newer than your compiler. rustup also gives you clippy, rustfmt, extra targets and several toolchains side by side, all in your home directory.
Install Rust with rustup on Ubuntu, Debian or Rocky Linux
- 1Install curl and a C compiler
Rust compiles your code itself but calls the system linker through
cc, and many crates compile some C. On Debian and Ubuntu runsudo apt install -y curl build-essential; on Rocky Linux,sudo dnf install -y gcc. The Rust book namesbuild-essentialfor Ubuntu for this reason. - 2Run the installer as the user who will build
Run the curl line from the short answer without
sudoand pick1) Proceed with standard installation. rustup installs per user: toolchains in~/.rustup, andrustc,cargoandrustupin~/.cargo/bin. Withsudo, the installer stops with$HOME differs from euid-obtained home directory: you may be using sudoon systems where sudo keeps yourHOME; elsewhere it quietly installs for root instead of you. - 3Load the PATH in this shell
The installer cannot change the shell you started it from. It ends with
To configure your current shell, you need to source the corresponding env file under $HOME/.cargo, so run. "$HOME/.cargo/env"(note the leading dot) or open a new login shell. - 4Check it
rustc --versionandcargo --versionprint the version, commit hash and date.rustup showlists the installed toolchains and which one is the default.
Install without prompts: -y, --profile minimal, --default-toolchain
For servers, cloud-init or a provisioning script, skip the menu. Downloading the script first also lets you read it before it runs:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init.sh
sh rustup-init.sh -y --profile minimal --default-toolchain stable
. "$HOME/.cargo/env"-ydisables the confirmation prompt. Without it and without a terminal, the script exits withUnable to run interactively. Run with -y to accept defaults, --help for additional options.--profile minimalinstalls onlyrustc,rust-stdandcargo. Thedefaultprofile addsrust-docs,rustfmtandclippy; on a build server the minimal one saves disk, andrustup component add clippy rustfmtadds those two later.--default-toolchaintakesstable, a version such as1.92.0to pin one, ornoneto install only rustup.--no-modify-pathleaves your shell files alone; you then add~/.cargo/bintoPATHyourself.
PATH and ~/.cargo/env
~/.cargo/env is a short shell script that puts $HOME/.cargo/bin at the front of PATH unless it is already there, so rustup’s rustc wins over a /usr/bin/rustc from apt. The installer adds the line . "$HOME/.cargo/env" to ~/.profile and to whichever of ~/.bash_profile, ~/.bash_login and ~/.bashrc exist, and to ~/.zshenv for zsh. Two places do not get that PATH:
sudo cargo buildfails withsudo: cargo: command not found, because sudo swaps your PATH forsecure_path. Build as your user; if a step really needs root, call the binary by its full path. The environment variable guide explains why.- systemd services and cron jobs do not load your profile either. Run the compiled binary from
target/release(or a copy in/usr/local/bin) in the unit, as in creating a systemd service, notcargo run.
First project: cargo new, run and build
cargo new hello # creates hello/Cargo.toml, hello/src/main.rs and a git repository
cd hello
cargo run # builds a debug binary and prints: Hello, world!
cargo build --release # optimized binary in target/release/hellocargo new starts a Git repository unless the folder is already inside one, and the debug build lands in target/debug. cargo check only checks that the code compiles, which is much faster than a full build while you work.
Update Rust, pin a version, add targets
rustup update # newest stable; also checks for a new rustup
rustup toolchain install 1.92.0 # an older version beside it
rustup default stable # which one plain rustc and cargo use
rustup target add x86_64-unknown-linux-musl # static Linux binariesStable Rust ships a new minor version every six weeks, so rustup update is the whole upgrade. Apt-installed Rust only moves with the distribution or its backports.
Installing Rust with apt or dnf instead
sudo apt install rustc cargo works and is fine for building Debian or Ubuntu packages, or a tool whose minimum Rust version is old enough. The versions are the ones in the table: Debian 12 ships rustc 1.63.0 and cargo 0.66.0, Debian 13 ships 1.85.1, and Ubuntu 24.04 ships 1.75.0. Ubuntu 24.04 also has versioned packages up to rustc-1.97 and cargo-1.97 in noble-updates; their commands carry the version in the name, so a plain cargo still runs 1.75. On Rocky Linux 9 and 10, sudo dnf install rust cargo gives 1.92.0.
If you later run rustup on such a system, it warns It looks like you have an existing installation of Rust at:, names /usr/bin on the next line and asks Continue? (y/N) before going on. Both can stay installed: in shells that load ~/.cargo/env, rustup’s copies come first. type -a rustc shows every rustc on your PATH in order.
Common errors when installing or building
| Error | Cause | Fix |
|---|---|---|
error: linker `cc` not found | No C compiler or linker installed | sudo apt install build-essential or sudo dnf install gcc |
rustc: command not found | ~/.cargo/bin is not on PATH in this shell | . "$HOME/.cargo/env" or a new login shell |
failed to run custom build command for `openssl-sys v0.9…` | A crate links OpenSSL and its headers are missing | sudo apt install pkg-config libssl-dev; Rocky: sudo dnf install pkgconf openssl-devel |
$HOME differs from euid-obtained home directory | Installer started with sudo | Run it again as your user |
(signal: 9, SIGKILL: kill) | The kernel killed rustc or the linker for lack of memory | Fewer jobs and swap, see below |
| A crate needs a newer rustc (its rust-version) | Compiler older than the crate supports, typical with apt | Install with rustup, or rustup update |
The linker message is printed by rustc as error: linker `cc` not found with the note No such file or directory (os error 2). The current rustup (1.29.3) also warns at the end of the install with no default linker (`cc`) was found in your PATH.
Building Rust on a small VPS
Cargo runs as many compiler jobs as the server has CPU threads by default, and each of them, plus the final link, can take a lot of memory. On a VPS with 1 or 2 GB of RAM a project with many dependencies can end with the OOM killer stopping the build and cargo reporting signal: 9, SIGKILL: kill. Three things help:
cargo build --release -j 1(orCARGO_BUILD_JOBS=1) builds one crate at a time: slower, but with a much lower memory peak.- A swap file gives the build room to finish instead of being killed; adding swap on Ubuntu and Debian takes a few commands.
- Build on a bigger machine and copy only the binary. Build on the same distribution release as the server, or for
x86_64-unknown-linux-musl, so the binary does not need a newer glibc than the server has.
Watch the disk too: target/ and ~/.cargo/registry grow with every dependency, and cargo clean deletes the build folder of a project. Checking disk usage shows where the space went.
Uninstall Rust
rustup self uninstall # rustup install: removes ~/.rustup, ~/.cargo and the PATH lines
sudo apt remove rustc cargo # apt install on Debian or Ubuntu
sudo dnf remove rust cargo # dnf install on Rocky LinuxFrequently asked
What is the command to install Rust on Linux?
Run curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh as your normal user and accept the standard installation. Then run . "$HOME/.cargo/env" so the current shell finds the new commands, and check with rustc --version. Install build-essential (Debian, Ubuntu) or gcc (Rocky Linux) as well, because Rust needs a C linker.
Should I install Rust with apt or with rustup?
With rustup in almost every case. apt install rustc cargo gives Rust 1.63 on Debian 12, 1.85.1 on Debian 13 and 1.75 on Ubuntu 24.04, while the current stable release on 9 November 2026 is 1.99.1, and many crates need a newer compiler than the distribution ships. The apt packages are fine for building distribution packages or tools with an old minimum Rust version.
How do I install Rust without the interactive prompt?
Download the script with curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init.sh and run sh rustup-init.sh -y --profile minimal --default-toolchain stable. The -y flag skips the confirmation, the minimal profile installs only rustc, rust-std and cargo, and --default-toolchain picks the version. Without -y and without a terminal, the script stops and asks for it.
How do I fix error: linker cc not found?
Rust calls the system C toolchain to link the final binary, and none is installed. On Debian and Ubuntu install it with sudo apt install build-essential, on Rocky Linux with sudo dnf install gcc, then run cargo build again. Nothing in the Rust installation needs to change.