Linux/Terminal Commands Cheat Sheet 2026 — Essential Commands

Bookmark this page. Use Ctrl+F (or Cmd+F on Mac) to find what you need. This cheat sheet covers essential terminal commands for macOS and Linux. Last updated: March 2026 Navigation Command Description pwd Print current directory ls List files ls -la List all files with details (including hidden) ls -lh List with human-readable sizes cd /path Change directory cd ~ Go to home directory cd .. Go up one directory cd - Go to previous directory tree Show directory tree (install: brew install tree) tree -L 2 Tree with max depth 2 Files and Directories Command Description touch file.txt Create empty file mkdir mydir Create directory mkdir -p a/b/c Create nested directories cp file.txt copy.txt Copy file cp -r dir/ newdir/ Copy directory recursively mv file.txt newname.txt Rename/move file rm file.txt Delete file rm -r dir/ Delete directory recursively rm -rf dir/ Force delete (no confirmation) ln -s target link Create symbolic link cat file.txt Print file contents head -20 file.txt First 20 lines tail -20 file.txt Last 20 lines tail -f file.log Follow file in real-time (logs) less file.txt Paginated viewer (q to quit) wc -l file.txt Count lines wc -w file.txt Count words diff file1 file2 Compare two files stat file.txt File details (size, dates, permissions) Searching Command Description grep "text" file.txt Search for text in file grep -r "text" dir/ Search recursively in directory grep -i "text" file.txt Case-insensitive search grep -n "text" file.txt Show line numbers grep -c "text" file.txt Count matches grep -v "text" file.txt Show lines NOT matching find . -name "*.txt" Find files by name find . -type d -name "src" Find directories by name find . -size +10M Find files larger than 10MB find . -mtime -7 Files modified in last 7 days which python Find where a command lives locate file.txt Fast file search (uses index) Pipes and Redirection # Pipe — send output of one command to another ls -la | grep ".txt" cat file.txt | sort | uniq ps aux | grep node # Redirect output to file echo "hello" > file.txt # overwrite echo "world" >> file.txt # append # Redirect errors command 2> errors.log # stderr to file command > output.log 2>&1 # stdout + stderr to file command &> all.log # same (bash shorthand) # /dev/null — discard output command > /dev/null 2>&1 # silence everything cmd1 | cmd2 pipe: stdout of cmd1 → stdin of cmd2 cmd > file redirect stdout to file (overwrite) cmd >> file redirect stdout to file (append) cmd 2> file redirect stderr to file cmd < file use file as stdin Permissions -rwxr-xr-- 1 alex staff 4096 Mar 15 file.txt │├─┤├─┤├─┤ │ │ │ │ │ │ │ └── Others: read only │ │ └───── Group: read + execute │ └───────── Owner: read + write + execute └─────────── File type (- = file, d = directory, l = link) Command Description chmod 755 file rwxr-xr-x (owner all, group/others read+exec) chmod 644 file rw-r–r– (owner read+write, others read) chmod +x script.sh Add execute permission chmod -w file.txt Remove write permission chown user:group file Change owner and group chown -R user dir/ Change owner recursively Number Permission 7 rwx (read + write + execute) 6 rw- (read + write) 5 r-x (read + execute) 4 r– (read only) 0 — (no permission) Processes Command Description ps aux List all processes ps aux | grep node Find a specific process top Live process monitor htop Better process monitor (install separately) kill <pid> Send SIGTERM (graceful stop) kill -9 <pid> Send SIGKILL (force stop) killall node Kill all processes by name lsof -i :3000 Find what is using port 3000 jobs List background jobs bg Resume job in background fg Bring job to foreground command & Run command in background nohup command & Run and keep running after logout Disk and System Command Description df -h Disk usage (human-readable) du -sh dir/ Directory size du -sh * | sort -rh Largest items in current dir free -h Memory usage (Linux) uname -a System info hostname Machine name uptime System uptime and load date Current date/time cal Calendar Networking Command Description curl https://example.com Fetch a URL curl -o file.html https://example.com Download to file curl -X POST -d '{"key":"value"}' -H "Content-Type: application/json" url POST JSON wget https://example.com/file.zip Download a file ping example.com Test connectivity ifconfig / ip addr Show network interfaces netstat -tlnp / ss -tlnp Show listening ports ssh user@host Connect via SSH scp file.txt user@host:/path Copy file to remote scp user@host:/path/file.txt . Copy file from remote Archives Command Description tar -czf archive.tar.gz dir/ Create gzip archive tar -xzf archive.tar.gz Extract gzip archive tar -xzf archive.tar.gz -C /dest Extract to directory zip -r archive.zip dir/ Create zip archive unzip archive.zip Extract zip Text Processing # Sort lines sort file.txt sort -r file.txt # reverse sort -n file.txt # numeric sort sort -u file.txt # unique only # Unique lines (file must be sorted first) sort file.txt | uniq sort file.txt | uniq -c # count occurrences # Cut columns cut -d',' -f1,3 data.csv # columns 1 and 3 (comma delimiter) # Replace text sed 's/old/new/g' file.txt # replace all occurrences sed -i 's/old/new/g' file.txt # in-place edit (Linux) sed -i '' 's/old/new/g' file.txt # in-place edit (macOS — needs empty '') # Print specific lines awk '{print $1, $3}' file.txt # columns 1 and 3 (space delimiter) awk -F',' '{print $1}' data.csv # with custom delimiter # Count and summarize cat access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head -10 # → top 10 IP addresses in an access log Keyboard Shortcuts (Terminal) Shortcut Action Ctrl+C Cancel current command Ctrl+D Exit shell / close terminal Ctrl+Z Suspend current process Ctrl+L Clear screen Ctrl+R Search command history Ctrl+A Move cursor to start of line Ctrl+E Move cursor to end of line Ctrl+W Delete word before cursor Ctrl+U Delete entire line before cursor Tab Auto-complete file/command name !! Repeat last command !$ Last argument of previous command Environment Variables echo $HOME # print variable export MY_VAR="value" # set for current session echo 'export MY_VAR="value"' >> ~/.zshrc # permanent (Zsh) echo 'export MY_VAR="value"' >> ~/.bashrc # permanent (Bash) env # list all env variables printenv PATH # print specific variable Common Mistakes rm -rf / or rm -rf * — There is no recycle bin in the terminal. Deleted files are gone. Always double-check your path before running rm -rf. Use ls first to preview what will be deleted. ...

