Linux Command Explainer
Paste any shell command and get a plain-English breakdown of every argument, flag, pipe and redirection — with warnings before you run something destructive.
Read a one-liner you found on the internet? Pasted from a forum, a README or a colleague’s terminal? Type it in below and the explainer splits the line into its individual commands, then walks through each one: what the command does, what every flag means (built-in notes for 70+ common tools), how the pipes and redirections move data around — and a red flag when the command can delete files, wipe disks or break your system. Nothing is executed and nothing leaves your browser.
1 · Paste a command (or a whole pipeline)
2 · The pipeline at a glance
Each chip is one command in the line, joined by the operator that connects them. Chips are coloured when they carry warnings.
3 · Safety check
4 · Command-by-command breakdown
How the shell reads a command line
Before anything runs, the shell (bash, sh, zsh…) parses the whole line. Understanding the order it works in explains almost every “why did that do that?” moment.
1. Quotes and escapes come first
'single quotes'freeze everything inside: no variables, no command substitution, no escapes.echo '$HOME'prints the literal text$HOME."double quotes"still expand variables and$(...), but protect spaces and glob characters like*from being expanded by the shell.- A backslash
\escapes the single character after it:echo \*prints a literal asterisk.
2. The line is split into words and operators
Unquoted whitespace separates words. These characters are operators, never part of a word:
| Operator | Meaning |
|---|---|
| | | Pipe: feed the standard output of the left command into the standard input of the right one. |
| |& | Pipe both stdout and stderr (bash). |
| && | Run the right side only if the left exited 0 (success). |
| || | Run the right side only if the left failed (non-zero exit code). |
| ; | Run the next command regardless of the previous result. |
| & | Run the command in the background. |
| > >> < <> &> | Redirections (below). |
3. Redirections move data between streams and files
| Syntax | What happens |
|---|---|
| cmd > file | Stdout goes to file — the file is truncated first if it exists. |
| cmd >> file | Stdout is appended; existing content is kept. |
| cmd < file | Stdin comes from file. |
| cmd 2>&1 | Duplicate stderr onto stdout — the classic way to capture both in one pipe or file. |
| cmd 2> err.log | Stderr goes to err.log; stdout is untouched (still on the screen). |
| cmd &> out.log | Bash shortcut: both stdout and stderr into out.log. |
| >> /dev/null 2>&1 | The idiom for “silence it completely”. |
4. Variables and substitutions
$VAR/${VAR}expand the variable’s value;${VAR:-default}supplies a fallback.$(command)runs a command and substitutes its output — nestable, the modern choice. Backticks `` `command` `` do the same but are harder to read and nest (legacy).$?is the exit code of the last command (0 = success);$$the shell’s PID;$1…$9positional parameters in scripts.
5. Common pitfalls
- Unquoted variables with spaces:
rm $dir/*where$dir="/my docs"becomes two paths — quote it:rm "$dir"/*. >truncates: runningcat notes.txt > notes.txtempties the file before it is read. Use>>to append.- Pipes hide failures: in
cmd1 | cmd2, the pipeline’s exit code iscmd2’s — a failure incmd1can go unnoticed (bash:set -o pipefail). sudoapplies to the whole pipeline:sudo ls | grep xruns onlylsas root;grepruns as you. For the whole line:sudo sh -c 'ls | grep x'.- Wildcards are expanded by the shell, not the command:
rm *.log— if no .log files exist, bash passes the literal*.log(andrmcomplains), but some shells pass nothing at all.
Suggested
Luke Keam | techgeek.biz