How To Install Rust in Linux


Running the following in your terminal

If you’re running macOS, Linux, or another Unix-like OS. To download Rustup and install Rust, run the following in your terminal, then follow the on-screen instructions.

curl --proto '=https' --tlsv1.2 -sSf | sh
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, run:
source $HOME/.cargo/env

To configure your current shell, run:

source ~/.profile
source ~/.cargo/env
rustc --version
cargo --version
rustc 1.60.0 (7737e0b5c 2022-04-04)
cargo 1.60.0 (d1fd9fe 2022-03-01)

When you install Rustup you’ll also get the latest stable version of the Rust build tool and package manager, also known as Cargo.

On Windows, download and run rustup-init.exe.

Standalone installers

The official Rust standalone installers contain a single release of Rust, and are suitable for offline installation. See:

Try Rust Online

You can try Rust online in the Rust Playground without installing anything on your computer. See: TRY RUST WITHOUT INSTALLING

Rustc Help Commands and Options

Usage: rustc [OPTIONS] INPUT

-h, --help
Display this message
--cfg SPEC
Configure the compilation environment
Add a directory to the library search path. The optional KIND can be one of dependency, crate, native, framework, or all (the default).
Link the generated crate(s) to the specified native library NAME. The optional KIND can be one of static, framework, or dylib (the default). Optional comma separated MODIFIERS (bundle|verbatim|whole-archive|as-needed) may be specified each with a prefix of either '+' to enable or '-' to disable.
--crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]
Comma separated list of types of crates for the compiler to emit
--crate-name NAME
Specify the name of the crate being built
--edition 2015|2018|2021
Specify which edition of the compiler to use when compiling code.
--emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]
Comma separated list of types of output for the compiler to emit
--print [crate-name|file-names|sysroot|target-libdir|cfg|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|native-static-libs|stack-protector-strategies|link-args]
Compiler information to print on stdout
Equivalent to -C debuginfo=2
Equivalent to -C opt-level=2
Write output to filename
--out-dir DIR
Write output to compiler-chosen filename in dir
--explain OPT
Provide a detailed explanation of an error message
Build a test harness
--target TARGET Target triple for which the code is compiled
-A, --allow LINT
Set lint allowed
-W, --warn LINT
Set lint warnings
--force-warn LINT
Set lint force-warn
-D, --deny LINT
Set lint denied
-F, --forbid LINT
Set lint forbidden
--cap-lints LEVEL
Set the most restrictive lint level. More restrictive
lints are capped at this level
-C, --codegen OPT[=VALUE]
Set a codegen option
-V, --version
Print version info and exit
-v, --verbose
Use verbose output

Cargo Help Commands and Options

Rust's package manager

    cargo [+toolchain] [OPTIONS] [SUBCOMMAND]

-V, --version
Print version info and exit
List installed commands
--explain <CODE>
Run `rustc --explain CODE`
-v, --verbose
Use verbose output (-vv very verbose/ output)
-q, --quiet
Do not print cargo log messages
--color <WHEN>
Coloring: auto, always, never
Require Cargo.lock and cache are up to date
Require Cargo.lock is up to date
Run without accessing the network
--config <KEY=VALUE>
Override a configuration value (unstable)
Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help
Print help information
Commands: Some common cargo commands are (see all commands with --list):
build, b
Compile the current package
check, c
Analyze the current package and report errors, but don't build object files
Remove the target directory
doc, d
Build this package's and its dependencies' documentation
Create a new cargo package
Create a new cargo package in an existing directory
run, r
Run a binary or example of the local package
test, t
Run the tests
Run the benchmarks
Update dependencies listed in Cargo.lock
Search registry for crates
Package and upload this package to the registry
Install a Rust binary. Default location is $HOME/.cargo/bin
Uninstall a Rust binary
See 'cargo help <command>' for more information on a specific command.

Related Tags