July 14, 2026 · 6 min

Rust Cheat Sheet 2026 — Syntax, Ownership, and Common Patterns

Bookmark this page. Use Ctrl+F (or Cmd+F on Mac) to find what you need. This cheat sheet covers Rust syntax, ownership, traits, error handling, and common patterns. Try examples at play.rust-lang.org. Last updated: March 2026 Variables and Types let name = "Alex"; // immutable (default) let mut count = 0; // mutable let age: i32 = 25; // explicit type const MAX: u32 = 100; // compile-time constant Type Description Example i8, i16, i32, i64, i128 Signed integers let x: i32 = -42; u8, u16, u32, u64, u128 Unsigned integers let x: u32 = 42; f32, f64 Floating point let x: f64 = 3.14; bool Boolean true, false char Unicode character 'A', '🚀' &str String slice (borrowed) "hello" String Owned string (heap) String::from("hello") () Unit type (void) fn do_thing() { } [T; N] Fixed array [1, 2, 3] Vec<T> Dynamic array vec![1, 2, 3] (T, U) Tuple (42, "hello") Option<T> Nullable value Some(42) or None Result<T, E> Success or error Ok(42) or Err("fail") Type Conversions let x: i32 = 42; let y: f64 = x as f64; // 42.0 let s: String = x.to_string(); // "42" let n: i32 = "42".parse().unwrap(); // 42 let n: i32 = "42".parse().unwrap_or(0); // 42 (or 0 on error) Strings // &str — string slice, borrowed, immutable let greeting: &str = "hello"; // String — owned, heap-allocated, growable let mut name = String::from("Alex"); name.push_str(" Smith"); // append name.push('!'); // append char // Conversions let s: String = "hello".to_string(); let s: &str = &name; // String → &str (auto-deref) // Common methods name.len() // byte length name.is_empty() // true if empty name.contains("Alex") // substring check name.starts_with("A") name.to_uppercase() name.to_lowercase() name.trim() // remove whitespace name.replace("Alex", "Sam") name.split(" ") // iterator of parts // Format let msg = format!("Hello {name}, age {age}"); Ownership and Borrowing // Ownership — each value has one owner let s1 = String::from("hello"); let s2 = s1; // s1 is MOVED to s2 // println!("{s1}"); // ERROR: s1 no longer valid // Clone — deep copy let s1 = String::from("hello"); let s2 = s1.clone(); // both valid // Borrowing — reference without taking ownership fn print_len(s: &String) { // immutable borrow println!("{}", s.len()); } fn add_excl(s: &mut String) { // mutable borrow s.push('!'); } // Rules: // 1. Many immutable references (&T) OR one mutable reference (&mut T) // 2. References must always be valid (no dangling) Structs struct User { name: String, age: u32, active: bool, } let user = User { name: String::from("Alex"), age: 25, active: true, }; // Access println!("{}", user.name); // Update syntax let user2 = User { age: 26, ..user }; // Tuple struct struct Point(f64, f64); let p = Point(1.0, 2.0); // Methods impl User { // Constructor (convention) fn new(name: &str, age: u32) -> Self { Self { name: name.to_string(), age, active: true } } // Method (takes &self) fn greet(&self) -> String { format!("Hi, I'm {}", self.name) } } Enums and Pattern Matching enum Direction { North, South, East, West } // Enums with data enum Shape { Circle(f64), // radius Rectangle(f64, f64), // width, height Triangle { base: f64, height: f64 }, } // Pattern matching with match match shape { Shape::Circle(r) => std::f64::consts::PI * r * r, Shape::Rectangle(w, h) => w * h, Shape::Triangle { base, height } => 0.5 * base * height, } // if let — match a single pattern if let Some(value) = optional { println!("Got: {value}"); } // let else — match or diverge let Some(value) = optional else { return; }; Option and Result // Option<T> — value or nothing let name: Option<&str> = Some("Alex"); let empty: Option<&str> = None; name.unwrap() // "Alex" (panics if None) name.unwrap_or("Unknown") // "Alex" (or default) name.is_some() // true name.is_none() // false name.map(|n| n.len()) // Some(4) // Result<T, E> — success or error fn divide(a: f64, b: f64) -> Result<f64, String> { if b == 0.0 { Err("division by zero".to_string()) } else { Ok(a / b) } } // ? operator — propagate errors fn read_file(path: &str) -> Result<String, std::io::Error> { let content = std::fs::read_to_string(path)?; // returns Err early Ok(content) } // Handle Result match divide(10.0, 3.0) { Ok(result) => println!("{result}"), Err(e) => println!("Error: {e}"), } Traits // Define a trait trait Greet { fn greet(&self) -> String; // Default implementation fn hello(&self) -> String { format!("Hello from {}", self.greet()) } } // Implement for a type impl Greet for User { fn greet(&self) -> String { self.name.clone() } } // Trait as parameter fn print_greeting(item: &impl Greet) { println!("{}", item.greet()); } // Trait bound syntax fn print_greeting<T: Greet>(item: &T) { println!("{}", item.greet()); } // Common derive traits #[derive(Debug, Clone, PartialEq, Eq, Hash)] struct Point { x: i32, y: i32 } Collections // Vec — dynamic array let mut v = vec![1, 2, 3]; v.push(4); v.pop(); // Some(4) v.len(); // 3 v[0]; // 1 (panics if out of bounds) v.get(0); // Some(&1) (safe) v.contains(&2); // true v.iter().filter(|&&x| x > 1).collect::<Vec<_>>(); // HashMap use std::collections::HashMap; let mut map = HashMap::new(); map.insert("name", "Alex"); map.get("name"); // Some(&"Alex") map.contains_key("name"); // true map.entry("age").or_insert("25"); for (key, value) in &map { } // HashSet use std::collections::HashSet; let mut set = HashSet::new(); set.insert(1); set.contains(&1); // true Iterators let nums = vec![1, 2, 3, 4, 5]; nums.iter().map(|x| x * 2).collect::<Vec<_>>(); // [2, 4, 6, 8, 10] nums.iter().filter(|&&x| x > 2).collect::<Vec<_>>(); // [3, 4, 5] nums.iter().sum::<i32>(); // 15 nums.iter().any(|&x| x > 3); // true nums.iter().all(|&x| x > 0); // true nums.iter().find(|&&x| x > 3); // Some(&4) nums.iter().position(|&x| x == 3); // Some(2) nums.iter().enumerate(); // (index, &value) nums.iter().zip(other.iter()); // pair elements nums.iter().take(3).collect::<Vec<_>>(); // [1, 2, 3] nums.iter().skip(2).collect::<Vec<_>>(); // [3, 4, 5] nums.iter().flat_map(|x| vec![x, x * 10]); nums.iter().fold(0, |acc, &x| acc + x); // 15 Control Flow // if / else (is an expression) let status = if age >= 18 { "adult" } else { "minor" }; // loop (infinite, break with value) let result = loop { if condition { break 42; } }; // while while count > 0 { count -= 1; } // for for i in 0..5 { } // 0, 1, 2, 3, 4 for i in 0..=5 { } // 0, 1, 2, 3, 4, 5 for item in &vec { } // iterate by reference for item in vec { } // iterate by value (moves) Closures let add = |a: i32, b: i32| -> i32 { a + b }; let double = |x| x * 2; // types inferred let greet = || println!("Hello"); // Closures capture variables let name = String::from("Alex"); let greet = || println!("Hello {name}"); // borrows name let greet = move || println!("Hello {name}"); // takes ownership Cargo Commands Command Description cargo new my_app Create a new project cargo run Build and run cargo build Build (debug) cargo build --release Build (optimized) cargo test Run tests cargo check Fast compile check (no binary) cargo clippy Lint your code cargo fmt Auto-format code cargo add serde Add a dependency cargo doc --open Generate and open docs Lifetimes // Lifetimes tell the compiler how long references are valid fn longest<'a>(a: &'a str, b: &'a str) -> &'a str { if a.len() > b.len() { a } else { b } } // Struct with a reference needs a lifetime struct Excerpt<'a> { text: &'a str, } Rule: if a function returns a reference, it must come from one of the inputs (annotated with the same lifetime). ...

