Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Linux command-line input is a small language interpreted first by a shell, such as Bash. A useful teaching sketch is command [options] [arguments] [redirections]: the shell parses the line, expands and connects its parts, and then the command itself decides what its options and arguments mean.

This distinction explains most beginner surprises. In ls -l /home, ls is the command name, -l is conventionally an option, and /home is an argument. In ls -l /etc | less, Bash creates a pipeline. In command > output.txt 2>&1, Bash changes where normal output and error output go. The syntax is related, but each part has a different job.

The shell and the command are different layers

When you press Enter, the shell reads the command line and interprets its syntax. Bash is one widely used shell, not a synonym for “the Linux command line.” A Linux installation may use another shell, and shell features can vary. The GNU Bash Reference Manual documents Bash 5.3 (edition 5.3, updated 18 May 2025), while your installed version may differ.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bash performs work such as recognizing operators, expanding variables and patterns, setting up redirections, and starting the requested command. The command that receives the resulting values then applies its own rules. That command might be:

  • a shell builtin, implemented inside Bash;
  • a function defined in the current shell;
  • a script; or
  • an external executable, such as a program from the GNU Coreutils collection.

The GNU Coreutils manual documents version 9.11 and its standard file and text utilities. Coreutils is common, but the programs and versions installed on your machine depend on its distribution and configuration.

The bracketed sketch command [options] [arguments] [redirections] helps you identify roles; it is not a universal grammar. A particular command can accept no options, require options in a special order, treat a word beginning with a hyphen as data, or define syntax that differs from another utility.

Commands, options, and arguments

Command name

The first word normally selects what Bash should run. For example, in ls -l /home, Bash locates ls using its command lookup rules and starts it (or invokes a builtin, function, or alias if one has that name in the current environment). The command name does not describe every word that follows; it only identifies the program or shell construct to execute.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Options adjust behavior

-l in the example is conventionally an option requesting a long listing. Many utilities also provide long forms such as --help, and some accept an option value, for example an option followed by a separate word or with the value attached. These conventions are common, not guaranteed. The utility defines the accepted spelling, whether options may be combined, and what each option does.

Arguments provide values

/home is an argument identifying the directory that ls should inspect. Arguments can be file names, directory names, patterns, numbers, strings, or other values, depending on the utility. A command may require a particular number of arguments, accept many, or interpret an argument differently based on its position.

To discover the rules for the specific command, try its own help output, often with --help, and read its manual page with a command such as man ls. The help text and manual are authoritative for that utility, rather than assumptions based on another program’s conventions.

What Bash passes to the utility

Bash parses the line and prepares command words before execution. Quoting and expansion can change those words: a quoted space can remain inside one argument, a variable can be replaced with its value, and an unquoted wildcard can expand to several file names. Therefore, punctuation and spaces do not always reach the utility literally. Parsing and expansion are a larger follow-on topic, but remember the boundary: Bash determines the words it will pass, and the utility interprets the resulting option and argument values.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Part Typical example Primary interpreter Purpose
Command ls Shell resolves and launches it Selects a builtin, function, script, or executable
Option -l or --help The utility defines its meaning Changes an operation or requests a mode
Argument /home The utility defines its meaning Supplies data or a target to operate on
Redirection > file Shell Changes a command’s input, output, or error destination
Pipeline | less Shell Connects one command’s output stream to another command’s input

Standard streams: input, output, and errors

Unix-style programs normally start with three standard streams, identified by file descriptors:

  • Standard input (fd 0) is where a command reads input.
  • Standard output (fd 1) is where normal results are written.
  • Standard error (fd 2) is where diagnostics and error messages are written.

By default, input often comes from your terminal, and both output streams appear on the terminal. They are separate even when they look mixed together on screen. Pipes use standard output by default, so a command’s diagnostics do not automatically flow through the pipe.

How pipes pass output between commands

A basic pipeline

Consider:

ls -l /etc | less

Bash starts the commands and connects the first command’s standard output to the second command’s standard input. less then reads the listing a page at a time without requiring an intermediate file. The first command still writes its normal output; the shell has simply provided a pipe as that output’s destination.

In a multi-command pipeline, commands generally run in separate subshells. This affects shell state: changing a variable or directory inside a pipeline component may not change the parent shell. Bash documents a conditional lastpipe behavior that can allow the final pipeline command to run in the current shell when specific job-control conditions are met, so do not assume the exception on every installation or script.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Errors are not included automatically

Because a plain | connects fd 1, an error sent to fd 2 normally remains attached to the terminal:

find /etc -name '*.conf' | less

Any permission diagnostics from find can still appear on screen while matching names go to less. Bash also provides |&, which connects standard output and standard error to the next command. It is effectively the Bash shorthand for 2>&1 |.

