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
#2 – Install rustup
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
#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
#5 – Verify Rust toolchain installation
#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:
|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
#8 – Compile with the rustc compiler
The compiler should output a single file named ‘hellorust’ which is a compiled binary of the hellorust.rs program:
You can now execute your compiled rust program: