Install Rust and run your first program
Learn Rust · Beginner · 8 min
How do you get from nothing to a running Rust program?
1Guess
fn main() { println!("Hello"); println!("{} + {} = {}", 2, 3, 2 + 3); }2Read
Install Rust
Install Rust with rustup, the installer and version manager the Book recommends. On Linux and macOS you run one command from rustup.rs; on Windows you download the installer. Then open a new terminal and type
rustc --version. If it prints a version number, Rust is installed.rustup updatelater moves you to a newer release.3Read
Make a project with Cargo
Cargo is Rust's build system and package manager, and it comes with the installer.
cargo new hellomakes a folder with aCargo.tomlfile, which names the package and lists its dependencies, andsrc/main.rs, which holds a "Hello, world!" program.cargo runbuilds and runs it.cargo buildonly builds.cargo checkonly checks that the code compiles, and is usually faster.4Code
A first program with println!
1 / 2fn main() { let name = "Ferris"; let age = 4; println!("Hello, {name}!"); println!("{} is {} years old", name, age); println!("Next year: {}", age + 1); }Read the program. What will it print?
5Read
What the ! and the ; mean
fn main()is the function Rust runs first. The!inprintln!means you call a macro, not a normal function; writeprintlnwithout it and you call something else. A statement ends with;, as theprintln!lines do. The Book formats code with four spaces, not a tab.6Fix
fn main() { println("Hello, Rust"); }7Say it back
8Mission · 8 min
Install Rust, check the version, make a project called hello and run the program Cargo generated. Then change the text in src/main.rs and run it again.
rustc --version cargo new hello cd hello cargo run
Common questions
- How do I install Rust?
- Use rustup, the installer the Rust Book recommends. On Linux and macOS you run the command shown on rustup.rs in a terminal; on Windows you download and run the installer. When it finishes, open a new terminal and type rustc --version. A printed version number means Rust works. Later, rustup update installs the newest release.
- What is Cargo in Rust?
- Cargo is the build system and package manager that comes with Rust. It creates projects with cargo new, builds them, runs them and downloads the libraries your code depends on. Almost every Rust project uses it, so the commands you learn here, such as cargo run, work the same on Linux, macOS and Windows.
- What is the difference between cargo run, cargo build and cargo check?
- The cargo build command compiles your project and leaves an executable in the target/debug folder. The cargo run command builds the project if needed and then starts it. The cargo check command only checks that the code compiles and makes no executable, so it is usually faster while you are still writing the code.
Sources
- https://doc.rust-lang.org/book/ch01-01-installation.html (read 2026-12-03)
- https://doc.rust-lang.org/book/ch01-02-hello-world.html (read 2026-12-03)
- https://doc.rust-lang.org/book/ch01-03-hello-cargo.html (read 2026-12-03)
Measured with rustc 1.100.1 (play.rust-lang.org, stable, edition 2024) on 2026-12-03
Published Dec 3, 2026 · Updated Dec 3, 2026