The Terminal and Shell
When you use a computer, you usually point and click: you open apps from a menu, drag files into folders, and type in word processors. But there is another way to work—by typing text commands into a terminal. The terminal is the window or application where you type those commands. The shell is the program that reads what you type, interprets it, and runs the right actions. Think of the terminal as the keyboard and screen you use to talk to the computer, and the shell as the “translator” that turns your words into things the computer does. Learning to use the terminal and shell will give you more control and is essential for programming, working on servers, and using many development tools.
Terminal vs. Shell: What's the Difference?
It's easy to mix these up, but they refer to different parts of the same workflow:
| Term | What It Is | Analogy |
|---|---|---|
| Terminal | The application or window where you type and see output | The keyboard and monitor you use to interact |
| Shell | The program that reads your commands and runs them | The translator between you and the operating system |
When you "open a terminal," you're really opening an app that runs a shell. You type a command, press Enter, and the shell runs it and shows you the result.
Why Use the Terminal?
You might use the terminal when:
- You need to run programming tools (compilers, interpreters, package managers)
- You're working on a remote server or a lab machine that has no graphical interface
- You want to automate tasks with scripts
- You need more power or precision than point-and-click interfaces provide
The Command Line and the Prompt
When you open a terminal, you see a line of text that usually ends with a symbol such as $ or %. That line is called the prompt. It means "the shell is ready for your next command." You type a command and press Enter to run it.
$ pwd
/home/student
$
Here, pwd is the command (it prints your current folder). The line below is the output, and then you get a new prompt. Everything happens one command at a time.
Prompt Format
Prompts can look different on different systems. Common patterns:
| Prompt | Meaning |
|---|---|
$ |
Normal user (Bash-style) |
% |
Normal user (some shells, e.g. Zsh) |
# |
Often indicates root or administrator |
username@hostname:~$ |
Shows your username, computer name, and current directory |
In this course we'll often show just $ before a command. You type only what comes after the $; don't type the $ itself.
Common Shells
Different shells have slightly different features and syntax. The ideas in this course apply to all of them; we'll use Bash-style examples.
| Shell | Description | Common On |
|---|---|---|
bash |
Bourne Again Shell; very common, good for learning | Linux, macOS (older), Git Bash on Windows |
zsh |
Z Shell; default on newer macOS, many extras | macOS (default) |
sh |
Generic "shell"; often points to bash or another shell | Many Unix-like systems |
To see which shell you're using, you can run:
echo $SHELL
Output might be /bin/bash or /bin/zsh, for example.
Basic Interaction
Every time you use the terminal, you're doing the same basic loop:
- Read the prompt.
- Type a command (and any options or arguments).
- Press Enter.
- Read the output (or any error message).
- Repeat.
Your First Commands
Try these to get a feel for the terminal. After each line, press Enter. We will look at these commands in more detail in later lessons.
# Show current directory
pwd
# List files and folders here
ls
# Show which shell is running
echo $SHELL
Tips for Success
- Type carefully: Commands and file names are case-sensitive (
File.txtandfile.txtare different). - Use Tab completion: Type part of a command or path and press Tab; the shell often fills in the rest or shows options.
- Read error messages: They usually say what went wrong (e.g. “No such file or directory”).
- One command per line: Press Enter after each command.
- Don't type the prompt: Only type the command that comes after
$or%.
Common Mistakes to Avoid
- Typing the
$or%as part of the command - Forgetting that spaces matter (e.g. putting a space in a file name when the name has no space)
- Confusing the terminal (the window) with the shell (the program running inside it)
- Ignoring error messages instead of reading them to fix the problem