How To Install Rust on Fedora 38
In this tutorial, we will show you how to install Rust on Fedora 38. For those of you who didn’t know, Rust is a statically typed language that guarantees memory safety, prevents data races, and ensures thread safety. It combines low-level control over hardware with high-level abstractions, making it suitable for a wide range of applications, including system programming, web development, and embedded systems.
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 a Fedora 38.
Features of Rust
- Memory Safety: Rust’s ownership system and borrow checker prevents common memory errors such as null pointer dereferences and buffer overflows at compile time.
- Concurrency: Rust provides lightweight concurrency primitives and enforces safe concurrent programming through ownership and borrowing rules.
- Performance: Rust’s zero-cost abstractions and control over low-level details allow for efficient code execution without sacrificing high-level productivity.
- Cross-platform Compatibility: Rust supports compilation to various platforms, making it easy to develop and deploy applications on different systems.
- Cargo Package Manager: Rust comes with Cargo, a powerful package manager and build system that streamlines project management and dependency resolution.
Prerequisites
- A server running one of the following operating systems: Fedora 38.
- 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).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Rust.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Rust on Fedora 38
Step 1. Before we can install Rust on Fedora 38, it’s important to ensure that our system is up-to-date with the latest packages. This will ensure that we have access to the latest features and bug fixes and that we can install Rust without any issues:
sudo dnf upgrade --refresh
Step 2. Installing Rust Programming Language on Fedora 38.
By default, Rust is not available on Fedora 38 base repository. Now download and run the rustup installation script by executing the following command in the terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Wait for the installation to complete. The script will set up the Rust environment and update your shell’s PATH variable.
To verify that Rust is installed correctly, open a new terminal window and execute the following command:
rustc --version
Step 3. Configuring the Rust Environment.
After installing Rust, it’s necessary to configure the environment by adding the necessary binaries to your PATH. Open a terminal and execute the following command:
source $HOME/.cargo/env
This command ensures that you can access the Rust compiler (rustc
) and the Cargo package manager from any terminal window.
Step 4. Managing Rust Toolchains.
Rust allows you to manage multiple toolchains and switch between them easily. To list the installed toolchains, execute the following command in the terminal:
rustup toolchain list
To switch to a specific toolchain, use the following command:
rustup default <toolchain>
Replace <toolchain>
with the desired toolchain identifier.
Step 5. Testing Rust installation.
To test the Rust compiler, we can create a sample program using the Rust programming language. Use any text editor to create a new file and enter the following Rust code:
fn main() { println!("Hello, world!"); }
Save the file with the name main.rs and compile the Rust code by running the following command:
rustc main.rs
Execute the compiled file by running the following command:
./main
Congratulations! You have successfully installed Rust. Thanks for using this tutorial for installing the Rust programming language on your Fedora 38 system. For additional help or useful information, we recommend you check the official Rust website.