paint-brush
How To Install Rust Programming Language On Linux (Ubuntu)by@rockyessel
1,773 reads
1,773 reads

How To Install Rust Programming Language On Linux (Ubuntu)

by Rocky EsselFebruary 7th, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Rust can be installed using the Ubuntu APT (Advanced Package Tool) or the curl tool. curl is a command-line tool and library for transferring data with URLs. The command below installs essential development tools (build-essential, gcc, and make) and the curl utility for making HTTP requests and downloading files.

People Mentioned

Mention Thumbnail
featured image - How To Install Rust Programming Language On Linux (Ubuntu)
Rocky Essel HackerNoon profile picture


This tutorial is a segment of an article designed to help web 2.0 developers comprehend concepts like decentralization, centralization, blockchain, and the associated tools (Vara Network & Gear Protocol). However, if your goal is solely to install the Rust programming language, this guide is still applicable.


Prerequisites

To successfully follow this tutorial, you should have a Ubuntu 20.04 server with a non-root user granted sudo privileges, as well as a configured firewall.

Method of Installation

There are two methods by which Rust can be installed on your System.  The first method will be using Ubuntu APT (Advanced Package Tool). It is a command-line tool for managing software packages on your system. With APT, you can install, upgrade, remove, and manage software packages.


The second method will be to use the curl to complete the installation. Curl is a command-line tool and library for transferring data with URLs. It allows you to interact with various network protocols to download or upload data, making it a versatile tool for working with web services and APIs.

System Updates & Upgrade

Firstly, I recommend that whenever you want to install any package at all, it is best practice to first check and install updates and upgrades to the system before continuing with the installation.

sudo apt update && sudo apt upgrade -y

When you run sudo apt update && sudo apt upgrade -y, you first update the package lists to get the latest information about available software packages. Then, if the update is successful, it proceeds to upgrade the installed packages to their latest versions, automatically confirming the upgrades to avoid manual intervention. This is a common and recommended practice to keep your Linux system up-to-date and secure.

Essential dependencies.

The command below installs essential development tools (build-essential, gcc, and make) and the curl utility for making HTTP requests and downloading files. These packages are commonly required for software development, compilation, and system administration tasks.

 sudo apt install curl build-essential gcc make -y

Method 1: Using apt

After successfully installing the commands mentioned above, we can proceed with the installation of our favorite programming language. Execute the following command in your terminal:

sudo apt install rustc 

The above command you run will install the Rust Language successfully, and to verify the installation, run the next command. First verification rustc -V Expected output:

rockyessel@UBUNTU-ROCKY:~$ rustc -V rustc 1.73.0 (cc66ad468 2024-02-07)

Once the output is similar to mine, then you have successfully installed Rust on your system.

Method 2: Using CURL

Since I have explained to you what the curl is, let's dive straight into the installation.

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


In the installation process, you'll be prompted a question: go with the default when it happens.

1. Proceed with installation (default) --> Enter
2. Customize installation
3. Cancel installation.

After this prompt, you have successfully installed Rust on the Ubuntu System. Now the next step is to restart your terminal, simply close the current terminal. Open a new one, and run the command below.

source "$HOME/.cargo/env" 

What this command source "$HOME/.cargo/env" does is to activate the Rust environment. The reason is that the Rust environment comprises essential variables and configurations required for effective Rust usage. Now, once run, there's no output, so you can verify the installation by running the command below.

 rustc -V

Expected output:

rockyessel@UBUNTU-ROCKY:~$ rustc -V rustc 1.73.0 (cc66ad468 2024-02-07)


Preferred Approach: While both methods outlined above effectively install Rust on your system, it's important to note the preferred option. According to the Ubuntu blog's web application and Rust itself, the recommended method is to utilize CURL. However, it's worth mentioning that you have the flexibility to opt for either method, as they achieve the same result.


Conclusion

Having successfully installed Rust, you are now equipped to delve into its robust capabilities. Let's seamlessly transition to the next phase of exploring decentralization(You and I, we code).


Also published here.