command |& less

The receiving utility must still be able to make sense of both kinds of text. Combining diagnostics with data is useful for inspection, but separating them is usually better when another program must parse the output.

Redirection operators and their exact effects

Read a file as standard input

The operator < makes a file the command’s fd 0:

sort < names.txt

sort reads from names.txt as if the data had been typed or provided by another process. The command itself does not need a file-name argument in this form.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Write or append standard output

> sends fd 1 to a file. Bash creates the file if necessary or truncates its existing contents before the command writes:

date > run-date.txt

Truncation is destructive. Check the destination before running a command when previous contents matter. Use >> to append instead:

date >> run-date.txt

Appending preserves existing data and adds new output at the end.

Save standard error separately

Prefix a redirection with a file descriptor to target that stream. This sends fd 2 to a diagnostics file while normal output remains on the terminal:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
command 2> errors.txt

You can combine independent destinations, for example:

command > output.txt 2> errors.txt

Capture output and errors in one file

To put both streams in the same file, redirect standard output first and then duplicate that destination for standard error:

command > all.txt 2>&1

The first operator points fd 1 at all.txt. The second tells fd 2 to use the destination currently associated with fd 1.

Why redirection order matters

Bash processes redirections from left to right. These two commands are therefore different:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
command > all.txt 2>&1
command 2>&1 > output.txt

In the first line, standard output is assigned to all.txt, then standard error is made a duplicate of that destination, so both streams go to the file. In the second, standard error first duplicates wherever standard output currently points (normally the terminal); only afterward is standard output changed to output.txt. The result is normal output in the file but diagnostics on the terminal.

This left-to-right rule also explains why merely mentioning both file descriptors does not guarantee a combined log. Place the duplication after the output destination you want it to copy.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A practical method for reading a command line

  1. Identify the shell context. Ask whether the example is Bash-specific. Operators such as |&, expansion rules, and pipeline behavior should not be presented as identical across all shells.
  2. Find the command name. Determine whether it is a builtin, function, script, or external program. Commands such as cd must commonly be builtins because they need to change the current shell’s directory.
  3. Separate ordinary words from shell operators. Look for |, |&, <, >, >>, and descriptor forms such as 2>. The shell handles these before the utility sees its arguments.
  4. List options and arguments as the utility will receive them. For ls -l /home, record -l as an option and /home as an argument, then check ls --help or man ls for exact rules.
  5. Trace the streams. Mark fd 0, fd 1, and fd 2 at each stage. A pipe normally carries fd 1; an explicit 2> or 2>&1 changes where errors go.
  6. Check destructive destinations. Treat every > as a possible truncation before executing it. Replace it with >> only when appending is the intended behavior.

Common beginner mistakes and fixes

Assuming every hyphenated word has the same meaning

An option’s spelling and behavior belong to its utility. If -v means verbose for one command, it may mean something else—or be invalid—for another. Read that command’s help or manual instead of transferring a convention.

Expecting a pipe to carry errors

A plain pipe carries fd 1 only. Use a separate error redirection when you need a log, or Bash’s |& when deliberately combining both streams.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Overwriting a log accidentally

> truncates before writing. Inspect the path, use a new filename, or choose >> for an append operation. If a command fails after truncating the file, the previous contents cannot be restored by the shell.

Believing the utility sees the original text

Quoting, variable expansion, and wildcard expansion can alter the words Bash passes. When a file name contains spaces or wildcard characters, quote it deliberately and consult Bash’s parsing and expansion documentation before diagnosing an argument-count error.

Assuming all Linux systems have identical tools

GNU Coreutils programs are widely available, but a minimal image, a non-GNU Unix-like system, or an older distribution can provide different utilities or option sets. Check the installed command’s version and manual on the system where a script will run.

Building confidence safely

Start with commands that only display information, such as printf, pwd, and a directory listing. Add one option or one redirection at a time, and inspect the result. For a pipeline, first run each command separately, then connect them with |. For logging, test with a temporary filename and deliberately generate a harmless diagnostic so you can see whether fd 2 went where intended.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep Bash-specific examples labeled as Bash when writing scripts or documentation. If portability matters, identify the target shell, avoid relying on undocumented behavior, and verify options against the utility’s manual on the target machine. A Linux command line book for beginners can provide structured practice on streams, pipes, and redirection, but the installed shell and utility documentation remain the definitive reference for actual behavior.

Reference documentation

Use the Bash Reference Manual for parsing, expansion, command execution, pipelines, and redirection in Bash 5.3. Use the GNU Coreutils manual for the documented file and text utilities in Coreutils 9.11. Because both shells and utilities evolve, check the version installed on the machine when behavior or option availability matters.

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.