Bash vs. Shell vs. Terminal
The words shell, Bash, and terminal are often used as if they meant the same thing, but they describe three different parts of a command-line session. Keeping them apart makes it much easier to understand error messages, configuration files, and instructions you find online. In short, the terminal is the window, the shell is the program that interprets your commands, and Bash is one particular shell.
Understanding the Concept
A command-line session is built from layers:
You → Terminal → Shell (Bash) → Commands and programs → Kernel
- The terminal displays text and sends your key presses onward.
- The shell reads what you typed, interprets it, and starts programs.
- Bash is the specific shell program that does the interpreting.
Each layer can be replaced independently. You can run Zsh inside a terminal that previously ran Bash, or you can run Bash inside a different terminal application. Nothing about the shell forces you to use a particular terminal, and nothing about the terminal forces you to use a particular shell.
The Terminal
A terminal, also called a terminal emulator, is a program that provides a text window. Its responsibilities are narrow:
- Draw characters, colors, and the cursor on screen.
- Capture keyboard input and send it to the program running inside.
- Handle scrolling, copy and paste, tabs, and fonts.
The terminal does not understand commands. If you type ls and press Enter, the terminal simply forwards those characters. It is the shell that decides that ls is a program to start.
Examples of terminal programs include GNOME Terminal, Konsole, xterm, iTerm2, the macOS Terminal app, Windows Terminal, and the integrated terminal in many code editors.
Where the Name Comes From
Early computers were controlled through physical devices that had a keyboard and a printer or screen. These devices were called terminals because they sat at the end of a connection to a large computer. Today the physical device is gone, and software imitates it. That is why the modern program is called a terminal emulator, and why you will sometimes see it called a TTY, short for teletypewriter.
The Terminal Type
A terminal announces its capabilities to programs through the TERM environment variable:
echo "$TERM"
Sample output:
xterm-256color
On the machine used to test this lesson, the value was linux. Programs such as editors and pagers read this variable to learn which colors and control sequences the terminal supports.
Checking Whether a Terminal Is Attached
The tty command prints the name of the terminal device connected to the shell:
tty
Sample output in a terminal window:
/dev/pts/0
When a command runs without a terminal, for example inside an automated job, tty prints:
not a tty
This distinction matters because programs sometimes behave differently depending on whether a person is watching.
The Shell
A shell is the program that interprets commands. It runs inside the terminal, reads each line you type, and executes it. The shell is also a scripting language, so it can read commands from a file when no terminal is involved at all.
Because the shell does not draw anything itself, it does not need a screen. You can run a shell in a terminal, over a network connection, inside a container, or as a background process started by a scheduler.
The previous lesson, What Is a Shell?, describes what the shell does in detail. The key point for this lesson is that "shell" is a category of program. Bash, Zsh, Fish, Dash, and Ksh are all shells.
Bash
Bash is one specific shell, the Bourne Again Shell. It is a program stored on disk, usually at /bin/bash. If the shell is the category, Bash is one member of it, much like "web browser" is a category and Firefox is one browser.
You can confirm that the program in your terminal is Bash:
ps -p $$ -o comm=
Output:
bash
$$ is the process ID of the current shell, and ps prints the name of that process. If you were using Zsh, the output would be zsh.
Putting the Three Together
Open a terminal and type a command, and all three pieces take part:
- You press keys. The terminal captures them and sends them to the shell.
- Bash reads the line
echo hello, recognizesechoas a built-in command, and runs it. - Bash writes
helloto its standard output, which is connected to the terminal. - The terminal receives the characters and displays them.
The following table compares the three terms side by side:
| Term | What it is | Main job | Examples |
|---|---|---|---|
| Terminal | A window program (terminal emulator) | Display text, capture keystrokes | GNOME Terminal, iTerm2, Windows Terminal |
| Shell | A command interpreter | Read commands, start programs, run scripts | Bash, Zsh, Fish, Dash |
| Bash | One particular shell | Interpret the Bash language | /bin/bash |
Shell Level and Nested Shells
Because a shell is just a program, you can start one shell from inside another. Bash keeps a counter called SHLVL that records how deep the nesting goes:
echo "outer=$SHLVL"
bash -c 'echo "inner=$SHLVL"'
Output:
outer=1
inner=2
The inner command starts a second Bash process, and that process increases the counter by one. When it ends, you return to the outer shell. This also shows that changes made in a nested shell do not carry over to the outer shell. For example:
bash -c 'exit 3'
echo "status=$?"
Output:
status=3
The inner shell ends with exit status 3, and the outer shell receives that number in $?. Nothing else from the inner shell survives.
Common Confusions
Several everyday phrases blur these terms. Reading them correctly clears up a lot of confusion.
"Open the Bash terminal"
This usually means "open a terminal window that runs Bash." The window is the terminal and the program running in it is Bash.
"Run it in the shell"
This means typing the command at a shell prompt, or running it in a script that a shell executes. It says nothing about which shell or which terminal.
"Command prompt," "PowerShell," and "CMD" on Windows
These are shells too, but they are not Bash. Windows Command Prompt and PowerShell have their own languages with different syntax. To use Bash on Windows, you start a Bash shell through WSL or a tool such as Git Bash, and run it inside a terminal such as Windows Terminal.
"SSH into the server"
When you connect to a remote machine with SSH, your local terminal displays the session, but the shell runs on the remote machine. You type in one place and the commands execute in another. This works precisely because the terminal and the shell are separate.
Why the Difference Matters in Practice
- Configuration. Terminal settings, such as fonts and colors, live in the terminal application. Shell settings, such as aliases and the prompt, live in files like
~/.bashrc. Editing the wrong place has no effect. - Troubleshooting. A garbled display or broken colors is often a terminal issue. A "command not found" message is a shell issue.
- Scripts. A script can be executed without any terminal, for example from a scheduler, so it must not assume a person is present.
- Portability. Instructions for "the shell" might use Bash-only syntax. Knowing that Bash is one choice among several helps you spot instructions that will not work in another shell.
Seeing the Pieces on Your Own System
Three short commands show the layers on a real machine:
echo "$TERM"
ps -p $$ -o comm=
echo "$BASH_VERSION"
The first reports the terminal type, the second reports the shell program in use, and the third reports the Bash version if the shell is Bash. Together they answer the three questions: what kind of terminal, which shell, and which version.