How to Install Rust on AlmaLinux 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 AlmaLinux 8; the tutorial will teach you how to install the latest version with the official bash script.

Update AlmaLinux

First, before proceeding with the tutorial, update your system to ensure all packages are up-to-date to avoid any conflicts using the following command.

sudo dnf upgrade --refresh

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 -y

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

sudo dnf install cmake gcc make curl -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 on AlmaLinux 8

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

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

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

Verify the version build of Rust installed, which will show you it is successfully installed as well. Type the following command and hit enter:

rustc -V

Example output:

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. You will make the famous (Hello World) output using rust for the guide.

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:

If the test application has been adequately compiled, you will see the helloworld file next to the original file.


How to Install Rust on AlmaLinux 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 on AlmaLinux 8

How to Update/Upgrade Rust Programming Language

Updating Rust is relatively easy and is done with a simple command in your terminal.

rustup update

Example output:

How to Install Rust on AlmaLinux 8

How to Remove (Uninstall) Rust Programming Language

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

rustup self uninstall

Example output:

How to Install Rust on AlmaLinux 8

To successfully remove type (Y) and press the enter key.

Next, you will 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 your AlmaLinux 8 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++, eliminates a whole class of security bugs in your software.

Not what you were looking for? Try searching for additional tutorials.

Leave a Comment