Share your love
Install Rust on Debian 12 From Linux Terminal
In this guide, we want to teach you to Install and Use Rust Programming Language on Debian 12 Bookworm From Linux Terminal. Rust is a static multi-diagram and memory-efficient programming language. It is also focused on speed, security, and performance. You can use Rust to develop:
- game engines,
- file systems,
- websites and tools,
- operating systems,
- browser components,
- and much more.
Debian 12 ships with Rustc 1.63, you can follow the steps below to install it in the latest version which is 1.71.
How To Install Rust on Debian 12 From Linux Terminal?
To complete this guide, you must have access to your server as a non-root user with sudo privileges. To do this, you can follow this guide on Initial Server Setup with Debian 12 Bookworm.
Then, follow the steps below to start your Rust installation from the Linux terminal.
Step 1 – Install the Required Packages for Rust on Linux Terminal
First, you must run the system update and upgrade by using the commands below:
# sudo apt update
# sudo apt upgrade -y
Then, use the following command to install the required packages:
sudo apt install curl build-essential gcc make -y
Step 2 – Download and Run Rust Installer Script on Debian 12
At this point, we will use the Rust installer script to install the latest Rust on Debian 12. To do this, run the command below:
sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo sh
You will get the following output. Type 1 and press enter to continue your installation.
Output
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
When your installation is completed, you will get the following output:
Output
stable-x86_64-unknown-linux-gnu installed - rustc 1.71.0 (8ede3aae2 2023-07-12)
Rust is installed now. Great!
Step 3 – How To Activate Rust Environment Variable on Debian 12?
At this point, you must activate the Rust path environment variable for your current shell with the following commands:
# sudo source ~/.profile
# sudo source ~/.cargo/env
Verify your Rust installation on Debian 12 by checking its version:
rustc -V
Output
rustc 1.71.0 (8ede3aae2 2023-07-12)
Step 4 – Create a Sample Project With Rust Programming Language
To see that our Rust programming language is working correctly, we want to create a sample hello world project with it on Debian 12.
First, you need to create a Rust project directory with the following command:
sudo mkdir ~/rust-projects
Then, switch to your Rust programming directory:
sudo cd rust-projects
Now use your favorite text editor to create your sample application, here we use the vi editor:
sudo vi helloworld.rs
Add the following content to the file:
fn main() {
println!("Hello World, this is a test provided by orcacore.com");
}
When you are done save and close the file.
Next, you need to compile the program with the following Rust command on Debian 12:
sudo rustc helloworld.rs
This will create an executable application.
Run the application with the command below:
sudo ./helloworld
In your output you will see:
Output
Hello World, this is a test provided by orcacore.com
Step 5 – How To Update Rust in Linux Terminal?
To update your Rust programming language, you can use the following command:
sudo rustup update
Step 6 – How To Uninstall Rust in Linux Terminal?
If you don’t want to use Rust, you can easily uninstall it from your Debian 12 with the following command:
sudo rustup self uninstall
Output
Thanks for hacking in Rust!
This will uninstall all Rust toolchains and data, and remove
$HOME/.cargo/bin from your PATH environment variable.
Continue? (y/N) y
info: removing rustup home
info: removing cargo home
info: removing rustup binaries
info: rustup is uninstalled
For more information, you can visit Rust Programming Language Docs.
Conclusion
At this point, you have learned to Install and Use Rust Programming Language in the latest version on Debian 12 Bookworm From Linux Terminal. Also, you have learned to test your Rust installation by creating a sample hello world project.
Hope you enjoy it. For more guides and articles, you can visit the Orcacore website.