×


Install Rust Programming Language on Ubuntu 20.04 - A step by step process ?

Rust is a popular, open-source high-level programming language that was developed in 2006. It is designed for high performance and reliability while emphasizing on the code’s safety. Rust's syntax is similar to that of C++ and it is used to build a wide range of applications such as operating systems, game engines, browser components, and much more

Among the big tech giants that use Rust in their applications include Dropbox, Firefox, and Cloudflare. 

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Linux system Software Installation queries.

In this context, we shall look into how to install Rust programming language on Ubuntu 20.04.


Steps to install Rust programming language on Ubuntu

1. Perform system update

First, start by updating the system packages by running the command:

$ sudo apt update && sudo apt upgrade -y


2. Download and Install Rust

Now we are ready to install Rust. Download the Rust installation script from the official site using the following curl command:

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

This command downloads a script and launches the rustup tool, which installs the latest stable version of Rust. 

You will be prompted to choose an option in order to continue with the installation. Type 1 and press enter to proceed.

To confirm the successful installation of Rust, verify the version installed by running the command:

$ rustc --version

Keep in mind that you will need to activate the Rust environment for your current shell. To enable the rust environment, run:

$ source ~/.profile
$ source ~/.cargo/env


How to test Rust Installation ?

We will run a simple hello world script to make sure rust is properly installed and configured on our machine:

$ mkdir ~/projects
$ cd projects

From the above command, First, we created a new folder to store the rust sample file.

Now, create the file:

$ sudo nano hello.rs

Then, append the following lines to the file:

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

Save the file. Thereafter, compile the rust file with the command:

$ rustc hello.rs

After that, an executable file will be created.

Now run the file to view the output of your program:

$ ./hello

The output 'Hello World' will be displayed.


[Need help in installing any Software on your Linux system ? We can help you. ]


Conclusion

This article covers how to install Rust on your Ubuntu Linux system. In fact, Rust is an open-source programming language which is extremely fast, prevents segfaults, and guarantees thread and memory safety. It supports zero-cost abstractions, threads without data races, move semantics, efficient C bindings, minimal runtime, and pattern matching. It is very similar to C++ and can run on several platforms.