How to Install Rust on Ubuntu 22.04 LTS

Rust is an open-source systems programming language that focuses on speed, memory safety, and parallelism. Developers use Rust to create a wide range of new software applications, such as game engines, operating systems, file systems, browser components, and simulation engines for virtual reality. Rust is syntactically similar to C++ but can guarantee memory safety by using a borrow checker for validating references.

For users, especially developers wanting to try out the Rust Programming language, the following tutorial will teach you how to import and install the latest version on Ubuntu 22.04 LTS Jammy Jellyfish, along with how to engage the Rust terminal with some essential tips such as updating and removing the software using the command line terminal.

Update Ubuntu

The first task is to update your system to ensure all existing packages are updated to avoid conflicts during the installation. Open your terminal and use the following command.

sudo apt update && sudo apt upgrade

Install Dependencies

Before proceeding further, run the following command to install the required packages needed to install and successfully run Rust on your system. The packages are well known and highly used amongst many similar types of installations.

sudo apt install curl build-essential gcc make -y

If you are unsure, just run the command regardless; it will not harm you.

Install Rust

Once you have completed the required installation of packages in prerequisites, you now can use (curl) to download the Rust installation script by executing the following command:

curl --proto '=https' --tlsv1.2 -sSf | sh

Next, you should see an output like the example below with a prompt about installing default or customizing the installation.

Type 1 and press the ENTER KEY to continue unless you want to customize.


How to Install Rust on Ubuntu 22.04 LTS

The entire installation should take between 1 to 5 minutes, depending on your server’s internet speed and hardware.

Once completed, you will see the following outcome:

How to Install Rust on Ubuntu 22.04 LTS

Note you will need to activate the (Rust environment) for your current shell. This is done using the following command to activate the rust environment:

source ~/.profile
source ~/.cargo/env

Verify the version build of Rust installed, which will show you it is successfully installed.

rustc -V

Example output:

How to Install Rust on Ubuntu 22.04 LTS

Note that you have not activated the Rust environment shell if you cannot print out the version build.

Create Rust Sample Project Application

So you have installed Rust and believe it should be working correctly. When installing a programming language on your operating system, the best way to verify is to create a quick test application.

For the tutorial, you will make the famous (Hello World) output using rust.

First, you need to create a directory that will serve as a (Workspace).

mkdir ~/rust-projects

Secondly, change the directory to the Workspace and create a sample application with the following command.

cd rust-projects && nano

Next, enter the following code for the hello world test.

fn main() {
    println!("Hello World, this is a test provided by");

Save and close CTRL+O, exit CTRL+X, and compile the program with the following command.


This will create an executable application after it has finished compiling. The application will be in your current directory as the example output below.


Example output:

How to Install Rust on Ubuntu 22.04 LTS

To run the application you created using Rust, run the program with the execute command:


Example output from the test application as below:

How to Install Rust on Ubuntu 22.04 LTS

How to Update/Upgrade Rust

To update Rust is relatively easy and is done with a simple command in your terminal. Type in the following:

rustup update

Example output:

How to Install Rust on Ubuntu 22.04 LTS

How to Remove (Uninstall) Rust

If in the future you no longer require Rust on your Ubuntu operating system, run the following command:

rustup self uninstall

Example output:

How to Install Rust on Ubuntu 22.04 LTS

To successfully remove type Y and press the ENTER KEY.

You will then get the following result Rust has been successfully removed from your system.

Comments and Conclusion

In the tutorial, you have learned how to install Rust programming language on Ubuntu 22.04 LTS and create a rudimentary test application. Overall, Rust is fantastic, especially in that it guarantees memory safety. You can’t write buffer overflows, dangling pointers, or double-free bugs in Rust which, instead of C/C++, eliminates a whole class of security bugs in your software.


Like to get automatic updates? Follow us on one of our social media accounts!