Home  »  ArticlesGuidesHardwareLibrariesProgrammingSoftwareTechnologyTools   »   How to Install Rust Programming Language on Rocky Linux 8.10 Systems

How to Install Rust Programming Language on Rocky Linux 8.10 Systems

Rust is a modern programming language known for its performance and reliability, making it a popular choice for system-level programming and web development. This guide will walk you through the steps to install Rust on Rocky Linux 8.10.

Prerequisites

Before you begin, ensure you have:

  • A running Rocky Linux 8.10 system
  • A user account with sudo privileges
  • Internet connectivity to download necessary packages

Step 1: Update Your System

First, update your system to ensure all existing packages are up to date.

$ sudo dnf update -y

Step 2: Install Required Dependencies

Rust requires some dependencies to be installed on your system. Install the necessary development tools and libraries.

$ sudo dnf groupinstall "Development Tools" -y
$ sudo dnf install curl -y

Step 3: Install Rust using Rustup

Rustup is the recommended way to install Rust, as it allows you to easily manage multiple Rust versions and keep them updated.

Download and Run Rustup Script

Download and run the Rustup installation script.

$ 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.

Configure the Environment

After Rustup is installed, you need to configure your current shell environment to include Cargo’s bin directory (where Rust binaries are installed).

$ 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 4: Verify the Installation

To confirm that Rust is installed correctly, check the version of Rust and Cargo (Rust’s package manager).

$ rustc --version
$ cargo --version

You should see output similar to:

plaintextCopy coderustc 1.55.0 (c8dfcfe04 2021-09-06)
cargo 1.55.0 (32da73ab1 2021-08-23)
$ rustc 1.55.0 (c8dfcfe04 2021-09-06)
$ cargo 1.55.0 (32da73ab1 2021-08-23)

Step 5: Update Rust (Optional)

Rust is frequently updated with new features and improvements. To update Rust to the latest version, use Rustup:

$ rustup update

Step 6: Create and Run a Simple Rust Program

To verify that everything is working correctly, you can create and run a simple Rust program.

Create a New Project

First, create a new directory for your project and navigate into it.

$ mkdir ~/rust-projects
$ cd ~/rust-projects

Create a new Rust project using Cargo:

$ cargo new hello_world
$ cd hello_world

This command creates a basic “Hello, world!” program. The main file is located in src/main.rs.

Run the Program

To run the program, use:

$ cargo run

You should see the output:

Compiling hello_world v0.1.0 (/home/user/rust-projects/hello_world)
    Finished dev [unoptimized + debuginfo] target(s) in 0.97s
     Running `target/debug/hello_world`
Hello, world!

Conclusion

You have successfully installed Rust on your Rocky Linux 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.

Happy coding!

References

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.