AlmaLinuxLinuxTutorials

How To Install Rust on AlmaLinux 8

Install Rust on AlmaLinux 8

In this tutorial, we will show you how to install Rust on AlmaLinux 8. For those of you who didn’t know, Rust is often called rust-lang. It is a general-purpose, multi-paradigm, modern, cross-platform, and open-source systems programming language sponsored by Mozilla Research. Rust programming language has a variety of other cool features including low-level coding for device drivers, operating systems, and being simplistic makes it easy to use and efficient.

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 AlmaLinux 8. You can follow the same instructions for CentOS and Rocky Linux.

Prerequisites

  • A server running one of the following operating systems: AlmaLinux 8, CentOS, and Rocky Linux 8.
  • It’s recommended that you use a fresh OS install to prevent any potential issues
  • 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 on AlmaLinux 8

Step 1. First, let’s start by ensuring your system is up-to-date.

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

Step 2. Installing Rust on AlmaLinux 8.

Now we download and install Rust with the command below:

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

When the installer has downloaded, it will run and first ask if you want to proceed, customize, or cancel the installation:

info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

It will add the cargo, rustc, rustup and other commands to
Cargo's bin directory, located at:

  /home/idroot/.cargo/bin

This can be modified with the CARGO_HOME environment variable.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/idroot/.rustup

This can be modified with the RUSTUP_HOME environment variable.

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

  /home/idroot/.profile

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
               profile: default
  modify PATH variable: yes

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

After the installer is finished, additional info is given to the user:

Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run source $HOME/.cargo/env

Finally, run the following command to configure your current shell:

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

Verify the version of Rust installed on your system by running the following command below:

rustc -V

Step 3. Create Rust Sample Project.

Let’s test Rust using the “Hello, World!” application. First, create a new directory to house our test with the command:

mkdir ~/rust-projects
cd rust-projects
nano helloworld.rs

Add the following line:

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

Then, run the following command which will create an executable called helloworld in the current directory:

rustc helloworld.rs

Next, run the program with the execute command:

./helloworld

Congratulations! You have successfully installed Rust. Thanks for using this tutorial for installing Rust programming language on your AlmaLinux 8 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 a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button