VOOZH about

URL: https://thenewstack.io/install-rust-on-linux/

⇱ Install Rust on Linux - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2020-06-05 12:00:59
Install Rust on Linux
tutorial,
Rust / Software Development

Install Rust on Linux

A tutorial on how to install Rust on Linux.
Jun 5th, 2020 12:00pm by Jack Wallen
👁 Featued image for: Install Rust on Linux
Feature image via Pixabay.

An open source programming language, Rust has grown quite popular over the last few years. Developed as a pet project by one-time Mozilla developer Graydon Hoare in 2006 and backed by the LLVM, Rust is extremely fast, prevents segfaults, and guarantees thread and memory safety. Rust also supports zero-cost abstractions, move semantics, threads without data races, trait-based generics, type inference, efficient C bindings, minimal runtime, and pattern matching.

Used by companies like Dropbox, Red Hat, and NPM, Rust is a multiparadigm language that is focused on performance and safety. The Rust language is similar to C++ and can run on numerous platforms.

If you’re looking to write extremely fast code with a very low memory footprint, you would have typically defaulted to C or C++. The problem with those languages is, using them in production code meant you’d have to manage memory manually and understand exactly how you might cause undefined behavior.

The Rust compiler, however, ensures you’re using memory safely, so you can concentrate on the problem you’re trying to solve, not the problem your programming language might introduce. Case in point, the Rust compiler checks every variable you use and every memory address you reference. In fact, according to this chart, half the Linux CVEs in 2018 would have been avoided using Rust.

If you’re curious as to what applications might make for good Rust applications, consider anything that would benefit from a very low overhead:

  • Embedded systems
  • Appliances
  • Industrial machines
  • Internet of Things/Edge Computing
  • Web apps
  • Bare metal development

The only caveat to Rust is that it does have a rather steep learning curve. This is mostly due to the fact that developers must be very aware of basic computing principles regarding memory allocation and concurrency. If, however, you’re willing to take the time to invest in learning Rust, the payoff will be worth the effort.

With that said, I want to walk you through the process of installing Rust on Linux. I’ll be demonstrating the process on both Debian- and Red Hat-based systems. The only things you’ll need are a running instance of Linux and a user with sudo privileges.

Let’s install.

Taking Care of the Dependencies

The first thing we must do is install the necessary dependencies for Rust. Like Rust, these dependencies are found in the standard repository, so the installation can be taken care of with a single command.

On a Debian-based system (such as Ubuntu), the dependency can be installed with the command:

sudo apt-get install build-essential -y

On a Red Hat-based system (such as CentOS), the dependencies can be taken care of with the command:

sudo dnf install cmake gcc -y

Installing Rust

The installation of Rust is actually quite simple. To do this, we’ll make use of the curl command. On the off-chance your distribution doesn’t include curl, you can install it from the standard repository.

On a Debian-based system, you can install curl with the command:

sudo apt-get install curl -y

On a Red Hat-based system, you can install curl with the command:

sudo dnf install curl -y

With curl installed, you can now install Rust, using the same command, regardless of the distribution you are using. That command is:

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

When prompted (Figure 1), type 1 and hit Enter on your keyboard.

👁 Image

Figure 1: Installing Rust on Pop!_OS Linux.

The installer does take a bit of time (no more than 2-5 minutes — depending on your network connection). Once it completes, you’ll be informed of the success (Figure 2).

👁 Image

Figure 2: Rust has been successfully installed.

You will notice, in the output, it states that as soon as you log out and log back in the Cargo bin directory will be added to your $PATH. That might fail. So instead, we’ll help it along manually. To do this, issue the command:

source $HOME/.cargo/env

After you’ve done that, source your user .profile so it will use the modified $PATH and ensure your shell functions properly with the Rust environment. To do this, issue the command:

source ~/.profile

Testing your Installation

With Rust installed, let’s run a test. We’ll use the tried and true “Hello, World!” example, with a twist. Create a new directory with the command:

mkdir ~/rustexample

Change into that directory with the command:

cd ~/rustexample

Next, we’ll create a new rust file with the command:

nano testingrust.rs

In that new file, paste the following:

fn main() {

    println!("Hello, The New Stack!");

}

Save and close the file.

Now, we’ll create the Rust executable for our Hello, World! program with the command:

rustc testingrust.rs

You should see no output.

To run the newly compiled program, issue the command (from within the ~/rustexample directory):

./testingrust

You should see Hello, The New Stack! printed in the output (Figure 3).

👁 Image

Figure 3: Our Hello, World! example runs just fine.

If you wanted, you could copy that executable into a directory that’s in your $PATH, so you could run the program from any directory. To do that, issue the command:

sudo mv testingrust /usr/local/bin

With the program moved, you can now run it, from any directory, with the command:

testingrust

And that’s all there is to installing and using Rust on Linux. At this point, you should probably take the time to read the Rust core documentation, in order to get up to speed on how to get most out of the language.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
Red Hat is a sponsor of The New Stack.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.