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
- 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 shellThe first shell started right after a user logs in. 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 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 -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!Lina Trips Up on echo
Conclusion:
$SHELLis case-sensitive. Type$shellin lowercase, and the variable can't be found. Nothing gets printed.
echo $shell... huh, nothing shows up.echo $shell
$SHELL. $shell doesn't exist, so it printed nothing.echo $SHELL
/bin/bash
Mini Exercises
Conclusion: Try today's commands yourself in Penguin Gym Linux to make them stick.
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.
- The shell is the kernel's translator - it interprets your commands, passes them to the kernel (the core), and returns the results
- 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
- Check with
echo $SHELL/ps -p $$, change withchsh -s- you can only specify a shell listed in/etc/shells