How to Install Rust Programming Language on Rocky Linux 8


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 Rust Programming language, you will know how to install Rust Programming Language on Rocky Linux 8.


  • Recommended OS: Rocky Linux 8.+.
  • User account: A user account with sudo or root access.

Update Operating System

Update your Rocky Linux operating system to make sure all existing packages are up to date:

sudo dnf upgrade --refresh -y

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:


sudo whoami

Example output showing sudo status:

[joshua@rockylinux ~]$ sudo whoami

To set up an existing or new sudo account, visit our tutorial on How to Add a User to Sudoers on Rocky Linux.


To use the root account, use the following command with the root password to log in.


Install Required Packages

The first step is to import the repository from EPEL (Extra Packages for Enterprise Linux); this will install updated dependencies and should be used regardless unless you are in a strict production environment.

Execute the command as follows:

sudo dnf install epel-release

Example output:


How to Install Rust Programming Language on Rocky Linux 8

Type “Y,” then press “ENTER KEY” to proceed with the installation.

Alternatively, use the “-y flag” to skip this and force the installation.

Next, install CMake, GCC, and Make, which must be compiled when creating Rust applications.

sudo dnf install cmake gcc make curl clang -y

Install Rust Programming Language

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

You should see an output like the example below. “Type 1” and hit “Enter” to continue.



How to Install Rust Programming Language on Rocky Linux 8

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:

Now 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 in turn will show you it is successfully installed as well. Type the following command and hit enter:

rustc -V

Example output (This will change in time with newer versions):

rustc 1.55.0 (c8dfcfe04 2021-09-06)

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 guide, you will create the famous (Hello World) output using rust.

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



mkdir path/to/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) and then exit (CTRL+X) then 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:

How to Install Rust Programming Language on Rocky Linux 8

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 Programming Language on Rocky Linux 8

How to Update 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 Programming Language on Rocky Linux 8

How to Remove (Uninstall) Rust

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

rustup self uninstall

Example output:

How to Install Rust Programming Language on Rocky Linux 8

To successfully remove, type “Y” and press the “ENTER KEY.”


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

Comments and Conclusion

In the tutorial, you have learned how to install Rust programming language on your Rocky Linux 8 operating system 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++, eliminate a whole class of security bugs in your software.

Share on: