Rust is a modern programming language known for its performance and reliability, particularly suited for systems programming. If you’re using AlmaLinux 8.10, a CentOS alternative, and want to install Rust, follow these steps to get up and running.
Prerequisites
Before you begin, ensure you have the following:
- An AlmaLinux 8.10 system
- A user account with sudo privileges
- Internet connectivity to download necessary packages
Step 1: Update Your System
To start, update your system to ensure all existing packages are up to date. Open a terminal and run:
$ sudo dnf update -y
Step 2: Install Required Dependencies
Install the necessary dependencies for Rust. Rust requires curl
to download the installation script.
$ sudo dnf install -y curl
Step 3: Download and Install rustup
The recommended way to install Rust is via rustup
, a toolchain installer for the Rust programming language. Download and run the installation script with curl
:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
During the installation, you will be prompted to proceed with the installation. Press 1
to proceed with the default installation.
Step 4: Configure the Environment
After installation, you need to configure your current shell environment to include Cargo’s bin directory (where Rust binaries are installed). This can be done by running:
$ source $HOME/.cargo/env
To make this change permanent, add the following line to your .bashrc
or .bash_profile
file:
$ echo 'source $HOME/.cargo/env' >> ~/.bashrc
Then, reload the shell configuration:
$ source ~/.bashrc
Step 5: Verify the Installation
To confirm that Rust is installed correctly, check the version of Rust and Cargo (Rust’s package manager) by running:
$ rustc --version
$ cargo --version
You should see output similar to:
$ rustc 1.56.0 (09c42c458 2021-10-18)
$ cargo 1.56.0 (4ed5d137b 2021-10-07)
Step 6: Update Rust (Optional)
Rust is frequently updated with new features and improvements. To update Rust to the latest version, use rustup
:
$ rustup update
Step 7: Create and Run a Simple Rust Program
To verify that everything is working correctly, you can create and run a simple Rust program. First, create a new directory for your project:
$ mkdir ~/rust-projects
$ cd ~/rust-projects
Create a new Rust project using Cargo:
$ cargo new hello_world
$ cd hello_world
This will create a basic “Hello, world!” program. To run it, use:
$ cargo run
You should see:
Compiling hello_world v0.1.0 (/home/user/rust-projects/hello_world)
Finished dev [unoptimized + debuginfo] target(s) in 2.18s
Running `target/debug/hello_world`
Hello, world!
Conclusion
You have successfully installed Rust on your AlmaLinux 8.10 system. Rust is now ready for you to start developing robust and high-performance applications. For more information on using Rust, check out the official Rust documentation.
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.