Install Rust on Ubuntu 18.04

Install Rust on Ubuntu 18.04

(Last Updated On: September 22, 2018)

Ready to give the new Rust programming language a test run?  In this post I will show you how to install Rust on Ubuntu 18.04.  We will also compile and run a sample Rust application.

What is Rust?

Rust is a relatively new systems programming language that promises to create fast applications that protect form segment faults and guarantees thread safety.  Companies like Atlassian, Chef, CoreOS and DropBox are using Rust.

Install Rust on Ubuntu 18.04

Rust can be installed with a simple curl command:

$ curl -sSf | sh

You will see the installation proceed.

install rust on ubuntu 18.04

Enter 1 to Proceed with installation.  After the installation finishes you will see that you need to configure the environment to run the Rust compiler.

$ source $HOME/.cargo/env

You won’t see any input but rest assured your environment is ready to start compiling Rust programs.  You will only have to do this once.  The next time you login to the terminal it will automatically be loaded for you.

Rust Commands

The install steps form the previous section installed several commands.  I will go over these now:

  • cargo – The package manager used by rust
  • rustc – The actual Rust compiler
  • rustup – The Rust installer that was downloaded and ran in the previous section

Sample Rust Application

Now it is time to get our hands dirty.  Lets go ahead and write a short application in Rust.  Open your favorite editor and create the file below and save it.

// AdminTome Sample Rust Application

fn main() {
  println!("Welcome to the Rust Sample Application");
  println!("By AdminTome Blog");

I won’t go over what everything means but it should be pretty obvious that it will print a couple of lines of text.  If you would like to know more about the Rust language then checkout the Rust by Example documentation.

Now the we have our source file we can compile it to make a native executable:

$ rustc

And finally, you can run your sample application:

$ ./sample

Click here for more great articles from AdminTome Blog.

Need Good Rust Training?

Check out this Rust Fundamentals course from Pluralsight.  Pluralsight has great video-based courses at a great price.  I use pluralsight every time I need to learn something new.


I hope you have enjoyed this article, if so please leave a comment below.  For more articles, please signup for the AdminTome Blog below.  Also please feel free to share the article to your friends using the buttons to the left.  Thanks again for reading this post.

1 thought on “Install Rust on Ubuntu 18.04

Leave a Comment

you're currently offline