How to Install Rust on Ubuntu


Rust or rust-lang is a general-purpose programming language for system-level development projects. Rust is known for its speed, memory efficiency, seamless integration with other languages, and type safety.

This guide will teach you how to install Rust on Ubuntu using the apt package manager or curl.

How to Install Rust on Ubuntu


Option 1: Install Rust on Ubuntu Using apt

The rustc package is included in the official Ubuntu repository, and Rust can be installed with the apt package manager. Even though it may not offer the latest available version, using apt to install Rust is a simple and fast option.

Step 1: Update the Package Registry

First, update the system packages registry with:

sudo apt update
sudo apt update terminal output

Step 2: Install Rust

After updating the package registry, install Rust by running the following command:

sudo apt install rustc
sudo apt install rustc terminal output

Type y when prompted and wait for the installation to complete.

rust installing progress terminal output

Step 3: Verify the Installation

Confirm the installation with:

rustc -V
rustc -V terminal output installed via apt

The command confirms the installation of rustc 1.61.

Option 2: How to Install Rust on Ubuntu Using rustup

To get the latest available version of Rust, use the curl command to download the rustup shell script. The rustup tool allows users to manage Rust in a more straightforward way.

Step 1: Download rustup

To download and install the rustup installer script, use the curl command:

curl -sSf | sh
curl install Rustup terminal output

Note: If you receive a "curl command not found" error message, it is likely that the curl package is not installed on your system. Install it by running sudo apt install curl.

2. Type 1 to proceed with the default installation.

type 1 terminal output

3. Restart the shell if necessary. (The system might not recognize the /.cargo/bin directory.)

Restart shell terminal output

Step 2: Add Rust to PATH

Once the shell reboots, run the following to add Rust to the system PATH:

source "$HOME/.cargo/env"
Add Rust to PATH

The command doesn't produce any output.

Step 3: Verify the Installation

Execute rustc with the -V argument to confirm the installation.

rustc -V
rustc -V terminal output installed via curl

The output shows Rust version 1.65., a more up-to-date version than the one in the repository.

How to Uninstall Rust on Ubuntu

Depending on which method you used to install Rust, use either apt or the rustup tool to uninstall it.

Uninstall Rust Using apt

To uninstall Rust using the apt package manager, run:

sudo apt remove rustc
sudo apt remove rustc terminal output

Confirm with y when prompted. To verify Rust is removed, run rust -V:

rustc -V terminal output uninstalled via apt

The output shows that the package is not on the system.

Uninstall Rust Using rustup

To remove Rust from the system, execute:

rustup self uninstall
rustup self uninstall terminal output

Hit y when prompted. When the process completes, check the Rust version to verify the outcome:

rustc -V terminal output uninstalled via curl


After reading this tutorial, you now know how to install Rust on Ubuntu, either with apt or the Rustup installer. Next, check out this list of the best Linux text editors for coding.

Was this article helpful?
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
How to Reinstall Ubuntu
July 6, 2022

This tutorial shows how to create a bootable USB and reinstall Ubuntu. Reinstalling the OS is sometimes the easiest solution for fixing issues with drivers or after an upgrade failure...
Read more
How to List Installed Packages on Ubuntu
March 9, 2022

Having a precise list of installed packages helps system admins maintain, replicate, and reinstall systems. In this tutorial, learn...
Read more
How to Install Ubuntu 22.04 LTS Desktop (Jammy Jellyfish)
April 20, 2022

Ubuntu 22.04 LTS is the newest Ubuntu version with great new features. Follow this guide to install Ubuntu 22.04...
Read more
How to Fix Broken Packages in Ubuntu
October 14, 2021

A bad internet connection or misconfigured third-party installers can corrupt packages and cause problems on your computer. This article will show...
Read more