What Is the Command Line?

Table of Contents

  1. Talking to the Computer in Text
  2. Terminal, Shell, Command Line
  3. Why Developers Still Use It
  4. Which Shell This Series Uses
  5. Opening a Terminal
  6. Reading the Prompt
  7. It's Not Dangerous (Mostly)
  8. Try It Yourself

1. Talking to the Computer in Text

Most of the time you control your computer with a graphical user interface (GUI): windows, icons, buttons, and a mouse pointer. You open a folder by double-clicking it, and you delete a file by dragging it to the trash.

The command line is the other way of doing the same things: you type a command, press Enter, and the computer does it and prints a result as text. Instead of double-clicking a folder, you type:

cd Documents

Instead of opening a folder window to see what's inside, you type:

ls

and get a list of names back:

essay.docx    notes.txt    photos

That's the whole idea. No pictures, no mouse — just you and the computer, taking turns: you type, it answers, you type again.

This is actually the older way of using computers. Before graphical interfaces existed in the 1980s, typing commands was the only way. The GUI was built on top of it later, and the command line never went away.

2. Terminal, Shell, Command Line

You'll hear three words used almost interchangeably. They're related, but they're not quite the same thing:

  • The terminal is the window — the app that shows text and sends your keystrokes along. Terminal on macOS, Windows Terminal, and GNOME Terminal on Linux are all terminals.
  • The shell is the program running inside that window that actually understands your commands. It reads what you type, figures out what you meant, runs the right program, and shows you the output. Bash, zsh, and PowerShell are shells.
  • The command line is the general idea of controlling a computer by typing commands — the text interface itself. People also call it the CLI (command-line interface).

A good way to picture it: the terminal is the telephone, the shell is the person on the other end who understands your language, and the command line is the conversation you're having.

The shell is not magic — it's an ordinary program, like the ones you met in How Computers Work. When you type ls, the shell starts a new child process for the ls program, which asks the operating system for the list of files in a folder and writes it to stdout — which your terminal shows on the screen.

3. Why Developers Still Use It

If the GUI can do the same things, why bother typing? Because for developers, the command line is often faster, more precise, and the only option:

  • Many tools only have a command line. Git, Node.js, npm, Docker, and most framework tools (npx create-next-app, nest new) are designed to be run by typing commands. There often isn't a button.
  • Servers have no screen. When you deploy an app to a Linux server, you connect to it over the network and get a terminal — no desktop, no mouse. Every company server you'll ever touch works like this.
  • It's repeatable. A command can be copied into a README, sent to a teammate, or saved into a script and run a thousand times. "Click here, then there, then right-click…" can't.
  • It scales. Renaming 500 photos by hand takes an hour. On the command line, it's one line.
  • It's how documentation talks. Almost every tutorial — including every other series on this site — gives instructions as commands to type.

You don't have to give up the GUI. Most developers use both all day: an editor like VS Code for writing code, and a terminal next to it for running things.

4. Which Shell This Series Uses

There are several shells, and they don't all speak exactly the same language:

ShellWhere you'll find it
BashThe default on most Linux systems and servers
zshThe default on macOS since 2019
PowerShellBuilt into Windows

Bash and zsh are close cousins: for everything in this series, they behave the same, so the commands you learn work on both. PowerShell is different — it has its own command names and its own way of doing things.

This series teaches Bash/zsh, on every operating system, including Windows. The reason is simple: it's what you'll use on servers, in Docker containers, in Git, and in almost every tutorial online. Learning it once means it works everywhere.

Windows users: you don't need to switch computers. You'll run a real Bash shell on Windows using WSL or Git Bash, shown in the next section. Where PowerShell does something noticeably differently, you'll see a short note like this one.

5. Opening a Terminal

macOS

Press Cmd + Space to open Spotlight, type Terminal, and press Enter. You're now in a zsh shell. That's it — nothing to install.

Linux

Press Ctrl + Alt + T on most distributions (Ubuntu included), or search your apps for Terminal. You're in a Bash shell.

WSL (Windows Subsystem for Linux) runs a real Linux system — with a real Bash shell — inside Windows. It's the closest you can get to what runs on servers, and it's what we recommend.

  1. Open the Start menu, type PowerShell, right-click it, and choose Run as administrator.

  2. Run this command:

    wsl --install
    
  3. Restart your computer when it asks you to.

  4. After the restart, an Ubuntu window opens and asks you to choose a username and password for Linux. These are separate from your Windows login.

When you type the password, nothing appears on screen — no dots, no stars. That's normal and on purpose (it hides the password's length too). Type it and press Enter.

From then on, open Ubuntu from the Start menu, or open Windows Terminal and pick Ubuntu from the drop-down next to the tab.

Windows: Git Bash (alternative)

If WSL won't install on your machine (some older or locked-down computers can't run it), install Git for Windows from git-scm.com. It includes Git Bash, a smaller Bash shell for Windows. You'll need Git for the next series anyway.

Git Bash runs nearly every command in this series. The main difference: your Windows drives appear as paths like /c/Users/dara instead of C:\Users\dara.

6. Reading the Prompt

When the shell is ready for a command, it shows a prompt and waits. It looks a little different on each system, but it usually tells you the same three things:

dara@laptop:~$
  • dara — the user you're logged in as
  • laptop — the computer's name (useful later, when you're logged into a server and need to know which machine you're typing on)
  • ~ — the folder you're currently in; ~ is short for your home folder
  • $ — the end of the prompt: "your turn"

On macOS with zsh, the default prompt is shorter and ends with % instead of $:

dara@MacBook-Air ~ %

If you ever see # at the end instead, you're logged in as the root (administrator) user — be careful, as nothing will stop you from changing system files. Chapter 10 covers this.

A convention used in this series: code blocks show only the command to type, without the prompt in front of it. When we show what the command prints, that appears in a separate block underneath.

7. It's Not Dangerous (Mostly)

Many beginners are nervous about the terminal, as if one wrong key could break the computer. It can't. Almost everything you'll do is harmless: if you type something the shell doesn't understand, it just says so:

zsh: command not found: lss

Nothing happened. You fix the typo and try again.

There are a few genuinely risky things, and this series will point each one out clearly when it comes up:

  • Deleting files with rm skips the trash — there's no undo (chapter 4).
  • Running commands as administrator with sudo removes the safety rails (chapter 10).
  • Pasting commands from random websites that you don't understand.

The habit to build is simple: read a command before you press Enter, and if you don't know what it does, look it up first (chapter 2 shows you how).

8. Try It Yourself

  1. Open a terminal using the steps for your operating system. On Windows, set up WSL (or Git Bash if WSL won't install).
  2. Look at your prompt. Can you find your username, your computer's name, and the current folder?
  3. Type whoami and press Enter. It prints your username — compare it with the prompt.
  4. Type ls and press Enter. You'll see the files and folders in your home folder. Open your file manager to your home folder and compare — it's the same list.
  5. Type a command that doesn't exist, like hello, and press Enter. Read the error message. Nothing broke.

You've opened a shell and had your first conversation with it. Next, let's learn how a command is actually put together.

Buy Me a Coffee

Found this tutorial helpful? Consider buying me a coffee to support more free content!