Solved: how use rust in linux ubuntu

Rust is an innovative system programming language that runs blazingly fast, and prevents many programming errors such as null pointer dereferencing, thanks to its unique features like ownership and borrowing. It allows direct control of hardware and memory, making it a perfect choice for embedded and system developers. As an efficient, memory-safe, and multi-paradigm language, Rust has become a promising choice in modern field of programming.

Preliminary Setup

Before engaging with Rust, it’s crucial that a suitable programming environment is set up. We’ll make sure that Linux Ubuntu is prepared for Rust development.

Firstly, the system must be updated with the following command.

sudo apt-get update
sudo apt-get upgrade

This will ensure your system is up-to-date before the Rust installation process proceeds.

Next, we’ll install `curl`. This is crucial for fetching the necessary files for installing Rust.

sudo apt-get install curl

Installing Rust

With the preliminary setup complete, it’s time to install Rust. We’ll utilize rustup, the recommended way to install the Rust programming language.

curl –proto ‘=https’ –tlsv1.2 -sSf | sh

This command will download a script and start the installation of the rustup toolchain installer. When the installation is done, we’ll need to add Rust to the system PATH manually.

source $HOME/.cargo/env

We can verify if Rust is installed successfully with the following command:

rustc –version

Writing a Simple Program in Rust

Now that Rust has been installed, let’s create our first Rust program! In Rust, the source file always ends with the `.rs`, and the conventional Rust file-name is always snake_case.

Let’s make a new file called ``, and input the following:

fn main() {
println!(“Hello, world!”);

We can use `rustc` to compile it, then execute with `./`.


We should see “Hello, world!” printed in the console. Success!

The Rust Ecosystem

The Rust environment comes with `cargo`, a build system and package manager. It makes managing dependencies and building your project a cinch. We’ll cover this in more detail in future sections, as `cargo` is a tremendously useful tool in the Rust ecosystem.

This introduction should be enough to get anyone started with Rust on Ubuntu Linux. In the subsequent articles, we will dive deeper into advanced features and the vibrant ecosystem of Rust.

Related posts:

Leave a Comment