How to Install Rust on Rocky Linux 8

Install Rust on Rocky Linux 8

In this article, we will have explained the necessary steps to install Rust on Rocky Linux 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Rust (commonly known as Rust-Lang) is a modern, powerful, open-source server-side programming language. 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.

Install Rust on Rocky Linux 8

Step 1. First, before you start installing any package on your Rocky Linux server, we always recommend making sure that all system packages are updated.

sudo dnf install epel-release
sudo dnf install cmake gcc make curl
sudo dnf update
sudo dnf upgrade

Step 2. Install Rust on Rocky Linux system.

Run the following command to download a Rust script installer using curl command:

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

The script will automatically install the required dependencies and rust itself. After this process is finished, we need to add rustup bin directory to our PATH variable in order to use rustc and other tools supplied by Rust. Now run the following command to activate the rust environment:

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

Finally, let’s verify the version of rust installed in our machine with the command:

rust --version

Step 3. Create Rust Sample Project Application.

It is now time to test the Rust Programming Language by writing a simple program as shown below:

cd && mkdir rust-apps
cd rust-apps

Let’s now create and open a new rust file with the command:

sudo nano hello_world.rs

Copy the following lines of code that print the statement “Hello World, LinuxTips”. Save and close the file:

fn main(){
println!(“Hello World, LinuxTips”);
}

After saving the above file, then compile the program with the following command:

rustc hello_world.rs

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

./hello_world

That’s all you need to do to install Rust on Rocky Linux 8. I hope you find this quick tip helpful. For further reading on Rust programming language, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.