July 13, 2026 · 7 min

Kubernetes Tutorial #4: ConfigMaps and Secrets — Manage Configuration

Your application needs a database host, a port number, an API key, and a password. How do you pass these to your containers in Kubernetes? You should not hardcode them in the Docker image. You should not put passwords in your Deployment YAML either. Kubernetes has two objects for this: ConfigMap — for non-sensitive configuration Secret — for sensitive data like passwords and API keys Why Not Hardcode Config? Imagine you hardcode a database hostname in your Docker image: ...

July 13, 2026 · 6 min

Best AI Coding Tools Compared 2026 — Complete Guide

The AI coding tool market in 2026 is crowded. Five major tools, dozens of smaller ones, and new features shipping every week. Picking the right tool (or combination of tools) matters more than ever. I have used all five major tools for real projects. This guide compares them honestly — features, pricing, strengths, weaknesses, and who should use what. The Five Major Tools Tool Type Price One-Line Summary Cursor IDE (VS Code fork) $20/month Best AI code editor for multi-file editing GitHub Copilot IDE extension $10/month Most popular, works everywhere Claude Code CLI agent $20/month+ Most powerful for complex tasks Windsurf IDE (VS Code fork) $15/month Cheapest premium editor with unique AI features Gemini Code Assist IDE extension Free / $75/user Enterprise Most generous free tier Let me break down each one. ...

