All     Ethical Hacking     Networking     Programming     OSINT

Rust in Termux – Installation & Basic Commands

Rust is a powerful and memory-safe programming language used for systems programming, tools, and high-performance applications. Termux lets you install Rust easily so you can write, compile, and run Rust programs directly on your Android device. Below are the installation steps and the basic commands you need.

Installation

Update Termux packages:

pkg update && pkg upgrade -y

Install Rust using rustup:

pkg install rust -y

Check Rust version:

rustc --version

Check Cargo version:

cargo --version

Create a new Rust file:

nano hello.rs

Add this code:

fn main() {
    println!("Hello Termux!");
}

Compile the program:

rustc hello.rs

Run it:

./hello

Basic Commands

Run a Rust file directly (without compiling):

cargo run

Create a new Cargo project:

cargo new projectname

Build a Cargo project:

cargo build

Build for release:

cargo build --release

Update Rust and Cargo:

rustup update

Uninstall Rust:

pkg uninstall rust