Before the First Command
Most courses make you type commands from the very first minute.
This lesson takes the opposite path: understanding what happens even before
pressing Enter.
When you type a command in a terminal, you are not speaking directly
to the operating system. There is an intermediary between you and the Linux kernel
— a program whose role is to receive what you type, interpret it,
and send it to the right place. That program is the shell.
The Shell: An Interpreter Between You and the Kernel
A modern computer is organized in layers. At the center is the kernel
— the program that directly controls the hardware: the
processor, memory, disks, network. The kernel is powerful but does not
speak human language. You do not communicate with it directly.
Above the kernel, programs provide an interface. The shell is one of them.
It is a command interpreter: it reads what you write, understands it
as an instruction, and asks the kernel to execute it.
When you type ls to list the files in a directory, here is what actually
happens: your terminal displays the characters you type. When
you press Enter, the terminal sends the line to the shell. The shell
recognizes ls as the name of a program. It asks the kernel to launch that
program. The kernel executes it and returns the result. The shell displays that
result in the terminal.
The shell is the interpreter that translates your commands into instructions understandable by the operating system kernel.
Shell comes from the idea of a “shell” — it is the outer layer that surrounds the kernel and allows you to interact with it.
Terminal and Shell: Two Different Things
A very common confusion among beginners: mixing up the terminal and
the shell.
The terminal is the program that displays text and captures your keyboard
input. It is the window you open — iTerm2 on macOS, GNOME Terminal
on Linux, Windows Terminal on Windows. The terminal handles display,
colors, fonts, scrolling.
The shell is the program running inside the terminal that
interprets your commands. Bash, Zsh, Fish — these are shells.
The simplest analogy: the terminal is the window. The shell is what
runs behind the window. You can change the shell without changing the
terminal, and change the terminal without changing the shell.
This command asks your shell to tell you which shell it is. The
$SHELL variable contains the path to the currently used shell program.
If you see /bin/bash, you are using Bash. If you see /bin/zsh,
you are using Zsh.
Terminal is the display program. Shell is the command interpreter running inside it.
Why the Shell Exists
One might wonder why this intermediate layer is necessary.
Why not speak directly to the kernel?
The answer is simple: the kernel does not understand human language. It understands
system calls — very precise binary instructions. Writing system
calls directly to list files or copy a directory would be
extremely tedious and reserved for system programmers.
The shell solves this problem by offering a command language: a syntax
readable by a human that automatically translates into system calls.
cp file.txt folder/ is infinitely more accessible than the equivalent in
C system calls.
The shell also does much more than execute simple commands. It manages
variables, loops, conditions, functions. It can read script files
and execute entire sequences of commands automatically. That is
why we speak of shell scripting: the shell is also a full programming language.
The shell provides a human-readable language that automatically translates into instructions the kernel understands.
The Different Types of Shells
There are several shells, each with its own characteristics. You will encounter
several throughout your career.
sh — the Bourne Shell — is the ancestor. Created in 1979, it defined the basic syntax
that all modern shells inherited. Minimalist, universal,
present on practically all Unix systems.
Bash — Bourne Again Shell — is the direct evolution of sh created in 1989.
It is the default shell on the vast majority of Linux distributions and
was the default shell on macOS until 2019. It is the shell you
will use in this course.
Zsh — Z Shell — has been the default shell on macOS since Catalina (2019).
Highly compatible with Bash but with additional features and an
improved interactive experience.
Fish — Friendly Interactive Shell — is a modern shell designed to be
particularly pleasant to use interactively, with advanced autocompletion
and a slightly different syntax.
We will explore these distinctions in more depth in a dedicated lesson. For now,
remember that Bash is the reference standard — it is the one you must
master first.
Bash — Bourne Again Shell — is the reference shell of this course and the most widespread on Linux systems.
What the Shell Is Not
The shell is not the operating system. Linux, macOS, Windows — these are
operating systems. Bash is a program that runs on these systems.
You can have Bash on Linux, on macOS, and even on Windows via WSL.
The shell is also not the only way to interact with a system.
Graphical interfaces — file explorers, applications — also
interface with the kernel through other mechanisms. The shell is simply
the text-based interface, and for many tasks, it is by far the most
efficient.
Exercise 1
Open your terminal and type the following command. Which shell are you using?
Exercise 2
Type the following command. What does it return and what does each
piece of information mean?
Exercise 3
Without using a search engine, explain in your own words the
difference between terminal, shell, and operating system. Then compare
with what you just read.
Next Lesson
You now know what a shell is and why it exists. The next
lesson explores the natural follow-up question: why use a
command-line interface rather than a graphical interface — and in
which cases each is the best option.