A shell is a command-line interpreter that allows users to interact with the Linux operating system.
The shell:
- Accepts commands
- Executes programs
- Manages scripts
- Handles automation
- Controls system operations
What is a Shell?
When you type a command like:
ls
The shell:
- Reads the command
- Finds the executable
- Executes it
- Displays output
Common Linux Shells:
| Shell | Full Name | Main Usage |
|---|---|---|
| sh | Bourne Shell | Original Unix shell |
| bash | Bourne Again Shell | Most common Linux shell |
| zsh | Z Shell | Advanced interactive shell |
1. Sh (Bourne Shell)
About
- One of the oldest Unix shells
- Created for early Unix systems
- Lightweight and simple
Features
- Basic scripting
- POSIX compatible
- Minimal functionality
Location
/bin/sh
Usage
sh script.sh
2. Bash (Bourne Again Shell)
About
Most widely used Linux shell.
Default shell in many Linux distributions.
Bash
Features of Bash
- Command history
- Tab completion
- Variables
- Scripting support
- Aliases
- Job control
- Pipes and redirection
Check Current Shell
echo $SHELL
Bash Configuration Files
| File | Purpose |
|---|---|
| ~/.bashrc | Interactive shell config |
| ~/.bash_profile | Login shell config |
| /etc/bashrc | Global bash config |
3. Zsh (Z Shell)
About
Advanced shell with better user experience and customization.
Features of Zsh
- Better auto-completion
- Smart suggestions
- Advanced themes
- Plugin support
- Better productivity
Install Zsh
Ubuntu/Debian
sudo apt install zsh -y
Change Default Shell to Zsh
chsh -s $(which zsh)
Logout and login again.
Zsh Configuration File
~/.zshrc
Install Oh My Zsh
Popular Zsh framework.
Install:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Real-World Zsh Plugins
Git Plugin
Edit:
nano ~/.zshrc
Add:
plugins=(git docker kubectl)
Reload:
source ~/.zshrc
Real-World Practical Example
DevOps Engineer Shell Setup
A DevOps engineer managing:
- Docker
- Kubernetes
- Git
- Cloud servers
Usually configures shell for faster operations.
Practical Bash Example
Create Productivity Aliases
Edit:
nano ~/.bashrc
Add:
alias k='kubectl'
alias d='docker'
alias dc='docker compose'
alias gs='git status'
alias gp='git pull'
alias tf='terraform'
Reload:
source ~/.bashrc
Now commands become:
k get pods
d ps
gs
tf apply
This is heavily used in:
- DevOps
- Cloud engineering
- Kubernetes administration
- Linux server management
Useful Shell Commands
View Current Shell
echo $0
List Available Shells
cat /etc/shells
Switch Shell Temporarily
bash
zsh
sh
Shell Scripting Example
Simple Script
Create:
nano backup.sh
Add:
#!/bin/bash
echo "Backup Started"
tar -czf backup.tar.gz /home/user/data
echo "Backup Completed"
Run:
chmod +x backup.sh
./backup.sh
Real-World Usage
| Area | Common Shell |
|---|---|
| Linux servers | Bash |
| DevOps | Bash + Zsh |
| Automation | Bash |
| CI/CD pipelines | Sh/Bash |
| Kubernetes management | Zsh/Bash |
| Cloud administration | Bash |
Top comments (0)