The Shell and Commands
The shell is the command interpreter that processes what you type and executes programs. Understanding how the shell works will make you much more effective at the command line.
What is a Shell?
The shell is a program that:
- Reads commands from the terminal
- Interprets those commands
- Executes programs
- Returns output to the terminal
Common Shells
| Shell | Description |
|---|---|
bash | Bourne Again Shell - most common, default on most Linux |
zsh | Z Shell - enhanced features, default on macOS |
sh | Bourne Shell - original Unix shell |
fish | Friendly Interactive Shell - user-friendly |
To check your current shell:
Command Structure
Commands follow a consistent structure:
command [options] [arguments]
Examples:
ls- just the commandls -l- command with optionls -l /home- command with option and argumentls -la /home- command with multiple options
Options and Arguments
Options (Flags)
Options modify how a command works:
- Short options: Single dash with letter (
-l,-a,-h) - Long options: Double dash with word (
--all,--help) - Combined short: Multiple letters (
-lasame as-l -a)
Arguments
Arguments are what the command operates on:
cat file.txt # file.txt is the argument
cp source dest # two arguments
mkdir new_folder # folder name is argument
Getting Help
Every command has help available:
| Method | Usage |
|---|---|
--help | ls --help |
man | man ls (manual page) |
help | help cd (for built-ins) |
Command History
The shell remembers your commands:
history- show all previous commandsUp Arrow- recall previous command!!- repeat last command!n- repeat command number n
Tab Completion
Tab completion saves time:
- Start typing a command or filename
- Press
Tab - Shell completes it (if unique) or shows options
Try it in the terminal!
Key Takeaways
- The shell interprets and executes commands
- Commands follow:
command [options] [arguments] - Use
--helpormanfor command documentation - Tab completion and history make you faster

