TracksPractical Coding FoundationsUsing the TerminalCommands as Actions(3 of 6)

Commands as Actions

Every terminal command follows a predictable pattern. Once you understand this structure, you can read and use commands you've never seen before — and even guess how new commands might work.

The Command Structure

Commands follow this general format:

command [options] [arguments]

Think of it like a sentence: verb (what to do), adverb (how to do it), and noun (what to do it to).

For example, ls -la /home breaks down as:

  • ls — the command (list files)
  • -la — options (show details and hidden files)
  • /home — argument (which folder to list)

Options Modify Behavior

Options (also called flags) change how a command works. They usually start with a dash:

  • Single dash + letter: -l, -a, -h
  • Double dash + word: --help, --verbose, --all

You can often combine single-letter options. These are equivalent:

ls -l -a
ls -la

The -l option shows detailed information (permissions, size, date). The -a option reveals hidden files (those starting with a dot).

Arguments Specify Targets

Arguments tell the command what to act on. Without an argument, most commands use a sensible default — usually the current directory:

ls              # Lists current directory
ls Documents    # Lists the Documents folder
ls *.txt        # Lists all .txt files

Getting Help

When you encounter an unfamiliar command, you can ask it for help:

ls --help       # Quick help text
man ls          # Full manual page (press 'q' to exit)
Get-Help Get-ChildItem    # PowerShell help
ls --help                 # If using Git Bash

The --help flag works with most commands and gives you a summary of available options. The man command (manual) provides comprehensive documentation.

Reading Command Examples

When you see commands in documentation or tutorials, you can now decode them. Something like grep -i "error" log.txt means: search (grep) case-insensitively (-i) for "error" in the file log.txt.

Understanding this pattern transforms the terminal from mysterious to logical.

See More

Further Reading

You need to be signed in to leave a comment and join the discussion