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.
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.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.
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.
| 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 $SHELLshows your login shell, andps -p $$shows the shell that's actually running right now.
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 -sto change it. Only specify a shell that is listed in/etc/shells.
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
zshto start it temporarily and try the feel first - To go back, run
chsh -s /bin/bashto return to bash
zsh to try it, then make it official with chsh if I like it!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 $SHELLandps -p $$let you check your current shellchsh -schanges your login shell (within the options in/etc/shells)