RHEL BasedRocky Linux

How To Install Rust Programming Language on Rocky Linux 9

Install Rust Programming Language on Rocky Linux 9

In this tutorial, we will show you how to install Rust Programming Language on Rocky Linux 9. For those of you who didn’t know, Rust is a free and open-source, multi-paradigm, general-purpose programming language developed by Mozilla. This language has many features such as safety, memory, and concurrency. 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.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Rust Programming Language on Rocky Linux. 9.

Prerequisites

  • A server running one of the following operating systems: Rocky Linux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Rust Programming Language on Rocky Linux 9

Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:

sudo dnf check-update
sudo dnf install dnf-utils
sudo dnf install epel-release
sudo dnf install cmake gcc make curl clang

Step 2. Installing Rust Programming Language on Rocky Linux 9.

By default, Rust is not available on Rocky Linux 9 base repository. Now run the following command below to download the latest stable version installer Rust packages from the official page to your system:

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

In your output you will see:

home directory, located at:

  /root/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /root/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /root/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /root/.profile
  /root/.bash_profile
  /root/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

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

Type 1 and hit Enter to start the installation and activate the Rust environment on Rocky Linux 9:

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

Verify the version build of Rust installed:

rustc -V

Step 3. Create Sample Rust Application.

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

mkdir rust-projects

Next, change to your Rust project directory:

cd rust-projects

Now create a sample app using the following command:

nano helloworld.rs

Add the following file:

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

After that, compile the created application above:

rustc helloworld.rs

To run the application you created using Rust on Rocky Linux, run the program with the execute the command below:

./helloworld

Output:

Hello World, this is a test provided by idroot.us

Congratulations! You have successfully installed Rust. Thanks for using this tutorial for installing the Rust Programming Language on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Rust website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button