The Shell and Terminal Explained
Beginners often use 'terminal' and 'shell' interchangeably, but they are distinct layers in the stack that lets you type a command and have the operating system act on it. The terminal (or, more precisely today, a 'terminal emulator' like GNOME Terminal, iTerm2, or Windows Terminal) is simply a program that displays text and forwards your keystrokes. The shell is the program that actually interprets what you type — parsing commands, expanding variables and wildcards, managing pipelines, and launching other programs. Underneath the shell sits the kernel, which performs the real work of creating processes, allocating memory, and talking to hardware on the shell's behalf.
Cricket analogy: Like the stadium's giant screen simply displaying whatever the scoring software decides to show, while the actual physical rules of the game are enforced by the ground's sensor system working behind the scenes on the scoring software's behalf.
Terminal Emulator vs. Shell vs. Kernel
Historically, a 'terminal' was a physical device — a keyboard and screen wired to a mainframe or minicomputer. Modern terminal emulators recreate that experience in software, providing a window that renders text and passes input to whatever program is running inside it, most commonly a shell. When you type ls -la and press Enter, the terminal emulator sends those keystrokes to the shell process; the shell parses the command line, resolves ls to /usr/bin/ls, and asks the kernel (via the fork() and execve() system calls) to create a new process running that binary. The shell then waits for that process to finish and displays its output, which the terminal emulator renders on screen.
Cricket analogy: Like a captain hearing the coach's shouted instruction to bring on the spinner, resolving which specific bowler that means, then asking the ground staff to actually get them onto the field, and waiting for the over to finish before reporting the result.
Bash and Other Shells
Bash (Bourne Again SHell) is the default interactive shell on most Linux distributions and is what this course focuses on for scripting. Other notable shells include sh (the original POSIX Bourne shell, often symlinked to dash on Debian/Ubuntu for faster script execution), zsh (popular for interactive use, default on macOS, with rich completion and theming via frameworks like Oh My Zsh), and fish (friendly interactive shell with sane defaults out of the box, but not POSIX-compatible). Scripts written for portability commonly start with a 'shebang' line specifying which interpreter should run them.
Cricket analogy: Like Test cricket being the traditional default format, a faster T10 variant suits quick games, a stylish franchise league with flashy graphics suits show, and a beginner-friendly backyard variant trades strict rule compliance for ease — every match still opens with an announced format.
# Identify your current shell and available shells
echo $SHELL # default login shell for the current user
ps -p $$ # shows the process name of the currently running shell
cat /etc/shells # list of shells registered as valid login shells
# A minimal script showing the shebang convention
cat > hello.sh << 'EOF'
#!/usr/bin/env bash
echo "Running under: $0"
echo "Shell PID: $$"
EOF
chmod +x hello.sh
./hello.sh
# Switching shells for the current session (temporary, does not change login shell)
zsh # drop into zsh
exit # return to the previous shellOn Debian and Ubuntu, /bin/sh is symlinked to dash, not bash. Dash is a minimal, POSIX-compliant shell with faster startup, used to speed up boot scripts and system-level shell invocations. This is a common source of bugs: a script that works when run as bash script.sh can fail when run as sh script.sh or ./script.sh with a #!/bin/sh shebang, because Bash-only features like arrays or [[ ]] are not supported in dash.
Closing a terminal emulator window does not necessarily stop the programs it launched — by default it sends a hangup (SIGHUP) signal to the shell, which typically terminates foreground jobs, but background jobs started with nohup or inside a tmux/screen session will keep running. Relying on assumptions here rather than verifying with jobs or ps is a common source of confusion.
- The terminal emulator displays text and forwards keystrokes; it does not interpret commands itself.
- The shell parses commands, expands variables/wildcards, and asks the kernel to create processes to run them.
- The kernel performs the actual work of process creation, memory allocation, and hardware access.
- Bash is the default interactive and scripting shell on most Linux distributions; dash, zsh, and fish are common alternatives.
- On Debian/Ubuntu, /bin/sh points to dash, not bash, which can break scripts relying on Bash-only syntax.
- The shebang line (e.g. #!/usr/bin/env bash) tells the kernel which interpreter should execute a script.
Practice what you learned
1. Which component is responsible for actually creating a new process when you run a command?
2. On a default Ubuntu installation, what does /bin/sh point to?
3. What is the purpose of the shebang line at the top of a script?
4. What typically happens to a foreground job when its terminal window is closed?
5. Which shell is best described as interactive-friendly with rich defaults but not POSIX-compatible?
Was this page helpful?
You May Also Like
What Is Linux?
An introduction to Linux as a kernel and family of operating systems: its history, the GNU/Linux relationship, and why it dominates servers, cloud, and embedded devices.
Writing Your First Bash Script
Get hands-on with the anatomy of a Bash script — shebang, permissions, execution, comments, and structuring commands into a reusable, repeatable tool.
Background Jobs and nohup
Learn to run and manage background jobs with &, jobs, bg/fg, and disown, and keep long-running processes alive after logout using nohup and disown.
Getting Help: man, --help, and info
How to find authoritative documentation for any Linux command using man pages, --help output, and the info system, plus tips for searching and navigating them efficiently.
Related Reading
Related Study Notes in DevOps
Browse all study notesNginx Study Notes
DevOps · 30 topics
DevOpsAnsible Study Notes
DevOps · 30 topics
DevOpsAdvanced Kubernetes Study Notes
Kubernetes · 30 topics
DevOpsAdvanced Bash Scripting Study Notes
Bash · 30 topics
DevOpsApache Kafka Study Notes
Kafka · 30 topics
DevOpsDocker & Kubernetes Study Notes
YAML · 40 topics