06. Shells & Shell Configurations
Overview¶
A shell is a text-based interface that allows users to interact with the operating system by:
-
Executing commands
-
Running programs
-
Managing files and directories
-
Controlling permissions and processes
The shell acts as a bridge between the user and the kernel, interpreting commands and returning output.
Accessing the Shell¶
Users interact with the shell through:
-
Terminal (Linux GUI)
-
Console (command-line interface)
A command prompt is displayed where commands can be entered.
Check Current Shell¶
Example Output¶
Explanation¶
-
$SHELLis an environment variable -
It shows the default shell assigned to the current user
List Available Shells¶
Example Output¶
Explanation¶
-
Displays all installed shells on the system
-
Useful when selecting or changing shells
Switching Between Shells (Temporary)¶
Explanation¶
-
Starts a new shell session
-
Does not permanently change the default shell
Exit Back¶
Change Default Shell (Permanent)¶
Step 1: Run Command¶
Step 2: Enter Password¶
- Required for authentication
Step 3: Enter Shell Path¶
Explanation¶
-
Sets the default login shell
-
Takes effect after logout/login
Alternative Command¶
Explanation
-
-s→ specify shell directly -
Faster method to change shell
Common Shells¶
| Shell | Description |
|---|---|
sh |
Basic shell (Bourne Shell) |
bash |
Most widely used shell |
dash |
Lightweight and fast shell |
zsh |
Advanced shell with plugins |
fish |
User-friendly interactive shell |
Practical Examples¶
Example 1: Check Current Shell¶
Example 2: List Installed Shells¶
Example 3: Switch to Another Shell¶
Example 4: Change Default Shell¶
Important Notes¶
-
Only valid shells listed in
/etc/shellscan be used -
Changes apply after re-login
-
Root privileges may be required in some cases
Summary Table¶
| Command | Purpose |
|---|---|
echo $SHELL |
Show current shell |
cat /etc/shells |
List available shells |
bash, sh, zsh |
Switch shell temporarily |
chsh |
Change default shell |
chsh -s |
Set shell directly |
Conclusion¶
The shell is a core component of Linux that enables:
-
Command execution
-
System interaction
-
Automation through scripting
Understanding how to manage and switch shells improves efficiency and flexibility in Linux environments.