Kolam Ayer MakersLinux Foundations

Shell

Core Idea

A shell is a command interpreter. It reads a line of text, expands shell syntax, starts programs, connects streams, and reports success or failure. Bash is the shell used for this course.

Command Anatomy

grep -R makers ~/src/pages > ~/playground/matches.txt 2>/dev/null

What The Shell Does Before A Program Runs

  1. Reads your line.
  2. Splits it into words using shell rules.
  3. Expands variables such as $USER.
  4. Expands ~ and some patterns.
  5. Sets up pipes and redirection.
  6. Starts the command.
  7. Stores the exit status in $?.

Why Quoting Matters

name='Ada Lovelace'
printf '%s\n' $name
printf '%s\n' "$name"

Unquoted variables can split into multiple words. Quoted variables preserve one value. This is why scripts in the course use "$1", "$HOME", and "$name".

Interactive Shell Versus Script

An interactive shell prints a prompt and waits for you. A script is a file of shell commands run by a shell. The same syntax appears in both, but scripts need more discipline: shebang, set -euo pipefail, argument checks, and predictable output.

Common Confusions

Proof Check

Run type cd, type grep, and type printf. Explain which are shell builtins and which are external commands on this system.

Docs Pointers