31.1 C
Texas
angeloma
Senior Writer and partner

Install Rust Programming Language on Debian 11

Hello, friends. Installing Rust on Debian 11 is an important issue for everyone who wants to learn how to program in this programming language. That’s why today in this post, you will learn how to install it quickly and easily.

What is Rust?

Rust is a programming language that was born to allow you to write code as fast as C or C++, eliminating the drawbacks with the garbage collector to avoid the problems arising from memory management. This was all thanks to Mozilla, but it has worked so well that many people are using it for many programs.

Currently, Rust is funded by large entities such as Amazon AWS, Microsoft Azure, Google Cloud, Facebook, and, since its inception, Mozilla Firefox. But it is also supported by a large community of users who share their experiences and help those new to the language.

As we know, Rust is quite fast, supports object-oriented programming, and is multi-purpose. So all in all it is an important programming language in our time.

- Advertisement -

So, let’s go for it.

Install Rust on Debian 11

From the Rust website, we are informed of a very simple installation procedure. This is due to the presence of an installation script that makes everything very easy.

So to start the process, you have to upgrade the operating system completely.

sudo apt update
sudo apt upgrade

The download of this script will be done using curl so it has to be installed on the system.

sudo apt install curl

If you do not have the build-essential package installed, you need to do so.

sudo apt install build-essential

Now all you have to do is run the following command:

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

During the installation process, you will be asked how the installation will be performed. In this case, it is wise to choose option 1 which will install Rust with the default configuration.

1.- Installing Rust programming Language on Debian 11
1.- Installing Rust programming Language on Debian 11

When the process finishes, you will be prompted to run a command to update the system environment variables. This will allow us to use Rust commands from any location in the terminal.

2.- Rust installed on Debian 11
2.- Rust installed on Debian 11
source $HOME/.cargo/env

And you can also check the compiler version.

rustc --version
rustc 1.54.0 (a178d0322 2021-07-26)

Testing the Rust installation

When we install Rust, we also install cargo which is the Rust package manager and provides us with the command line tools to create our project without any problems.

So, we create our project by executing the following command

cargo new [project-name]

For example

cargo new osradar
     Created binary (application) `osradar` package

This will create a new folder called osradar which will have a file called Cargo.toml where you can specify your project dependencies and manifest. Also, there will be a folder called src where the source code for the application will be. This folder comes with a file called main.rs which is the main file where we will start our coding.

Now access the folder and run the Hello World that comes with the cargo new command.

cd osradar
cargo run

Output:

    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/osradar`
Hello, world!
3.- Rust running properly
3.- Rust running properly

So, Rust is installed correctly.

Conclusion

Rust is a modern programming language that presents an alternative to C++ and can be used in many places and for many things. Installing it on Debian 11 is something we can do without much difficulty as we have explained.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article