Home  »  ArticlesGuidesHow ToProgrammingTechnologyTools   »   How to Install Rust on Ubuntu 20.04 Using apt

How to Install Rust on Ubuntu 20.04 Using apt

Here is yet another tutorial, this time we will be showing you how to install Rust on Ubuntu 20.04 using the apt package utility. Just one thing. To follow along with this tutorial you will need to be a non-root user with sudo privileges.

Rust is a multi-paradigm, general-purpose programming language designed for performance, efficiency, and safety, especially with regards to concurrency. Like C++ it contains no garbage collector and is also syntactically similar but unlike C++ it is type-safe. See more details here.

Now let’s Install Rust on Ubuntu 20.04

Step 1: Update the package list and upgrade any packages.

$ sudo apt update && sudo apt upgrade

Step 2: Next, install Rust.

$ sudo apt install rustc

Once the installation is completed you can verify the version of Rust installed in your Ubuntu using the following command.

$ rustc --version

rustc 1.53.0

Create a Rust project with a single file to display text to screen.

$ mkdir ~/projects
$ cd ~/projects
$ mkdir hello_world
$ cd hello_world

Create a new file with the .rs extension.

$ sudo nano hello_world.rs

Add the following function to the file.

fn main() {
    println!("Hello, world!");

Compile and run the program.

$ rustc hello_world.rs 
$ ./hello_world

Here’s your output.

Hello, world!

That’s how to install Rust on your Ubuntu-based system using the apt package utility. For those on Debian, we have prepared a guide where you can install Rust on Debian 11 here.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.