What Is the Terminal?

The terminal is the window for giving the computer commands in text. The shell (bash, zsh) is the program inside the terminal that reads and runs commands…

Have you ever ordered food by sending a chat message to a food stall you know? The chat app is only a window: the place where you type your message and read the reply. The cashier at the stall reads your message and understands what you want. The kitchen does the actual cooking.

You can also give a computer commands in text. You type one command and press Enter, and the operating system (the computer's basic program, such as Windows or Linux) runs it and answers in text too. The computer has the same three roles:

Terminal, shell and CLI

People often use these three words as if they were the same, but they mean different things:

In daily talk, people say "open the terminal" for all three, and that is fine. But if someone asks about the difference: the terminal is the window, and the shell is the program that processes commands.

The prompt: the terminal is ready for a command

As soon as the terminal opens, the shell writes a prompt, a short text like the one below, then waits for you to type:

budi@laptop:~$

In all the examples in this course, the text after the prompt is what you type. The lines under it are the computer's answer.

Anatomy of a command

A command is made of parts separated by spaces. This command has three parts:

ls -a web-project

Because spaces separate the parts of a command, a name that contains a space needs quotes: ls "school work".

Your first commands

This is the terminal on Budi's laptop, with the output (the answer) that bash really shows on Linux:

budi@laptop:~$ whoami
budi
budi@laptop:~$ pwd
/home/budi
budi@laptop:~$ ls
Documents  Downloads  web-project
budi@laptop:~$ ls web-project
error.log  index.html  logs  script.js  src  style.css
budi@laptop:~$ ls -a web-project
.  ..  .env  error.log  index.html  logs  script.js  src  style.css
budi@laptop:~$ echo "Hello, Terminal"
Hello, Terminal

Who does the work for those commands? Take ls as the example. The shell splits the line you typed, looks for a program called ls in the folders where programs are stored, such as /usr/bin, and runs that program. Some commands, such as cd (change folder), pwd and echo, are builtins: the shell does them itself without calling another program.

If you use Windows, you have three choices for running these commands. This lesson uses bash, so the default choice is WSL:

Option When to pick it
WSL (Ubuntu) The default for this lesson. WSL runs real Linux, so the commands are the same as on any Linux system. Install it by typing wsl --install in PowerShell (a shell that comes with Windows), opened as administrator.
Git Bash Installed together with Git for Windows. Enough for basic commands like ls, cd and pwd, without installing Linux.
PowerShell Already on Windows, but its commands are different from bash. In PowerShell, ls is another name for Get-ChildItem: the output looks different, and hidden files only appear with ls -Force, not ls -a.

When you mistype a command

The shell treats upper and lower case letters as different. On Linux, LS is not ls, so the shell cannot find a program called LS:

budi@laptop:~$ LS
bash: LS: command not found

The shell wrote the command not found message, and every shell has its own style of message. If the same window runs zsh, the message becomes zsh: command not found: LS.

Compare that with an error that comes from a program, not from the shell. In this example, Budi asks for a folder that does not exist:

budi@laptop:~$ ls project
ls: cannot access 'project': No such file or directory

The program ls wrote this message, so it reads exactly the same in bash and in zsh. What can change the message is the version of the program ls. macOS has a different version of ls, so on a Mac the message is a little different: ls: project: No such file or directory. Read error messages slowly. They usually say three things: which program reports the problem (ls), what it was looking for ('project') and what the problem is (that folder does not exist).

Shortcuts you'll use right away

Key What it does
Tab Completes the name of a command, file or folder you've typed part of
↑ / ↓ Brings back earlier commands
Ctrl+C Stops the command that's running (not copy)
Ctrl+L Clears the screen, the same as clear
Ctrl+Shift+C / Ctrl+Shift+V Copy and paste in a Linux terminal. On macOS it's still Cmd+C / Cmd+V

💡 Why developers still use the terminal

⚠️ Four first-day mix-ups

TL;DR: The terminal is the window for giving the computer commands in text. The shell (bash, zsh) is the program inside the terminal that reads and runs commands. CLI is the general name for working by typing commands, the opposite of a GUI (a view you click). A prompt such as budi@laptop:~$ means the shell is ready for a command. A command can have three parts separated by spaces: the command (what to do), flags (they change how it works, and start with -) and arguments (the things it works on). Start with whoami (your user name), pwd (the folder you are in), ls (what is in a folder), ls -a (hidden files too), echo (show text) and clear (clear the screen). On Linux, upper and lower case are different. The message command not found comes from the shell. Tab (complete a name), ↑ (the previous command) and Ctrl+C (stop a command) are the first shortcuts to learn.

⚡ The window and the command reader

Guess first: terminal or shell, which one reads your command?

The shell. The terminal is only the window: the place where you type commands and read the reply. The shell is the program inside that window that processes the command, for example bash or zsh.

Meaning: Compare it with ordering food by chat. The chat app is the terminal, and the cashier who understands your order is the shell. The kitchen that makes the order is the operating system (the computer's basic program, such as Windows or Linux).

⚡ The prompt: ready for a command

Meaning: A prompt is the text the shell writes when it is ready for a command, for example budi@laptop:~$. budi is the user name, laptop is the computer's name, ~ is the folder you are in (the home folder, your personal folder), and $ means "ready, type here".

⚡ Command, flag, argument

Write:

ls -a web-project

Meaning: ls is the command: what to do (show what is in a folder). -a is a flag: it changes how the command works (hidden files are shown too). web-project is the argument: the thing the command works on (the folder to look into). The parts are separated by spaces, so a name that contains a space needs quotes.

⚡ Your first commands

Write:

whoami
pwd

Meaning: whoami shows your user name. pwd shows the folder you are in right now. On Linux, upper and lower case are different: if you type LS instead of ls, the shell answers command not found.

What you will learn