How To Set up Rust Programming Language on AlmaLinux 8

In this article, we want to teach you How To Set up Rust Programming Language on AlmaLinux 8.

Rust programming language is open source and has been the “most loved language” in the developer community Stack Overflow’s annual survey for the last four years.

Rust has been called a systems programming language, and in addition to high-level features such as functional programming, it also offers mechanisms for low-level memory management.

How To Set up Rust Programming Language on AlmaLinux 8

Before you start to set up Rust on AlmaLinux 8, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with AlmaLinux 8.

Now follow the steps below to complete this guide.

Install Rust Programming Language on AlmaLinux 8

First, you need to install the Epel repository on your server with the following command:

sudo dnf install epel-release

Then, you need to install the required packages for the Rust programming language on your server with the command below:

sudo dnf install cmake gcc make curl -y

Now you can use the curl command to download the Rust installer script:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

In your output you will see:

Output
Current installation options:

default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

Enter 1 to proceed with the installation.

At this point, you need to start the Rust environment on AlmaLinux 8 with the following command:

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

To verify that Rust programming language is installed successfully on your server, run the command below:

rustc -V
Output
rustc 1.59.0 (9d1b2106e 2022-02-23)

Now that you have Rust installed on your server, let’s see how to use it.

How To Use Rust Programming Language

At this point, we want to show you how to use Rust on AlmaLinux 8 by creating a new sample protect hello world.

First, you need to create a directory for your Rust project with the command below:

mkdir rust-projects

Then, switch to your Rust project directory:

cd rust-projects

Now you need to create a sample application with your favorite text editor, here we use vi:

vi helloworld.rs

Add the following content to the file:

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

When you are done, save and close the file.

Now compile the program with the following command:

rustc helloworld.rs

This will create an executable application after it has finished compiling.

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

./helloworld
Output
Hello World, this is a test provided by orcacore.com

Also, you can update your Rust programming language with the following command:

rustup update
Output
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: checking for self-updates

stable-x86_64-unknown-linux-gnu unchanged - rustc 1.59.0 (9d1b2106e 2022-02-23)

info: cleaning up downloads & tmp directories

If you no longer want to use Rust on AlmaLinux 8, you can easily remove it with the following command:

rustup self uninstall
Output
Thanks for hacking in Rust!

This will uninstall all Rust toolchains and data, and remove
$HOME/.cargo/bin from your PATH environment variable.

Continue? (y/N)

Conclusion

At this point, you learn to Set up Rust Programming Language on AlmaLinux 8.

Hope you enjoy it.

May you will be interested in these articles:

How To Install CouchDB on AlmaLinux 8.

How To Install TensorFlow on AlmaLinux 8.

Set up and Configure XRDP on AlmaLinux 8.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!