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

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

What you'll be able to do

  • Explain how a shell differs from the kernel
  • Tell what bash, zsh, and sh each refer to

Prerequisites (read these first)

What Is a Shell, Really?

"bash," "zsh," "shellAn interactive program that reads the commands you type and runs them. 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 kernelThe core program of an OS. It bridges hardware and software. work together — all through a conversation between Lina and Linny-senpai.

What You'll Learn

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 pathA string that describes the location of a file or directory. 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.

Lina Trips Up on echo

Conclusion: $SHELL is case-sensitive. Type $shell in lowercase, and the variable can't be found. Nothing gets printed.

Lina: Let me check my shell like you showed me! echo $shell... huh, nothing shows up.
echo $shell

Lina: The screen's just blank... what happened?
Linny-senpai: Close! The right variable is the uppercase $SHELL. $shell doesn't exist, so it printed nothing.
echo $SHELL
/bin/bash
Lina: Oh, uppercase worked! I have to type the variable name exactly right.
Linny-senpai: Exactly. The shell reads your commands exactly as typed. So the case has to be right too.

Mini Exercises

Conclusion: Try today's commands yourself in Penguin Gym Linux to make them stick.

Linny-senpai: Let's try a few exercises to check what you learned today.

Exercise 1: Check Your Login Shell

Task: Run a command to check the path of your login shell.

Show Hint 1 (Direction)

A special variable holds the shell that starts at login. Show it.

Show Hint 2 (Command name)

Use echo to display the $SHELL variable.

Show Answer
echo $SHELL
/bin/bash

Exercise 2: Check the Running Shell from Its Process

Task: Show the process info for the shell that's running right now.

Show Hint 1 (Direction)

Recall the command that shows process info. The clue is the special variable holding the running shell's own process ID.

Show Hint 2 (Command name)

Run ps with the -p $$ option.

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

Exercise 3: List the Available Shells

Task: Display the list of shells installed on this system.

Show Hint 1 (Direction)

There's a file that lists the available shells. Look at its contents.

Show Hint 2 (Command name)

Use cat to display the /etc/shells file.

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

Today's 3-Line Summary

Conclusion: Today's key points are the shell-kernel relationship, the bash/zsh/sh differences, and the check/change commands.

  1. The shell is the kernel's translator - it interprets your commands, passes them to the kernel (the core), and returns the results
  2. sh, bash, and zsh are all types of shell - sh is the baseline, bash is the most widely-used successor, zsh is bash-compatible and feature-rich
  3. Check with echo $SHELL / ps -p $$, change with chsh -s - you can only specify a shell listed in /etc/shells

Next Reading

Share this article

Next steps