In this guide, you will find:
How to Install Rust on Debian 12
- How to Install Rust on Debian 12 from Source Repository
- How to Install Rust on Debian 12 from Official Script
- Bonus Method: How to Install Rust on Debian 12 from Snap Store
How to Install Rust on Debian 12
You can install Rust on Debian 12 from:
How to Install Rust on Debian 12 from Source Repository
The Debian’s source repository includes the installation of Rust, making it easy for you to install it on your system with a single command. However, before installing Rust on Debian 12, you should update the repository from the following command:
Right after updating the repository, run the below-given command to install Rust on Debian 12:
To ensure Rust is installed on Debian, you can run the following command:
How to Remove Rust from Debian 12
You can remove Rust from Debian 12 installed through repository method by executing the below-given command:
How to Install Rust on Debian 12 from Official Script
If you want to install the latest version of Rust on Debian 12, you can do it using the script provided by the official website. To install Rust on Debian 12 from the script, follow the below-given steps:
Step 1: Install Curl on Debian 12
First, you must install curl on your Debian system through the following command because it will be used later on to download the script file from the Internet:
Step 2: Download and Run Rust Script on Debian 12
Now, download and run the script for Rust installation on Debian using the following command:
Step 3: Install Rust on Debian 12 from Script
At the execution of the script, you will be provided with several options to install Rust on Debian. However, to make things simple, go with the default option by typing 1 in the selection menu:
Step 4: Configure Current Shell
To make changes, you must configure your current shell, this can be done from the following command:
Step 5: Check Rust Version on Debian
Now, run the following command to check for the installed Rust version on Debian:
Step 6: Check for Updates for Rust
If you want to check for Rust updates, you can use the rustup manager that is used to install and manage Rust packages. You can use the following command to check for updated Rust version if available:
Step 6: Update Rust on Debian
If you want to update Rust on Debian, you can use the following command:
Step 7: Install Other Version of Rust on Debian
You can also use the rustup manager to install other version of Rust on your Debian system, this can be done using the rustup install command followed by version number:
Step 8: Uninstall Rust from Debian 12
To uninstall Rust from Debian 12 installed through this method, you can simply use the rustup self command followed by the uninstall keyword. It will install a complete rustup setup from Debian including Rust as well.
Bonus Method: How to Install Rust on Debian 12 from Snap Store
Snap Store is another effective package manager that allows the installation of various applications on your system, which doesn’t conflict with your other packages. You can also use the Snap Store service to install Rust on Debian 12. However, you cannot install Rust on Debian 12 from Snap Store directly because it is not available in the repository. You first have to install rustup manager from Snap Store on Debian through the following command:
Note: To install Snap Store on Debian, you can use the following command:
Now use the rustup command followed by the Rust version you want to install, this can be done using the below-given syntax:
Or you can run rustup from the Snap Store and install any Rust version using the below-given command:
How to Use Rust on Debian 12
To learn how to use Rust on Debian 12 for programming, you can use the following steps:
Step 1: Create a File with .rs Extension
First, create a file using nano editor, add your Rust Programming code and save this file with a proper name with the .rs extension:
Here, I have added the following Rust code inside the file and name the file as hello.rs:
println!("Hello Linux Hint Users");
}
Step 2: Compile the Rust Code on Debian 12
You must compile your code with the rustc interpreter followed the filename you have created in the e:
After the compilation, the rustc interpreter will create a file inside the directory where your Rust file is saved.
Step 3: Run the File
You can run your file on Debian using the following command:
Conclusion
Rust is a robust programming language that you can install on Debian directly from the official system repository. However, to install the latest version of Rust on Debian 12, you have to run the official script that installs Rust with the rustup package manager. Besides that, you can also use Snap Store to install rustup manager and install different versions of Rust programming language on your system. This guide has provided the installation and use of Rust, and after completing the installation, you will be able to start your journey with Rust on Debian 12.