July 13, 2026 · 9 min

Kubernetes Tutorial #3: Pods, Deployments, and Services

When you deploy an application to Kubernetes, you work with three objects almost every time: Pods, Deployments, and Services. A Pod is the unit that runs your containers A Deployment manages a set of Pods and handles updates A Service gives your Pods a stable network address Understanding these three is the foundation for everything else in Kubernetes. Prerequisites: A running Kubernetes cluster. See Kubernetes Tutorial #2: Installing Kubernetes Locally. Pods — The Smallest Unit A Pod is the smallest deployable unit in Kubernetes. It wraps one or more containers that share the same network and storage. ...

July 12, 2026 · 7 min

Claude Code Review 2026 — The CLI That Changed How I Code

Claude Code is not an editor. It is not an extension. It is a terminal agent that reads your code, writes code, runs commands, and handles git — all from your terminal. When I first tried it, I thought “why would I use a terminal tool when I have Cursor?” After one week, I understood. Claude Code does things that no IDE-based tool can match. Here is my honest review after months of daily use. ...

July 12, 2026 · 9 min

GitHub Copilot Review 2026 — Complete Guide

GitHub Copilot is the most popular AI coding tool in the world. Over 15 million developers use it. It works in VS Code, JetBrains, Neovim, Xcode, and even the GitHub website. But in 2026, Copilot has serious competition. Cursor, Claude Code, and Windsurf are all fighting for the same developers. Is Copilot still worth it? I have used Copilot since its early days. Here is my honest review of where it stands today. ...

