13 13. What Is the Command Line?
Most of the time you control your computer by pointing and clicking. Developers also control computers by typing commands, and AI coding agents do exactly the same. This page explains what the command line is, why it is worth learning, and how to read a command. You will install and open Bash on the next page.
13.1 Two ways to talk to a computer: GUI and CLI
- A GUI (graphical user interface) is what you use every day: windows, icons, menus, and a mouse or trackpad. To create a folder, you right-click in Finder or File Explorer and choose “New Folder”.
- A CLI (command-line interface) is a text conversation with the computer. You type a command, press
Enter, and the computer answers with text. To create a folder namedprogress-reports, you type:
mkdir progress-reportsThink of a CLI as texting your computer precise instructions instead of pointing at things. The command line is the line where you type those instructions. In everyday speech, “the command line”, “the CLI” and “the terminal” are often used to mean the same thing.
A GUI is easier to discover: you can see your options. A CLI is faster, more precise, and easy to automate - once you know a few commands.
13.2 Terminal vs. shell
Two programs work together when you use the command line:
- The terminal is the app that gives you a window to type in and shows the text that comes back. Examples: the Terminal app on a Mac, the Git Bash window on Windows, Windows Terminal, and the terminal panel inside code editors such as VS Code.
- The shell is the program running inside the terminal. It reads each command you type, runs it, and shows you the result.
An analogy: the terminal is a chat window; the shell is who you are chatting with. Different shells understand different “languages” (sets of commands and rules):
| Shell | Where you meet it | Notes |
|---|---|---|
| Bash | Most Linux computers and servers; Git Bash on Windows; also available on Macs | The shell this book teaches. The name stands for “Bourne Again SHell”: it was written as a free replacement for Stephen Bourne’s older shell. |
| zsh (“Z shell”) | The default shell on Macs since macOS 10.15 Catalina (2019) | Nearly identical to Bash for the everyday commands in this book. |
| PowerShell | Built into Windows | Different commands, such as Get-ChildItem to list files. |
| CMD (Command Prompt) | Built into Windows (the older shell) | Different commands, such as dir to list files. |
This book teaches Bash: it is the standard shell on the Linux servers that run most web apps, it comes with Git on Windows, and most tutorials and AI tools assume it. Mac users can type the same commands in zsh.
PowerShell and CMD are good shells, but their commands and rules are different. PowerShell even accepts a few Bash-looking names such as ls and cd as shortcuts for its own commands, but Bash options such as ls -la then fail with an error. When you follow this book on Windows, use Git Bash (set up on the next page).
13.3 Why learn the command line?
Developer tools live there. Git, Python, Node.js and npm are all used by typing commands. Some developer tools have no graphical version at all.
Speed and automation. Suppose a folder
project1holds 100 files and you want to move the 50 whose names contain2025intoproject2. In Finder or File Explorer that means a lot of careful clicking. In Bash it is one line (the*is a wildcard meaning “anything” - see Wildcards and Pipes):mv project1/*2025* project2Because commands are just text, you can also save them in a file and rerun them whenever you like - a script (see Bash Scripts).
Servers have no GUI. The computers that run websites and apps in the cloud are usually Linux machines without a screen. People manage them by typing commands, very often in Bash.
AI coding agents work in the terminal - see the next section.
13.4 The command line in the age of AI
As of Oct 6, 2026 · Official docs: How Claude Code works · Configure permissions
Claude Code, the main AI tool in this course, runs in your terminal: you start it by typing claude. According to its documentation, it can run any command you could run yourself - listing files, running tests, using Git, creating, moving, or deleting files. Depending on its permission mode, it may show you a command such as rm -r old-reports and ask “Do you want to proceed?” before running it, or let an automatic safety check approve routine commands without asking you (details in Permissions, Modes, and Safety).
To answer that question sensibly - and to understand afterwards what an agent did to your files - you must be able to read commands. You don’t need to memorize hundreds of them. You need to recognize the common ones (the next pages cover them) and know how to look up the rest.
13.5 Anatomy of a command
A command is like a short sentence. Its words are separated by spaces:
ls -l -a documents
│ └─┬─┘ └───┬───┘
│ │ └── argument: what to work on
│ └────────── options: how to do it
└─────────────── command name: what to do
- The command name comes first. It names the program to run (
lslists the contents of a folder). - Options (also called flags) change how the command behaves. They start with a dash:
- Short options are one dash and one letter:
-l,-a. Several short options can be combined, and their order usually doesn’t matter:ls -lameans the same asls -l -aandls -a -l. - Long options are two dashes and a word:
--all,--help. They are easier to read but longer to type. Not every program supports them.
- Short options are one dash and one letter:
- Arguments tell the command what to act on - usually file or folder names, such as
documents.
| Command line | Command | Options | Arguments |
|---|---|---|---|
pwd |
pwd |
(none) | (none) |
ls -l |
ls |
-l |
(none) |
ls -la documents |
ls |
-l and -a |
documents |
mkdir progress-reports |
mkdir |
(none) | progress-reports |
cp -r website website-backup |
cp |
-r |
website and website-backup |
Three rules that save a lot of frustration:
- Spaces matter.
ls -lworks, butls-lmakes Bash look for a command namedls-l, which doesn’t exist (bash: ls-l: command not found). - Capitalization matters.
-land-Lare two different options. - Silence is success. Many commands print nothing when they work. If something goes wrong, you get an error message.
Some programs, such as git and npm, have subcommands: git status, git commit, npm install. Some options also take a value:
git commit -m "Fix typo on home page"Here git is the command, commit is the subcommand, -m is an option meaning “message”, and "Fix typo on home page" is the value of that option. The quotes keep the four words together as one value (quotes have their own pages: Writing to Files and Single Quotes vs. Double Quotes).
13.6 The prompt
When the shell is ready for your next command, it shows a prompt: a bit of text ending in a symbol such as $ or %. Prompts look different on different computers, but they work the same way.
maria@MacBook-Air ~ %
User maria, on a computer named MacBook-Air, currently in her home folder (~). The % at the end is the zsh prompt symbol. If Maria starts Bash instead, the prompt ends with $.
sam@DESKTOP-4F7Q2K1 UCRT64 ~
$
User sam, on the computer DESKTOP-4F7Q2K1, in his home folder (~). The word in the middle is a label for Git Bash’s environment (older versions of Git show MINGW64). The $ on the second line is where Sam types.
maria@laptop:~$
User maria, on the computer laptop, in the home folder (~), followed by the $ prompt symbol.
In this book, commands you should type appear in boxes without a prompt, so you can copy them with the copy button. When we show a command together with its output, we put $ in front of the command, as many websites do:
$ pwd
/Users/maria
Don’t type the $ (or %). It belongs to the prompt, not to the command. (pwd prints the folder you are in; it’s explained in Moving Around: pwd, ls, and cd.)
13.7 Key takeaways
- GUI = point and click. CLI = type commands and read text answers.
- The terminal is the window; the shell is the program that interprets your commands. This book uses Bash (Git Bash on Windows; Mac users can use the default zsh).
- A command = command name + options + arguments, separated by spaces.
- Don’t type the prompt symbol (
$or%). - AI coding agents run shell commands for you - reading those commands is your job.
Practice Questions
Easy
Question 1 · Short answer
What do the abbreviations GUI and CLI stand for? Give one example of creating a folder with each.
Question 2 · Multiple choice
Which statement best describes the difference between a terminal and a shell?
- They are two names for exactly the same program.
- The terminal is the window you type in; the shell is the program that interprets and runs your commands.
- The shell is the window you type in; the terminal runs the commands.
- The terminal is only for Mac; the shell is only for Windows.
Question 3 · Multiple choice
Which shell is the default on new Mac user accounts (since macOS 10.15 Catalina)?
- Bash
- PowerShell
- zsh
- CMD
Question 4 · Matching
Match each shell with its description.
| Shell | Description | |
|---|---|---|
| 1. Bash | A. The older built-in Windows shell; lists files with dir |
|
| 2. zsh | B. The shell this book teaches; standard on Linux servers and in Git Bash | |
| 3. PowerShell | C. The default shell on modern Macs | |
| 4. CMD | D. Built into Windows; lists files with Get-ChildItem |
Question 5 · True or false
When a tutorial shows $ ls -l, you should type the $ too.
Question 6 · Short answer
Many commands print nothing at all when you run them. What does that usually mean?
Medium
Question 7 · Short answer
Identify the command name, the option(s), and the argument(s) in:
ls -l -t projectsQuestion 8 · Write the command
Rewrite ls -l -a -t as a single combined group of short options. Does the order of the letters matter?
Question 9 · Multiple choice
Which of these is a long option?
-a-la--allall
Question 10 · Predict the output
Sam types ls-l (forgetting the space) in Git Bash and presses Enter. What happens, and why?
Question 11 · Fill in the blank
Complete the sentence: “The ______ is the app that shows you a window; the ______ is the program that reads your commands and runs them. In this book we use the ______ shell.”
Question 12 · Scenario
A classmate on Windows opens PowerShell, types ls -la, and gets an error. The same command works for you in Git Bash. Explain what is going on and what your classmate should do.
Question 13 · Short answer
Give three reasons why developers use the command line even though a GUI is easier to learn.
Hard
Question 14 · Long answer
Some people say “Now that AI can write and run commands for me, I don’t need to learn the command line.” Explain why this course disagrees.
Question 15 · Scenario
Claude Code shows you this command and asks “Do you want to proceed?”:
rm -r old-reportsIdentify the parts of the command. Which part would you double-check before answering, and why?
Question 16 · Short answer
Explain in your own words why the single command mv project1/*2025* project2 can save a lot of time compared with Finder or File Explorer. What does each part do?
Question 17 · Short answer
In the command below, name the command, the subcommand, the option, and the option’s value. Why are the quotes needed?
git commit -m "Add contact page"Question 18 · Compare
Maria (Mac) sees the prompt maria@MacBook-Air ~ %. Sam (Windows, Git Bash) sees sam@DESKTOP-4F7Q2K1 UCRT64 ~ with a $ on the next line. What do the two prompts have in common, and what does the ~ tell you in both?