What Is a Shell? bash, zsh, and the Kernel

What Is a Shell? bash, zsh, and the Kernel

What Is a Shell, Really?

"bash," "zsh," "shell script" — as soon as you start learning commands, these words pop up everywhere. But what a shell actually is often gets skipped over.

This guide untangles what a shell is, how bash, zsh, and sh differ, and how the shell and the kernel work together — all through a conversation between Lina and Linny-senpai.

What You'll Learn

  • Why a shell is a "translator" between you and the OS
  • How the shell and the kernel divide the work
  • The difference between bash, zsh, and sh — and which to use
  • The command to check which shell you're using
  • How to switch your login shell safely

1. What Is a Shell?

Conclusion: A shell is a translator program — it takes the commands you type, passes them to the OS core (the kernel), and returns the result.

Lina: Linny-senpai, what even is a "shell"? I keep hearing names like bash and zsh...
Linny-senpai: Great question. A shell is a translator program. It takes the commands you type and passes them to the "kernel" at the center of the OS.
Lina: A translator...?
Linny-senpai: Right. You type ls. But the kernel doesn't understand the text ls directly. The shell interprets that text and asks the kernel, "run the program that lists files." Then it hands the result back to you in a form you can read.
Lina: So it stands between me and the OS!
Linny-senpai: Exactly. The name "shell" comes from being the outer layer that wraps the kernel (kernel means "core").

A shell is a command interpreter

The shell's formal job is to be a "command interpreter": it reads the text you type and launches the matching program. It helps to remember that the terminal (the screen) and the shell (the interpreter) are two different things.

2. How Do the Shell and Kernel Relate?

Conclusion: The kernel is the "core" that manages hardware directly; the shell is the outer "front desk" that connects that core to humans.

Lina: You keep mentioning the kernel — what is it exactly?
Linny-senpai: The kernel is the innermost part of the OS. It manages hardware directly: memory, CPU, disk. It really is the "core."
Lina: So can't we just talk to the kernel directly?
Linny-senpai: That's hard to do safely. The kernel is so powerful that one wrong move could break the whole system. So we put a shell in between, to communicate safely and in human-friendly language.
Lina: Like asking someone important through a receptionist.
Linny-senpai: That's the perfect image. Here's the flow laid out.
You → Terminal → Shell → Kernel → Hardware
(input) (display) (interpret) (execute) (CPU/memory/disk)

Three players

  • Terminal: the "screen" where you type and read text
  • Shell: the "translator" that interprets commands and passes them to the kernel
  • Kernel: the "core" of the OS that drives the hardware

3. How Do bash, zsh, and sh Differ?

Conclusion: sh is the original baseline, bash is its widely-used successor, and zsh is bash-compatible with richer features. All are members of the same "shell" family.

Lina: So what are bash and zsh? They're all shells, right?
Linny-senpai: Right, they're all "types of shell." Same translator, but each is good at slightly different things. Let's look at the big three.
Lina: Please!
Linny-senpai: First, sh. It's the original, most basic shell — "sh" is short for shell. These days it's often a link (alias) to a newer shell in many environments.
Lina: And bash?
Linny-senpai: bash stands for "Bourne Again SHell," an enhanced successor to sh. It's the default shell on most Linux systems and the most widely used today. When in doubt, reach for bash.
Lina: Then what about zsh?
Linny-senpai: zsh (Z Shell) is largely compatible with bash but has powerful completion and theming. It's also the default shell on macOS. Popular with people who like to customize their setup.
Shell Read as Features Position
sh "S-H" Most basic, minimal Classic, scripting baseline
bash "bash" sh successor, most common Default on most Linux
zsh "Z shell" bash-compatible + rich features macOS default, customizer favorite

When in doubt, use bash

bash is plenty for beginners. Most online tutorials and command examples assume bash, so your learning will go smoothly. Once you're comfortable, you can consider switching to zsh.

For a deeper comparison of each shell, see bash vs zsh vs fish.

4. How Do I Check Which Shell I'm Using?

Conclusion: echo $SHELL shows your login shell, and ps -p $$ shows the shell that's actually running right now.

Lina: I'm not even sure which shell I'm using...
Linny-senpai: There's a command for that. First, let's check your login shell — the one that starts when you log in.
echo $SHELL
/bin/bash

$SHELL holds the path of the shell launched at login. In the example above, you're using bash.

To check the shell that's actually running right now, use this command.

ps -p $$
  PID TTY          TIME CMD
 2451 pts/0    00:00:00 bash

$$ is a special variable holding "the process ID of the running shell itself." With ps -p $$, you can directly confirm whether that shell is bash or zsh. It may differ from echo $SHELL (your configured shell), so it's good to know both.

You can list the installed shells with this command.

cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/zsh
/usr/bin/zsh

The How to Use the Terminal page lets you practice typing commands from the ground up. Try these check commands there too.

5. How Do I Change My Login Shell?

Conclusion: Use chsh -s to change it. Only specify a shell that is listed in /etc/shells.

Lina: I want to try switching from bash to zsh! How do I do it?
Linny-senpai: You use the chsh (change shell) command. But there are a few things to watch out for first.

First, confirm the shell you want is listed in /etc/shells (you can't specify a shell that isn't listed). Once confirmed, change it like this.

chsh -s /bin/zsh

The change takes effect from your next login.

Tips for trying it safely

  • Don't specify a path that isn't in /etc/shells (it can leave you unable to log in)
  • Instead of switching right away, just type zsh to start it temporarily and try the feel first
  • To go back, run chsh -s /bin/bash to return to bash
Lina: Got it. First type zsh to try it, then make it official with chsh if I like it!
Linny-senpai: Perfect order. Now you can choose the shell on your own machine with confidence.

Summary

  • A shell is a "translator" program that passes your commands to the kernel
  • The kernel is the "core" that drives hardware; the shell is the outer front desk
  • sh is the baseline, bash is the most widely-used successor, zsh is bash-compatible and feature-rich
  • echo $SHELL and ps -p $$ let you check your current shell
  • chsh -s changes your login shell (within the options in /etc/shells)

Next Reading