July 12, 2026 · 8 min

Windsurf IDE Review 2026 — The AI-First Editor

Windsurf is the underdog of AI code editors. It does not have Cursor’s hype or Copilot’s install base. But it has something neither of them has — Cascade. Cascade is an AI agent that understands your entire codebase, plans multi-step edits, and executes them while explaining every decision. It is Windsurf’s killer feature. I used Windsurf for real projects over several weeks. Here is my honest review. What Is Windsurf? Windsurf is an AI-first code editor built on VS Code. It was originally called Codeium, and it started as a free AI autocomplete extension. In 2024, it became a full IDE. In late 2025, Cognition AI (the company behind Devin) acquired Windsurf for around $250 million. ...

July 11, 2026 · 8 min

Kubernetes Tutorial #2: Installing Kubernetes Locally (minikube + kind)

You cannot learn Kubernetes from docs alone. You need a real cluster to practice on. The good news: you can run a full Kubernetes cluster on your laptop for free. In this tutorial, you will install Kubernetes locally, run your first pod, and learn the essential kubectl commands. Prerequisites: Docker must be installed. If not, see Docker Tutorial #2: How to Install Docker. Options for Running Kubernetes Locally There are four main ways to run Kubernetes on your laptop: ...

July 11, 2026 · 6 min

Cursor IDE Review 2026 — Is It Worth Switching From VS Code?

Cursor looks like VS Code. It feels like VS Code. But it is not VS Code. It is a full IDE replacement with AI built into every corner. Autocomplete, chat, multi-file editing, background agents, and deep codebase understanding. All in one app. I have used Cursor every day for months. Here is my honest review — what works, what does not, and whether you should switch. What Is Cursor? Cursor is an AI-powered code editor built on top of VS Code. It uses the same extension system, the same keybindings, and the same settings. If you know VS Code, you already know how to use Cursor. ...

July 11, 2026 · 8 min