How to Install Rust Programming Language in Linux

Rust (commonly known as Rust-Lang) is a relatively new, open source practical systems programming language that runs extremely fast, prevents segfaults, and guarantees thread safety. It is a safe and concurrent language developed by Mozilla and backed by LLVM.

It supports zero-cost abstractions, move semantics, guaranteed memory safety, threads without data races, trait-based generics and pattern matching. It also supports type inference, minimal runtime as well as efficient C bindings.

Rust can run on a great number of platforms and is being used in production by companies/organizations such as Dropbox, CoreOS, NPM and many more.

In this article, we will show how to install Rust programming language in Linux and setup your system to get started with writing programs with rust.

Install Rust Programming Language in Linux

To install Rust, use the following official method of installing rust via the installer-script, which requires curl command-line downloader as shown.

$ sudo apt-get install curl  [On Debian/Ubuntu]
# yum install install curl   [On CentOS/RHEL]
# dnf install curl           [On Fedora]

Then install rust by running the following command in your terminal, and follow the onscreen instructions. Note that rust is actually installed as well as managed by the rustup tool.

$ curl --proto '=https' --tlsv1.2 -sSf | sh
Install Rust in Linux

Install Rust in Linux

Once the Rust installation is complete, the Cargo’s bin directory (~/.cargo/bin – where all tools are installed) will be added in your PATH environment variable, in ~/.profile.

During the installation rustup will attempt to add the cargo’s bin directory to your PATH; if this fails for one reason or another, do it manually to get started with using rust.

Add Rust Cargo Bin Directory to PATH

Add Rust Cargo Bin Directory to PATH

Next, source the ~/.profile file to use the modified PATH and configure your current shell to work with the rust environment by running these commands.

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

Finally verify the version of rust installed on your system by running the following command.

$ rustc --version
Check Rust Installed Version in Linux

Check Rust Installed Version in Linux

Test Rust Programming Language in Linux

Now that you have rust installed on your system, you can test it by creating your first rust program as follows. Begin by making a directory where your program files will reside.

$ mkdir myprog
$ cd myprog

Create a file called, copy and paste the following lines of code to the file.

fn main() {
    println!("Hello World, it’s – Best Linux HowTos, Guides on the Internet!");

Then run the following command which will create an executable called test in the current directory.

$ rustc

Finally, execute test as shown.

$ ./test 
Write Programs in Rust Language

Write Programs in Rust Language

Important: You should take note of these points about rust releases:

  • Rust has a 6-week rapid release process, be sure to get many builds of rust available at any time.
  • Secondly, all these builds are managed by rustup, in a consistent manner on every supported platform, enabling installation of rust from the beta and nightly release channels, and support for additional cross-compilation targets.

Rust Homepage:

In this article, we have explained how to install and use rust programming language in Linux. Try it out and give us your feedback or share any queries via the comment form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

5 Responses

  1. sedlav says:

    It seems that your PATH is related to Go, Lang,

  2. Mike says:

    Thank you for your insight, got mine installed on Linux Ubuntu 19.04.

  3. frt says:


    You mean:

    rustc // mot rustc

    Best regards,

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.