Read commands and find help

Lesson 3 of 30 · Working with Linux

A simple command has a name followed by any arguments it needs. Spaces usually separate those arguments. In echo 'field report', the quotes tell Bash to treat the two words as one argument; the quotes themselves are not printed. Names are case-sensitive on typical Linux filesystems, so Report.txt and report.txt may be different files.

Some arguments are options (also called flags) that change a command’s behavior. For example, once the practice file exists, head -n 2 field.txt means: run head, use the -n option with value 2, and read field.txt. The command prints its first two lines. Options belong to the particular command: the same letter can mean something different elsewhere. Position can matter. Some tools also offer longer options such as --help.

Documentation helps us check instead of guessing. On many Linux systems head --help prints a short usage description. man head opens the manual page if the manual and page are installed. In the usual pager, Space advances, / followed by a word and Enter searches, n finds the next match, and q quits. Some shell built-ins have Bash help instead: help cd. If a help option or manual is missing, consult the distribution’s documentation. A manual’s [OPTION] notation describes an optional part; do not type the brackets unless its instructions say otherwise.

Read the command and its target before pressing Enter. A line that creates, replaces, or removes data deserves more care than one that only displays it.