Installing Rust on Ubuntu | Generated by AI
Installing Rust on Ubuntu 22.04 LTS
Rust is best installed using rustup, the official toolchain installer. This method is straightforward, supports easy updates, and works on your 64-bit Ubuntu 22.04 system. No additional dependencies are typically needed beyond a basic Ubuntu setup.
Step-by-Step Instructions
- Update your package list (optional but recommended):
sudo apt update - Install Rust using rustup:
Run the following command to download and execute the installer script:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh- This will download the script securely via HTTPS.
- When prompted, choose the default installation option (press
1and Enter). - The installer will add Rust binaries to
~/.cargo/binand update your shell profile (e.g.,~/.bashrcor~/.profile).
- Reload your shell configuration:
To make the changes take effect immediately without restarting your terminal:
source ~/.cargo/envAlternatively, close and reopen your terminal.
- Verify the installation:
Check that Rust is installed correctly:
rustc --version cargo --versionYou should see output like
rustc 1.82.0(or the latest stable version) and similar for Cargo.
Additional Notes
- Uninstalling: If needed, run
rustup self uninstall. - Updating Rust: Use
rustup updateto get the latest version. - IDE/Support: For development, consider installing
rust-analyzervia your editor (e.g., VS Code extension) for better code completion. - This installs the stable channel by default. For nightly or beta, use
rustup install nightlyafter setup.
If you encounter any errors (e.g., curl not found), install it with sudo apt install curl.
Official Rust Installation Guide