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 named progress-reports, you type:
mkdir progress-reports

Think 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.

Windows: PowerShell and CMD are not Bash

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?

  1. 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.

  2. Speed and automation. Suppose a folder project1 holds 100 files and you want to move the 50 whose names contain 2025 into project2. 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* project2

    Because commands are just text, you can also save them in a file and rerun them whenever you like - a script (see Bash Scripts).

  3. 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.

  4. 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 (ls lists 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 -la means the same as ls -l -a and ls -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.
  • 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 -l works, but ls-l makes Bash look for a command named ls-l, which doesn’t exist (bash: ls-l: command not found).
  • Capitalization matters. -l and -L are 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.

Next: Getting Bash on Your Computer.

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.

GUI = graphical user interface; CLI = command-line interface.

  • GUI: right-click in Finder (Mac) or File Explorer (Windows) and choose “New Folder”.
  • CLI: type a command such as mkdir progress-reports and press Enter.

Question 2 · Multiple choice

Which statement best describes the difference between a terminal and a shell?

  1. They are two names for exactly the same program.
  2. The terminal is the window you type in; the shell is the program that interprets and runs your commands.
  3. The shell is the window you type in; the terminal runs the commands.
  4. The terminal is only for Mac; the shell is only for Windows.

b. The terminal is the app that shows the window and text; the shell runs inside it and does the work. Option a is how people speak casually, but they are technically different programs. Option c swaps the roles. Option d is wrong: both Mac and Windows have terminals and shells.

Question 3 · Multiple choice

Which shell is the default on new Mac user accounts (since macOS 10.15 Catalina)?

  1. Bash
  2. PowerShell
  3. zsh
  4. CMD

c. zsh. Bash was the Mac default before Catalina and is still available. PowerShell and CMD are Windows shells.

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

1 → B, 2 → C, 3 → D, 4 → A.

Question 5 · True or false

When a tutorial shows $ ls -l, you should type the $ too.

False. The $ (or % in zsh) is the prompt: the shell displays it to show it is ready. You type only ls -l. If you type the $, Bash treats it as the command name and you get an error such as bash: $: command not found.

Question 6 · Short answer

Many commands print nothing at all when you run them. What does that usually mean?

It usually means the command succeeded. Most commands stay silent when they work and print an error message only when something goes wrong (“no news is good news”).

Medium

Question 7 · Short answer

Identify the command name, the option(s), and the argument(s) in:

ls -l -t projects
  • Command name: ls
  • Options: -l and -t
  • Argument: projects

Question 8 · Write the command

Rewrite ls -l -a -t as a single combined group of short options. Does the order of the letters matter?

ls -lat (or ls -alt, ls -tla, …). For simple on/off options like these, the order doesn’t matter - all of these versions mean the same thing.

Question 9 · Multiple choice

Which of these is a long option?

  1. -a
  2. -la
  3. --all
  4. all

c. Long options start with two dashes followed by a word. -a is a short option, -la is two short options combined, and all without dashes would be treated as an argument (for example, a file named all).

Question 10 · Predict the output

Sam types ls-l (forgetting the space) in Git Bash and presses Enter. What happens, and why?

He gets an error: bash: ls-l: command not found. Bash splits a command line into words at the spaces. Without a space, the whole thing ls-l is one word, so Bash looks for a program named ls-l, which doesn’t exist.

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.”

“The terminal is the app that shows you a window; the shell is the program that reads your commands and runs them. In this book we use the Bash 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.

PowerShell is a different shell with its own commands and rules. It accepts ls as a shortcut for its own Get-ChildItem command, but it doesn’t understand Bash options such as -la, so it reports an error. Your classmate should open Git Bash (installed with Git for Windows) and run the command there.

Question 13 · Short answer

Give three reasons why developers use the command line even though a GUI is easier to learn.

Any three of:

  • Many developer tools (Git, npm, Python, Claude Code) are command-line tools, and some have no GUI.
  • It is faster for many tasks, such as moving all files whose names match a pattern with one command.
  • Commands can be saved in scripts and rerun (automation).
  • Servers in the cloud usually have no GUI, so they are managed by typing commands.
  • AI coding agents run shell commands, and you need to read and understand them.

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.

Agents such as Claude Code run commands on your computer, with your files. Depending on its permission mode, Claude Code may show you a command and ask whether to proceed - you can only make a good decision if you can read the command (for example, recognize that rm -r deletes a folder and everything in it). Even when it runs commands without asking, you are still responsible for the result and need to understand what it did, spot mistakes, and fix problems. You also need the command line to set things up yourself (installing tools, using Git, starting Claude Code with claude). A good answer mentions: agents run real commands, you approve or review them, and you stay responsible.

Question 15 · Scenario

Claude Code shows you this command and asks “Do you want to proceed?”:

rm -r old-reports

Identify the parts of the command. Which part would you double-check before answering, and why?

  • Command name: rm (remove, i.e. delete)
  • Option: -r (“recursive”: delete a folder and everything inside it)
  • Argument: old-reports (what will be deleted)

Double-check the argument: is old-reports really the folder you want to delete, and is it the one in the current folder (not some other folder with the same name)? Deleting with rm is permanent - there is no trash can (see Creating, Copying, Moving, and Deleting).

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?

  • mv moves files.
  • project1/*2025* means “every file in project1 whose name contains 2025” - the * wildcards match any characters before and after 2025.
  • project2 is the destination folder.

In a GUI you would have to find and select each matching file by hand (easy to miss one). The command selects them all by a rule, in one step, and you can reuse it whenever you need it.

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"
  • Command: git
  • Subcommand: commit
  • Option: -m (the commit message)
  • Value: Add contact page

Spaces separate the words of a command. Without quotes, Add, contact and page would be three separate words; the quotes keep them together as one value for -m.

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?

Both show the user name, the computer name, and the current folder, followed by a prompt symbol (% for zsh, $ for Bash) that says “ready for your next command”. In both, ~ means the user is currently in their home directory. The exact look of a prompt depends on the shell and its settings, but its job is the same everywhere.

© 2025-2026 Y. Rosenthal. All rights reserved.