info@ceoworld.biz
Sunday, November 17, 2024
CEOWORLD magazine - Latest - Education and Career - How To Install The Rust Programming Language On Linux

Education and Career

How To Install The Rust Programming Language On Linux

Rust was developed by Mozilla, originally released on July 7, 2010, and designed for highly concurrent and safe systems. The syntax of Rust is similar to C and C++, with blocks of code delimited by curly braces ({}). The emphasis of Rust is safety, control of memory layout, and concurrency.

Rust is currently being employed by companies like Dropbox, Sentry, Postmates, Brilliant, Tonsser Stac, Wantedly, Klarna, Doctolib, QIWI, and software development companies like BairesDev. Rust seamlessly integrates with tools like Google Code, Ethereum, Iron, Ripple, Leaf, Tokamak, Pencil, and Airbrake.

The Rust language supports zero-cost abstractions, threads without data races, trait-based generics, and pattern matching. It’s also fast, has a minimal runtime, supports algebraic data types, includes efficient C bindings, and is open source. Those new to Rust will need to install the programing language on a supported platform.

Although there are a number of operating systems Rust can be used on, chances are you’ll be developing with Rust on Linux, especially for web-based applications and services. So let’s walk through the process of installing Rust on Linux. I’ll show you how to install this programming language on Debian/Ubuntu and CentOS/RHEL. Once installed, you can start your development journey to create world-class applications and services.

What You’ll Need

The only things you’ll need to get Rust installed are:

  • A running Linux distribution.
  • A user with sudo privileges.
  • A network connection.

That’s it. Let’s install it.

Update/Upgrade

Before we jump into the installation of Rust, let’s update and upgrade our system. Just remember that if the kernel gets upgraded, you’ll need to reboot the machine. Because of this, make sure to run the update/upgrade process at a time when a reboot is possible.

Once you have the time set, you can upgrade the different distributions like so.

Debian/Ubuntu with the commands:

sudo apt-get update

sudo apt-get upgrade -y

CentOS/RHEL with the command:

sudo dnf update -y

If required, reboot and log back into your machine.

Installing Rust

Now, we can install Rust. In order to do so, we must first install the curl application. This can be done on the various distributions with the following commands.

Debian/Ubuntu:

sudo apt-get install curl -y

CentOS/RHEL:

sudo dnf install curl -y

With curl installed, download and run the Rust installation script with the command:

curl https://sh.rustup.rs -sSf | sh

Once the installer has downloaded it will automatically run and ask you if you want to proceed, customize, or cancel the installation (Figure 1).

Figure 1

Proceeding with the installation.

Type 1 to proceed with the installation. During the process, rustup will attempt to add Cargo’s bin directory to your $PATH. Chances are it will fail, so you’ll have to do it manually. To add the Cargo bin directory to your $PATH, issue the command:

source $HOME/.cargo/env

You also need to source ~/.profile to use the modified $PATH and ensure your shell will work with the rust environment. Do this with the command:

source ~/.profile

Once you’ve taken care of that, log out and log back into your machine and verify the rust installation by issuing the command:

rustc –version

You should see the version of Rust printed in the output (Figure 2).

Figure 2

Rust has been successfully installed.

Finally, you’ll need to install the required dependencies for the rustc command. Here’s how you do that on the various distributions.

Debian/Ubuntu:

sudo apt-get install build-essential -y

CentOS/RHEL:

sudo dnf install cmake gcc -y

Testing Rust

If you’re an application development company, it’s not enough to just install the programming language. You need to test the Rust installation by creating a simple program. We’ll create the tried and true “Hello, World!” application.

First, create a new directory for the program with the command:

mkdir rusttest

Change into that new directory with the command:

cd rusttest

Create a new file with the command:

nano rusttest.rs

Paste the following into that file:

fn main() {

println!(“Hello, World!”);

}

Create the Rust executable with the command:

rustc rusttest.rs

You will not see any output from the above command. You should, however, see a new executable application in the rusttest directory, called rusttest. To run that executable application, issue the command:

./rusttest

When you execute the application, Hello, World! should print out on your screen (Figure 3).

Figure 3

A successful test of Rust.

And that’s all there is to installing Rust and creating your first program. Congratulations, your journey is just beginning. You’ll soon be creating powerful and helpful applications used by your company or end-users around the globe.


Have you read?

World’s Happiest Countries.
Countries With The Highest Life Expectancy.
World’s Most (And Least) Religious Countries.
World’s Best Countries For Investment In Travel And Tourism Sector.


Add CEOWORLD magazine to your Google News feed.
Follow CEOWORLD magazine headlines on: Google News, LinkedIn, Twitter, and Facebook.
Copyright 2024 The CEOWORLD magazine. All rights reserved. This material (and any extract from it) must not be copied, redistributed or placed on any website, without CEOWORLD magazine' prior written consent. For media queries, please contact: info@ceoworld.biz
CEOWORLD magazine - Latest - Education and Career - How To Install The Rust Programming Language On Linux
Ryan Miller
Ryan Miller is a Senior Economist and Alternate Executive Editor at CEOWORLD magazine. He specializes in global finance, labor laws, international banking, public financial management, fiscal policy, and applied microeconomics. In his current role, he oversees the production of special reports, profiles, and lists for the magazine. Prior to this, he was an Advisor to the Editor-in-Chief for one year. Before that, he served as the lead economist for Central America (Costa Rica, El Salvador, Guatemala, Honduras, Nicaragua, and Panama), Europe, and Central Asia in the magazine's news division. Ryan has extensive experience in economic forecasting, surveillance, and providing economic policy advice.


Follow Ryan on Twitter, Facebook, Instagram, or connect on LinkedIn. Email her at Ryan@ceoworld.biz.