100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Bash

The Shell and Terminal Explained

Clarifies the difference between the terminal, the terminal emulator, the shell, and the kernel, and introduces Bash as the default command interpreter on most Linux systems.

Linux FoundationsBeginner8 min readJul 9, 2026
Analogies

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.

bash
# 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 shell

On 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

Was this page helpful?

Topics covered

#Bash#LinuxShellScriptingStudyNotes#DevOps#TheShellAndTerminalExplained#Shell#Terminal#Explained#Emulator#StudyNotes#SkillVeris