DebianDebian Based

How To Install Rust on Debian 12

Install Rust on Debian 12

In this tutorial, we will show you how to install Rust on Debian 12. Rust, the programming language that has been making waves in the software development world, offers developers unparalleled safety and performance features. Whether you’re a seasoned programmer or just starting your coding journey, Rust has something to offer.

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 Rust programming language on a Debian 12 (Bookworm).

Prerequisites

  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • 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).
  • Make sure your Debian 12 system is connected to the internet. An active connection is essential for downloading the required packages and updates during the installation.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Rust on Debian 12 Bookworm

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade

This command updates the package list and upgrades the installed packages to their latest versions.

Step 2. Installing Rust Programming Language on Debian 12.

Now, let’s obtain the official Rust installer script from the Rust website. Use the curl command to download it:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

This command fetches the script and passes it to the sh shell for execution.

Execute the Rust installer script by running the following command:

source $HOME/.cargo/env

This command sets up the environment for Rust by sourcing the appropriate file.

To verify that Rust is installed correctly, check the Rust version using:

rustc --version

Output:

root@idroot.us:~# rustc --version
rustc 1.73.0 (gd26466b5 2023-10-10)
root@idroot.us:~#

You should see the Rust version displayed in your terminal, indicating that the installation was successful.

Step 3. Configuring Rust.

Now that you have Rust installed on your Debian 12 system, it’s essential to configure it properly. Rust requires specific environment variables to be set up correctly. You can do this by adding the following line to your shell configuration file (e.g., .bashrc, .zshrc, or .profile):

source $HOME/.cargo/env

This line ensures that the Rust environment variables are loaded every time you start a new terminal session.

Rust is a rapidly evolving language, and it’s crucial to keep it up to date. You can do this easily using the official package manager for Rust, rustup. Run the following command to update Rust:

rustup update

Step 4. Create a Simple Rust Program.

Create a new directory for your Rust project, and inside it, create a file named main.rs with the following content:

fn main() {
println!("Hello, Mey Mey!");
}

To compile the program, open your terminal, navigate to the directory containing main.rs, and run the following command:

rustc main.rs

Now, execute the program:

./main

You should see the output “Hello, Mey Mey!” displayed in your terminal, indicating that your Rust installation is working correctly.

Congratulations! You have successfully installed Rust. Thanks for using this tutorial to install the latest version of Rust programming language on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Rust website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button