Search The Hostwinds Guides Knowledge Base

Install Rust Toolchain (Linux Cloud VPS)

Share This Article [TheChamp-Sharing]

Unlike popular languages like C and Python, which have gcc and CPython bundled in most Linux releases, Rust does not (yet) have native support on Linux, and must be installed separately.

This guide will help if you want to install the Rust development toolchain. You’ll need a Linux host with shell access to get started.

#1 – Update Rust root dir

# export RUSTUP_HOME='~/.rustup'

#2 – Install rustup

# curl --proto '=https' --tlsv1.2 -sSf | sh

Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable
profile: default

modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation


To proceed with the default Rust installation, type 1 when prompted, and press Enter. If you want to modify PATH variables, change the toolchain stream, or add a profile, you can select 2 and provide custom values for each.

#3 – Apply installation PATH changes

# source ~/.bash_profile

#4 – Set Profile

Rust comes with separate profiles that controls which Rust tools are installed in the current environment. The default profile is selected during the installation. You can change profiles at any time

  • minimal – rustc, rust-std, cargo
  • default – rustc, rust-std, cargo, rust-docs, rustfmt, clippy

# rustup set profile minimal

#5 – Verify Rust toolchain installation

# which rustc /root/.cargo/bin/rustc

#6 – Install ‘build-essential’ package

rustc utilizes the gcc linker for the linking stage of compilation. Your host may or may not have cc available. You can install build-essential the following way:

Distro Command
RHEL / CentOS / Amazon Linux sudo yum install gcc gcc-c++ make
Ubuntu / Debian sudo apt-get install build-essential
Fedora sudo yum install make gcc gcc-c++ kernel-devel

At this point, the Rust toolchain has been installed and is ready to use. You can test the Rust toolchain by compiling and executing a test Rust program:

#7 – Create a ‘Hello World’ Rust Program

# echo -e 'fn main() {\n\tprintln!("Hello from Hostwinds!");\n}' >>

# cat
fn main() {
println!("Hello from Hostwinds!");

#8 – Compile with the rustc compiler

# rustc

The compiler should output a single file named ‘hellorust’ which is a compiled binary of the program:

# file hellorust
hellorust: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/, for GNU/Linux 3.2.0, BuildID[sha1]=b7a1b1e072fb63c7be826f7964636d6a3b628485, with debug_info, not stripped, too many notes (256)

You can now execute your compiled rust program:

# ./hellorust
Hello from Hostwinds!

Related Aricles: