How to install Rust language on Fedora

Endrit Qerreti

Endrit Qerreti

Rust is an open source programming language, that started as a side project. Nowadays Rust is widely used, from creating applications to operating systems.

Rust can be easily installed on Fedora, via dnf package manager, by downloading the rust package that can be found on the main repositories of Fedora.

In this tutorial, you will learn how to install Rust on your Fedora machine, easily by using dnf package manager.

Step 1 - Update the system

Since we'll be downloading Rust from the official Fedora repositories, in order to make sure that we can download the latest version of Rust, first we need to update the system.

To update Fedora, simply execute the following command.

sudo dnf update -y

Step 2 - Install Rust on Fedora

Once you have updated your Fedora system, you can now proceed to install Rust.

Rust is available on the default Fedora repositories, so to install Rust, all you need to do is use dnf.

To do so, simply execute the command below.

sudo dnf install rust

Note: The command above will download and install Rust and the compiler rustc, you will also need cargo in order to manage Rust packages on your system.

To install cargo simply run the command below.

sudo dnf install cargo

Step 3 - Verify Rust installation on Fedora

Rust should be now installed on your Fedora system. Before you start using Rust on your system, ensure that Rust was installed correctly.

To do so, simply check Rust version, by running the command below.

rust --version

The command above, will return version of the Rust package that you installed, as shown in the screenshot below.

Step 4 - Add RUST to PATH on Fedora

After verifying that Rust was installed correctly on your Fedora system, now you need to add Rust on your system's PATH so that you can use Rust.

source "$HOME/.cargo/env"

Step 5 - Run Rust Code

To execute a script written in Rust via the terminal on Fedora is very simple.

1) First you need to create the Rust file.

sudo nano hello-world.rs

2) Next, add the following code in the Rust file we created hello-world.rs

fn main() {

    println!("Hello World!");
}

3) Compile Rust file.

rustc hello-world.rs

4) Execute Rust script.

./hello-world.rs

Updating Rust on Fedora

In this tutorial, we installed Rust via dnf package manager, so updating Rust can be done also via dnf.

To update Rust on Fedora, simply run the command below.

sudo dnf update -y

Uninstall Rust on Fedora

If you no longer need Rust installed on your Fedora system, you can easily uninstall it by using dnf also.

To uninstall Rust on Fedora, simply execute the command below.

sudo dnf remove rust

To uninstall Rust package manager cargo, run the following.

sudo dnf remove cargo

Conclusion

In this tutorial, you learned how to install and uninstall Rust programming language on Fedora, using dnf.