Linux command lines are small programs written for a shell. The shell reads your text, expands and connects it, opens any requested files, and then starts a command. The command—whether a shell builtin, function, script, or external utility—interprets its own options and arguments. In Bash, a useful teaching sketch is command [options] [arguments] [redirections], but each utility defines its own actual syntax.
The shell and the command are different layers
When you type a line, Bash does not simply pass every character to a program. It parses the line, performs shell expansions, sets up pipes and redirections, and chooses what to execute. The resulting command words and file descriptors are then supplied to a builtin, function, script, or external program. That program applies its own rules to the values it receives.
As an Amazon Associate I earn from qualifying purchases.
Bash is only one shell. A Linux installation might use another shell, and the same utility can differ by implementation or version. The GNU Bash Reference Manual documents Bash 5.3 (edition 5.3, updated 18 May 2025), while the GNU Coreutils manual documents the GNU file and text utilities (version 9.11). Treat examples labeled Bash as Bash examples, and check the software installed on your system.
A practical mental model
For teaching, visualize a line in this order:
command [options] [arguments] [redirections]
This is not a universal grammar. Brackets mean “optional” in the sketch, not characters to type. Redirections may appear in several positions, and shell syntax also includes assignments, conditionals, command substitutions, quoting, and expansions. The model is useful because it separates the program name, the values it receives, and the shell wiring around it.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Commands, arguments, and options
Command
The first word commonly identifies what should run. In ls -l /home, ls is the command name. Bash may resolve that name to a builtin, function, alias, script, or executable found through the shell’s command-search rules. Two commands with the same visible name can therefore behave differently on different systems.
Arguments are values
Arguments are the values supplied to the command. In the example, /home identifies the directory that ls should inspect. A utility can treat an argument as a filename, directory, pattern, number, URL, or some other value; only that utility’s documentation decides which interpretation is valid.
Arguments are not guaranteed to be passed literally as you typed them. Bash performs parsing, quoting, and expansions before execution. A space can separate two words unless you quote it, and wildcard expansion can turn one typed pattern into several filename arguments. Learning quoting and expansion is the natural next step after the basics; do not assume punctuation always reaches the utility unchanged.
Recommended Free Tools
Options adjust behavior
Options conventionally select or modify a utility’s behavior. In ls -l /home, -l requests a long listing. Many programs also accept long forms such as --help, and some options take a value, either as a separate argument or attached to the option. These are conventions, not promises: a utility may use different letters, spellings, separators, or option rules.
Look up the specific command rather than guessing. Try its documented help option when available, for example:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
utility --help
man utility
The help output and manual page describe accepted options, required values, positional arguments, defaults, and exit-status behavior. Coreutils programs share many conventions, but the available command set and exact version depend on the distribution and installation.
How the pieces are interpreted
| Piece | Typical purpose | Who gives it meaning? | Example |
|---|---|---|---|
| Command name | Selects a builtin, function, script, or program | Shell command lookup, then the selected command | ls |
| Option | Changes a command’s mode or requests a feature | The particular utility | -l, --help |
| Argument | Supplies data or identifies an object to process | The particular utility | /home |
| Shell syntax | Connects commands, expands text, or redirects descriptors | The shell (Bash in the examples) | |, >, 2>&1 |
Thus, the shell handles the pipe symbol and redirection operators before the utility sees its arguments. The utility normally never receives a literal | or > as an argument unless you quote or otherwise escape it.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Pipes connect standard output to standard input
The basic pipeline
In Bash, | connects one command’s standard output to the next command’s standard input:
ls -l /etc | less
The shell starts both commands, creates a data channel, and connects the file descriptor used for output by ls to the input descriptor read by less. The second command consumes the first command’s output as it is produced, so you do not need an intermediate file.
A pipeline can contain several stages:
command-one | command-two | command-three
Each vertical bar connects the standard output of the command on its left to the standard input of the command on its right. The receiving command must actually read that input; piping data to a program that ignores standard input does not make it process the data.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Errors do not automatically travel through a pipe
Programs commonly write normal results to standard output and diagnostics to standard error. A plain pipe connects only standard output. In Bash, |& is a shorthand that sends standard output and standard error onward, effectively 2>&1 |:
build-command |& less
Use this deliberately. Combining diagnostics with data can make a downstream parser treat an error message as if it were a valid record.
Pipeline processes and shell state
Bash generally runs the commands in a multi-command pipeline in separate subshell environments. A variable changed inside one stage may therefore not have the value you expect in the parent shell after the pipeline finishes. Bash documents a conditional lastpipe behavior in which the final command can run in the current shell when the option is enabled and job control is not active. Do not rely on that exception without checking the shell configuration; design scripts so their state does not depend on an unexamined pipeline detail.
Standard input, output, and error
Unix-like programs normally begin with three standard file descriptors:
- 0 (standard input): data the program reads, often from your keyboard or a file.
- 1 (standard output): normal results, often displayed in the terminal or sent into a pipe.
- 2 (standard error): diagnostics and error messages, normally displayed in the terminal independently of standard output.
A terminal is only one possible destination. Redirection changes where a descriptor reads or writes. The shell opens files and duplicates descriptors before it starts the command, so the program can use the resulting streams as if they were ordinary input and output.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Redirection operators and safe examples
Read input from a file
command < input.txt
The shell opens input.txt for reading and makes it descriptor 0. The command then reads from the file instead of waiting for terminal input.
Write or replace standard output
command > output.txt
> creates output.txt if necessary or truncates an existing file before the command writes standard output. Truncation happens as part of setting up the redirection, so a typo can erase previous contents even if the command later fails. Check the filename and, for scripts where accidental overwrites are unacceptable, consider Bash’s noclobber setting or writing to a new file and renaming it after success.
Append standard output
command >> output.txt
>> creates the file when needed and appends new standard output to its existing contents. It does not append standard error unless you redirect descriptor 2 as well.
Save errors separately
command 2> errors.txt
The 2> prefix selects descriptor 2, so diagnostics go to errors.txt while normal output keeps its current destination. The file is created or truncated under the same rules as ordinary >.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsCombine output and errors in one file
command > all.txt 2>&1
Bash processes redirections from left to right. First, descriptor 1 is directed to all.txt. Then 2>&1 duplicates descriptor 1’s current destination for descriptor 2, so both streams reach that file.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Why redirection order matters
command 2>&1 > output.txt
Here Bash first makes descriptor 2 point wherever descriptor 1 points at that moment—normally the terminal. It then redirects descriptor 1 to output.txt. Standard output goes to the file, but standard error remains on the terminal. The two commands look similar, yet they produce different routing because descriptor duplication captured the earlier destination.
| Command line | Standard output | Standard error |
|---|---|---|
command > all.txt 2>&1 |
all.txt |
all.txt |
command 2>&1 > output.txt |
output.txt |
Original output destination, usually the terminal |
Putting the pieces together
Consider this Bash line:
grep --line-number 'error' app.log | less > review.txt 2> review-errors.txt
grepis the first command.--line-numberis an option understood by this implementation ofgrep.'error'andapp.logare arguments; the quotes also prevent the shell from treating the pattern’s characters as shell syntax.|sends the first command’s standard output toless‘s standard input.> review.txtredirects the pipeline’s final standard output to a file, replacing that file if it already exists.2> review-errors.txtredirects diagnostics produced by the command whose redirection it is attached to; it does not automatically collect every diagnostic from earlier pipeline stages.
For a pipeline in which you need errors from an earlier stage, redirect that stage explicitly or use Bash’s |& at the appropriate connection. Always decide whether downstream commands should receive clean data or mixed data and diagnostics.
A reliable method for reading an unfamiliar command
- Identify the shell syntax. Mark pipes, redirections, command substitutions, quoting, and expansions. These are interpreted before the utility runs.
- Split pipeline stages. For every
|, write down which standard output feeds which standard input. Check whether errors remain separate. - Name the command. Determine whether it is a builtin, function, alias, script, or external executable. In Bash, commands such as
type namecan help reveal what will run. - Classify each remaining word. Separate options from positional arguments, while remembering that the utility—not the shell—defines the distinction.
- Read the command’s documentation. Use its
--helpoutput or manual page to verify option spelling, required values, input format, and exit behavior. - Trace descriptors left to right. For each redirection, record the destination of descriptors 0, 1, and 2 at that point in the line.
- Check destructive effects. Confirm filenames before using
>, and test a complicated pipeline with harmless input before applying it to valuable data.
Common beginner mistakes and fixes
Assuming every dash word is an option
A utility may accept an argument beginning with a dash, may stop option parsing at a special marker, or may use a nonstandard convention. Do not infer behavior from appearance; consult that utility’s documentation and use its documented end-of-options syntax when needed.
Expecting a pipe to save output
A pipe transfers data between running commands; it does not create a permanent copy. Add an explicit redirection such as > result.txt when you need a file, and remember that the final stage’s output is the stream being redirected.
Mixing errors into machine-readable data
Keep descriptor 2 separate when another command will parse descriptor 1. Use a separate error file or leave diagnostics on the terminal. Combine streams only when a human-readable combined log is the goal.
Overwriting a file unintentionally
Use >> for intentional appends, verify paths, and inspect a command before pressing Enter. In interactive Bash, enabling set -o noclobber can make ordinary > refuse to overwrite an existing regular file; understand the setting and any explicit override before relying on it in scripts.
Assuming a command exists everywhere
GNU Coreutils is a documented suite of common file and text programs, but distributions can omit programs, provide another implementation, or ship a different version. Check availability and version on the machine where the command will run. A Bash example is not automatically portable to every shell.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →What to learn next
Once command roles, streams, pipes, and redirections make sense, study Bash quoting and expansion in detail, exit statuses and conditional operators, shell variables, functions, and safer scripting practices. The Bash manual explains parsing, expansion, execution, pipelines, and redirection in one reference. The Coreutils manual is the appropriate companion for the behavior and options of GNU utilities. A beginner Linux command-line book that covers streams, pipes, and redirection can also provide guided exercises; verify its edition and availability before buying, because titles and listings change.
Quick Recap
Key distinctions to keep in mind
- The shell interprets syntax such as
|,>, and2>&1; the utility interprets its own options and arguments. - An argument is a value, while an option is a conventional behavior switch whose exact spelling and meaning belong to one utility.
- A plain pipe carries standard output only. Standard error requires a separate redirection or Bash’s
|&. - Descriptors 0, 1, and 2 represent standard input, output, and error.
- In Bash, redirections are processed from left to right, and
>truncates before writing. - Verify behavior against the shell and utility versions installed on the system you are using.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




