Course outline · 0% complete

0/29 lessons0%

Course overview →

Anatomy of a command

lesson 1-3 · ~8 min · 3/29

Command, options, arguments

Learning this one pattern pays for itself forever: every manual page, tutorial, and Stack Overflow answer assumes you can read it. Once you see the parts, an unfamiliar command stops being a magic string and becomes name + settings + target.

Almost every command you'll ever type has the same three-part shape:

ls -l /tmp
  • Command name (ls): which program to run.
  • Options (also called flags), like -l: switches that change how the program behaves. They start with - (short form) or -- (long form, like --help).
  • Arguments (/tmp): what the program should act on. A file, a directory, some text.

You met this already: in echo "Hello, world" (lesson 1-1), echo is the command and the quoted text is its argument. Options are optional, and many commands also work with no arguments at all (pwd, ls).

Code exercise · bash

See a flag change behavior: echo normally ends its output with a newline. The -n flag suppresses it, so the next echo continues on the same line.

When you don't know a command

Two built-in ways to learn, no Google needed:

  • commandname --help: most commands print a short usage summary.
  • man commandname: opens the full manual page in a scrollable reader. Move with the arrow keys or space, and press q to quit (everyone gets stuck in man exactly once).

You don't memorize commands. You remember they exist and look up the details. man ls will show you a dozen flags, and you'll use about four of them, ever.

Quiz

In the command `grep -i error log.txt`, which part is an option (flag)?

Problem

You're reading a man page and want to get back to your prompt. Which single key quits the manual reader?

Code exercise · bash

Your turn. `echo` normally ends its output with a newline; the `-n` option suppresses it (you saw this in the demo above). Use two commands — an `echo -n` and then a plain `echo` — to print exactly one line: ``` loading...done ```