Install Rust on Ubuntu

Update apt

Start with a refresh of the package index so apt sees the latest package lists.

This step is quick and it prevents confusing errors about missing packages during the install.

sudo apt update

All package lists are up to date

Install rustup with apt

Install the rustup package from the Ubuntu repositories for a simple system managed setup.

After the apt install finishes, use the rustup toolchain command described as text below to select the stable toolchain as the default.

sudo apt install rustup

rustup installed successfully

Run the rustup default stable command as plain text to complete the toolchain selection.

rustc --version check

Open a new terminal window and confirm that the compiler responds with a version number.

rustc --version

rustc 1.75.0 (ad2397f6f 2023-12-28) (x86_64-unknown-linux-gnu)

If the command is not found, restart the shell so the PATH changes made by rustup take effect.

Get a newer toolchain

The apt version can lag behind the latest stable release, so check for updates with rustup on a regular schedule.

Run the rustup update command as plain text to fetch the newest stable compiler and cargo. Run the version check from the previous section again to confirm the new numbers.

The code on this page was not run: it needs Ubuntu and root.

Article author: Arthur Isaev