Bash Cheat Sheet
Searchable reference of essential bash commands with syntax, examples, and output.
About This Tool
The Bash Cheat Sheet is a comprehensive, searchable reference of essential bash and shell commands for developers, system administrators, and DevOps engineers. Whether you are writing shell scripts, managing servers, or automating deployments, this tool provides instant access to command syntax, real-world examples, and expected output for the most commonly used bash commands.
Commands are organized into eight categories: File Operations (ls, cp, mv, rm, find, chmod, mkdir, tar), Text Processing (grep, sed, awk, sort, head/tail, wc, cut), System Info (df, du, uname, uptime, free), Network (curl, wget, ssh, scp, ping), Process Management (ps, kill, top/htop, bg/fg/jobs), Variables (assignment, special variables, arrays), Control Flow (if/elif/else, for loops, while/until, case, functions), and String Manipulation (length, substring, replace, regex matching).
Each command entry includes the full syntax with common flags, a practical example you can copy and run, and sample output showing what to expect. The Quick Tips section covers essential bash patterns including pipes, redirects, logical operators, command substitution, process substitution, brace expansion, and exit codes.
All processing happens entirely in your browser. No data is sent to any server, and no commands are executed remotely. You can safely use this reference even on air-gapped systems by bookmarking the page.
If you are working with shell scripts, you may also find the Shell Script Linter useful for catching common mistakes. For regex patterns used in grep and sed, check the Regex Tester. And if you need to build cron expressions for scheduled tasks, try the Cron Expression Builder.
How to Use
- Use the search bar at the top to find commands by name, keyword, or description (e.g., type "file" to find file-related commands).
- Click a category badge (File Operations, Text Processing, etc.) to filter commands by topic.
- Click any command row to expand it and see the full syntax, example, and expected output.
- Click the Copy button next to Syntax or Example to copy the code to your clipboard.
- Toggle the Quick Tips panel to see common bash patterns like pipes, redirects, and brace expansion.
- Use keyboard shortcut Ctrl+Shift+C to copy the currently visible code.
- Click "All" in the category filter to reset and show all commands again.
Popular Bash Command Examples
FAQ
Is my data safe when using this tool?
Yes. This is a purely static reference tool that runs entirely in your browser. No commands are executed, no data is sent to any server, and there is no backend processing. It is safe to use on any network.
Does this tool actually run bash commands?
No. This is a read-only reference. It displays command syntax, examples, and sample output but does not execute anything. To run commands, you need a terminal or shell environment.
Which version of bash is this reference based on?
The commands and syntax cover bash 4.x and 5.x, which are the versions found on most modern Linux distributions and macOS (with Homebrew). Some features like associative arrays and case conversion require bash 4.0 or later.
Do these commands work on macOS?
Most commands work on macOS, but there are differences. macOS ships with BSD versions of utilities like sed, grep, and find, which have slightly different flags than the GNU versions on Linux. For example, sed -i on macOS requires a backup extension argument. Installing GNU coreutils via Homebrew gives you the Linux-compatible versions.
Can I use this as a learning resource for bash scripting?
Absolutely. The cheat sheet covers fundamental concepts from basic file operations to advanced string manipulation and control flow. Each entry includes practical examples with expected output, making it suitable for beginners learning bash and experienced developers who need a quick refresher.
What is the difference between bash and sh?
sh (Bourne shell) is the original Unix shell, while bash (Bourne Again Shell) is an enhanced version with additional features like arrays, string manipulation, and extended test expressions [[ ]]. Most modern systems use bash as the default shell, and bash is backward-compatible with sh scripts.
How do I make a bash script executable?
Add a shebang line (#!/bin/bash or #!/usr/bin/env bash) as the first line of your script, then make it executable with chmod +x script.sh. You can then run it with ./script.sh. The shebang tells the system which interpreter to use.
Related Tools
Vim Cheat Sheet
Interactive Vim cheat sheet with search, mode and category filters. Browse 100+ Vim commands for Normal, Insert, Visual, and Command-line modes.
Git Command Reference
Comprehensive git command reference organized by workflow. Search, reverse lookup, visual workflow diagram, and copy any command.
Linux Permission Reference
Complete Linux file permission reference with interactive octal/symbolic converter, umask calculator, ACL guide, and common permission scenarios.
Docker CLI Reference
Comprehensive Docker CLI command reference with search, categories, flags, examples, Dockerfile instructions, and reverse lookup.
Regex Cheat Sheet
Interactive regex cheat sheet with searchable syntax reference, category filters, live pattern testing, and common regex patterns for JavaScript.
Shell Script Linter
Lint and check bash/shell scripts for common issues, deprecated syntax, and best practices. Catch bugs before they reach production.