## glossary
What is Shell?
The shell is the program that interprets the commands you type and translates them into calls to the operating system. The name comes from the image of a shell wrapped around the system’s core (the kernel) — you talk to the shell, and it talks to the kernel.
It is not just a command runner. It is also a complete programming language, with variables, conditionals, loops and functions, which makes it the default tool for automation on Unix-like systems.
The main shells
- Bash — the most widespread; the historical Linux default and what you find on most servers.
- Zsh — the macOS default since 2019; Bash-compatible and richer in autocomplete and customization.
- Fish — prioritizes usability with native suggestions and syntax highlighting, at the cost of not being compatible with Bash scripts.
- PowerShell — the Windows default; unlike the others, it passes structured objects between commands instead of text.
- sh — the minimal POSIX shell; writing scripts for it guarantees maximum portability.
Shell scripting in practice
#!/usr/bin/env bash
set -euo pipefail # aborts on error, undefined variable or pipe failure
SOURCE="/var/www/app"
DEST="/backup"
DATE=$(date +%Y-%m-%d)
FILE="$DEST/app-$DATE.tar.gz"
if [[ ! -d "$SOURCE" ]]; then
echo "Source not found: $SOURCE" >&2
exit 1
fi
tar -czf "$FILE" "$SOURCE"
echo "Backup created: $FILE"
# removes backups older than 30 days
find "$DEST" -name "app-*.tar.gz" -mtime +30 -deleteThat first line after the shebang deserves attention. set -euo pipefail turns the shell’s default behavior — pressing on after errors — into something predictable. Without it, a backup script can fail silently and delete old files believing it saved the new ones.
Redirection and pipes
command > output.txt # redirects output (overwrites)
command >> output.txt # appends to the end
command 2> errors.txt # redirects only the errors
command > all.txt 2>&1 # merges output and errors into one file
command < input.txt # reads from standard input
command1 | command2 # connects one's output to the other's inputWhere the shell shows up professionally
Every CI/CD pipeline runs shell commands. Every Dockerfile has RUN instructions interpreted by it. Server maintenance, automation of repetitive tasks and incident investigation happen mostly in the terminal. The articles on essential terminal commands and SSH in practice cover the necessary foundation.
## faq
Frequently asked questions
What is the difference between shell, terminal and console?
The terminal is the program with the window that displays text. The shell is the interpreter running inside it that executes your commands. The console, historically, was the physical terminal attached to the machine — today the term is used interchangeably with terminal.
Bash or Zsh: which should I use?
For daily interactive use, Zsh offers better autocomplete and customization, and it is the default on macOS. For writing scripts that will run on servers, prefer Bash or plain sh — that is what will be installed practically everywhere.
When should I stop using shell script and switch languages?
A common rule of thumb: if the script passes a hundred lines, needs to manipulate complex data structures or requires automated tests, move to Python or Go. The shell is excellent for orchestrating commands and terrible for elaborate logic.