This detailed tutorial provides a concise introduction to the Rust programming language, followed by clear instructions on how to install Rust using rustup on Linux. It also guides you through updating Rust, creating and running a sample Rust program, and finally, how to uninstall Rust from your Linux system.
Table of Contents
Introduction to Rust Programming Language
Rust, also known as rust-lang, is a modern, fast, cross-platform, and open-source systems programming language designed to replace C/C++ while offering high-level abstractions that appeal to developers familiar with C# and Java.
It boasts a plethora of features, including:
- Zero-cost abstractions: Rust's abstractions incur no runtime overhead, ensuring performance comparable to native code.
- Move semantics: Rust's ownership model utilizes move semantics to efficiently transfer ownership of data between variables, eliminating the need for manual memory management.
- Guaranteed memory safety: Rust's strong type system and ownership model enforce memory safety, preventing memory-related errors like dangling pointers and memory leaks.
- Threads without data races: Rust's type system and ownership model also ensure thread safety, preventing data races and ensuring consistent memory access across threads.
- Trait-based generics: Rust's generic programming capabilities are based on traits, enabling flexible and reusable code that works with a variety of data types.
- Pattern matching: Rust's pattern matching syntax allows for concise and expressive code, particularly when dealing with data structures like enums and tuples.
- Type inference: Rust's type inference system automatically deduces the types of variables and expressions, reducing the need for explicit type declarations.
- Minimal runtime: Rust's minimal runtime eliminates the overhead of garbage collection, further enhancing its performance.
- Efficient C bindings: Rust seamlessly integrates with C code, enabling interoperability with existing C libraries.
Rust is actively used in production by prominent organizations such as Canonical, Chef, Coursera, CoreOS, Dropbox, Mozilla, and NPM.
Install Rust Programming Language in Linux
The Rust language can be installed in a few different ways. The officially recommended method for installing Rust is to use Rustup, the official Rust toolchain installer.
Installing rust using rustup is quite simple. All you have to do is open your Terminal and run the following command:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Or,
curl https://sh.rustup.rs -sSf | sh
Type 1 (number one) to proceed the installation with default values. Or, type 2 to customize the installation. I am going with default values, so I typed 1.
Sample output:
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
/home/ostechnix/.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory is located at:
/home/ostechnix/.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
/home/ostechnix/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile files located at:
/home/ostechnix/.profile
/home/ostechnix/.bash_profile
/home/ostechnix/.bashrc
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host tuple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>1
info: profile set to default
info: default host tuple is x86_64-unknown-linux-gnu
info: syncing channel updates for stable-x86_64-unknown-linux-gnu
info: latest update on 2026-11-12 for version 1.100.0 (0ef1bc386 2026-11-09)
info: downloading 6 components
cargo installed 10.44 MiB clippy installed 5.11 MiB rust-docs installed 23.22 MiB rust-std installed 29.83 MiB rustc installed 81.02 MiB rustfmt installed 2.41 MiB info: default toolchain set to stable-x86_64-unknown-linux-gnu
stable-x86_64-unknown-linux-gnu installed - rustc 1.100.0 (0ef1bc386 2026-11-09)
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, you need to source the
corresponding env file under $HOME/.cargo.
Consider running the right command for your shell (note the leading DOT):
. "$HOME/.cargo/env" # For sh/ash/dash/pdksh/bash
cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
CC_x86_64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
CC_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=HOST_CC
HOST_CC = None
cargo:rerun-if-env-changed=CC
CC = None
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:warning=Compiler family detection failed due to error: ToolNotFound: failed to find tool "cc": No such file or directory (os error 2)
cargo:rerun-if-env-changed=CPATH
cargo:rerun-if-env-changed=C_INCLUDE_PATH
cargo:rerun-if-env-changed=CPLUS_INCLUDE_PATH
cargo:rerun-if-env-changed=OBJC_INCLUDE_PATH
cargo:rerun-if-env-changed=OBJCPLUS_INCLUDE_PATH
cargo:rerun-if-env-changed=COMPILER_PATH
cargo:rerun-if-env-changed=SOURCE_DATE_EPOCH
cargo:rerun-if-env-changed=GCC_EXEC_PREFIX
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=HOST_CFLAGS
HOST_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
CFLAGS_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
CFLAGS_x86_64-unknown-linux-gnu = None
warn: no default linker (`cc`) was found in your PATH
warn: many Rust crates require a system C toolchain to build
As seen in the output above, the rustup installer script downloads and installs the official compiler for the Rust programming language, along with its package manager, Cargo. It also adds commands like cargo, rustc, rustup, and others to Cargo's bin directory, located at ~/.cargo/bin. Furthermore, the script modifies the profile file located at ~/.profile to add Cargo's bin directory to your PATH environment variable.
Finally, run the following command to configure your current shell.
If you're using sh / bash / zsh / ash / dash / pdksh shells, run:
source $HOME/.cargo/env
For fish shell:
source "$HOME/.cargo/env.fish"
For nushell:
source $"($nu.home-path)/.cargo/env.nu"
To verify the installed version, run:
rustc --version
This will print the currently installed Rust version:
rustc 1.100.0 (0ef1bc386 2026-11-09)
You can also use the following commands to verify the Cargo version and installed toolchains:
$ cargo --version
cargo 1.100.0 (3acc79c0c 2026-11-05)
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/ostechnix/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (active, default)
active toolchain
----------------
name: stable-x86_64-unknown-linux-gnu
active because: it's the default toolchain
installed targets:
x86_64-unknown-linux-gnu
If you have multiple Rust toolchains installed, select the stable one:
rustup update stable
rustup default stable
Alright! We have just installed the latest Rust version. Let us go ahead and see if it works by creating a sample rust program.
Update:
The latest Rust installer also notifies you if there is no default linker (cc) was found in your PATH. You need to have a C compiler like gcc installed to act as the linker. For more details, check the Troubleshooting Rust section below.
Create a Sample Program in Rust
Make a main project directory to put all your Rust code in. This directory works as parent directory to all our Rust programs.
For example, I am going to create a main project directory named "my_rust_projects" in my $HOME directory.
$ mkdir ~/my_rust_projectsGo to that directory:
$ cd ~/my_rust_projectsNext create a binary 'hello_world' package using Cargo as shown below.
$ cargo new hello_world
The above command will create a new directory named "hello_world" with all necessary files in it.
CD into that directory:
$ cd hello_world
Finally run hello_world program using command:
$ cargo run
This command compiles and runs your program. You should see "Hello, world!" printed in the terminal.
Sample output:
Compiling hello_world v0.1.0 (/home/ostechnix/my_rust_projects/hello_world)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.61s
Running `target/debug/hello_world`
Hello, world!
This is the recommended way to use Cargo.
Write the Code in Text File and Compile It
Alternatively, you can manually create the project's directory, write the code in a text file and finally compile and run it like below.
Let us create the project directory:
$ mkdir hello_world
Cd into that directory:
$ cd hello_world
Now write your first Rust program using any text or GUI editors. The rust files always ends with extension .rs.
To write a sample rust program, for example ostechnix.rs, do:
$ vi ostechnix.rs
Copy and paste the following code in it.
fn main() {
println!("Hello, Welcome To OSTechNix blog!");
}Press ESC key and type :wq to save and quit the file.
Next run the following command to compile the rust code.
$ rustc ostechnix.rs
The above command will create a executable rust program named ostechnix in the current directory.
$ ls ostechnix ostechnix.rs
Finally run the Rust program with command:
$ ./ostechnix Hello, Welcome To OSTechNix blog!
It's working!!
Rust Learning Resources: Consider checking out The Rust Programming Language book online for comprehensive learning.
Troubleshooting Rust
Sometimes you may get "error: linker cc not found" message when compiling programs with Cargo. To fix this install a C compiler like GCC as described in the following link.
Enable Tab Completion
Rustup supports tab completion for popular shells such as Bash, Fish, Zsh and Powershell.
To enable Tab completion for Bash, do:
$ mkdir -p ~/.local/share/bash-completion/completions
$ rustup completions bash >> ~/.local/share/bash-completion/completions/rustup
On Fish:
$ mkdir -p ~/.config/fish/completions
$ rustup completions fish > ~/.config/fish/completions/rustup.fish
On Zsh:
$ mkdir ~/.zfunc
Then add the following lines to your '.zshrc' file just before 'compinit':
fpath+=~/.zfunc
Now you can install the completions script using the following command:
$ rustup completions zsh > ~/.zfunc/_rustup
After enabling tab completion, you should log out and log back in to your shell session for the changes to take effect.
Update Rust
To update rust when a new version is released, run:
$ rustup update info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: latest update on 2018-03-29, rust version 1.25.0 (84203cac6 2018-03-25) info: downloading component 'rustc' info: downloading component 'rust-std' info: downloading component 'cargo' info: downloading component 'rust-docs' info: removing component 'rustc' info: removing component 'rust-std' info: removing component 'cargo' info: removing component 'rust-docs' info: installing component 'rustc' info: installing component 'rust-std' info: installing component 'cargo' info: installing component 'rust-docs' info: checking for self-updates stable-x86_64-unknown-linux-gnu updated - rustc 1.25.0 (84203cac6 2018-03-25)
This command also checks for updates to rustup and automatically installs the latest version.
If you want to manually check for updates and install the latest version of rustup without updating installed toolchains, type:
$ rustup self update
Uninstall Rust
You can uninstall rust language at any time using command:
$ rustup self uninstall
This command will delete Rust from your system, and all the above changes will be reverted.
Thanks for hacking in Rust! This will uninstall all Rust toolchains and data, and remove $HOME/.cargo/bin from your PATH environment variable. Continue? (y/N) y info: removing rustup home info: removing cargo home info: removing rustup binaries info: rustup is uninstalled
Finally, remove your Rust project's parent directory.
$ rm -fr ~/my_rust_projects
Frequently Asked Questions (FAQ)
A: Rust is a modern, efficient, and safe systems programming language. It's designed for performance and reliability, offering features like zero-cost abstractions and guaranteed memory safety.
A: You can install Rust on Linux using rustup, which is the Rust toolchain installer. Run the command curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh in your terminal, and follow the on-screen instructions.
rustup?A: rustup is a command-line tool for managing Rust versions and associated tools. It simplifies installing, updating, and managing the Rust programming environment.
rustup?A: To update Rust, simply open your terminal and run rustup update.
A: Yes, once Rust is installed, you can write and run Rust programs. Use Cargo, Rust's package manager and build system, to create and manage your projects.
A: Use the command cargo new project_name to create a new Rust project. This creates a new directory with the necessary files to start coding.
A: Navigate to your project directory and run cargo run. Cargo will compile and execute your Rust program.
A: To uninstall Rust and rustup, run rustup self uninstall in your terminal.
A: Absolutely! Rust is used by numerous organizations for various applications, including network services, embedded systems, and even as part of operating systems.
A: The official Rust website (rust-lang.org) offers extensive documentation. The online book "The Rust Programming Language" is also a great resource for beginners.
And, that's all for now. You know now how to install Rust using rustup , how to update it, create and run a sample rust program and finally how to remove rust from your system. Hope this was useful.
Resources:





4 comments
You don’t need to create the project directory manually and run rustc directly. The recommended way is to use cargo:
cd ~/my_rust_projects
cargo new hello_world
cd hello_world
cargo run
Thanks for pointing it out. Updated the guide with your inputs.
Hi Ostechnix,
This unfortunately does not work for me. I’m running omv with a pve kernel bash shell 4.4.12(1)
$ uname -vm
#1 SMP PVE 4.15.18-52 (Thu, 05 Dec 2019 10:14:17 +0100) x86_64
$ which curl
/usr/bin/curl
$ which sh
/bin/sh
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
$ curl https://sh.rustup.rs -sSf | sh
-bash: $: command not found
I tried placing the quotes around the url n/c
tried quoting the whole string url to sh same result.
Havn’t tried to install rustc using apt. Just thought there might be some input you can provide me with.
tx
Hey, I haven’t tested it in OpenMendiaVault. So, don’t have any working solution for now. My apologies. Please try the following command and see if it works:
curl –proto ‘=https’ –tlsv1.2 -sSf https://sh.rustup.rs | sh
If it doesn’t work, please file an issue in GitHub. https://github.com/rust-lang/rust/issues