How to Install Rust on Rocky Linux 10
Rust is a modern systems programming language focused on speed, memory safety, and parallelism. It’s ideal for performance-critical applications and guarantees memory safety without a garbage collector.
Prerequisites
- A system running Rocky Linux 10
- At least 2 GB of RAM
- Root or sudo access
Update Your System
Ensure your system is up to date before installing any new packages:
sudo dnf update -y
sudo dnf upgrade -y
Install Required Development Tools
Rust depends on certain build tools and libraries. Install them using:
sudo dnf install cmake gcc make curl clang -y
Enable the EPEL Repository
Some dependencies may require EPEL (Extra Packages for Enterprise Linux):
sudo dnf install epel-release -y
Install Rust Using rustup
Rust provides an official installer script called rustup
, which manages versions and toolchains.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
You’ll see a welcome prompt. Press 1
to proceed with the default installation.
Load the environment changes:
source $HOME/.cargo/env
To make the path permanent for all sessions:
echo 'source $HOME/.cargo/env' >> ~/.bashrc
Verify the Rust Installation
Check the installed version of the Rust compiler:
rustc --version
Output:
[root@vps ~]# rustc --version
rustc 1.87.0 (17067e9ac 2025-05-09)
Compile and Run Your First Rust Program
Create a Workspace
mkdir -p ~/rustprojects/helloworld
cd ~/rustprojects/helloworld
Create a Rust File
nano hello.rs
Paste the following code:
fn main() {
println!("Congratulations! Rust is installed and running.");
}
Compile the Program
rustc hello.rs
Run the Output Binary
./hello
Output:
Congratulations! Rust is installed and running.
Updating Rust
Rust updates frequently with performance improvements and new features. To update:
rustup update
Example:
[root@vps helloworld]# rustup update
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: checking for self-update
stable-x86_64-unknown-linux-gnu unchanged - rustc 1.87.0 (17067e9ac 2025-05-09)
Conclusion
You have successfully installed Rust on Rocky Linux 10, compiled your first program, and verified the toolchain. You're now ready to start building fast and safe applications with Rust.
Pro Tip: To create and manage full projects with dependency management, use
cargo new project_name
andcargo build
.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS