Skip to content

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

echo $SHELL

Example Output

/bin/bash

Explanation

  • $SHELL is an environment variable

  • It shows the default shell assigned to the current user


List Available Shells

cat /etc/shells

Example Output

/bin/sh
/bin/bash
/usr/bin/zsh
/usr/bin/fish

Explanation

  • Displays all installed shells on the system

  • Useful when selecting or changing shells


Switching Between Shells (Temporary)

bash
sh
dash

Explanation

  • Starts a new shell session

  • Does not permanently change the default shell

Exit Back

exit

Change Default Shell (Permanent)

Step 1: Run Command

chsh

Step 2: Enter Password

  • Required for authentication

Step 3: Enter Shell Path

/bin/bash

Explanation

  • Sets the default login shell

  • Takes effect after logout/login


Alternative Command

chsh -s /bin/bash

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

echo $SHELL

Example 2: List Installed Shells

cat /etc/shells

Example 3: Switch to Another Shell

zsh

Example 4: Change Default Shell

chsh -s /usr/bin/zsh

Important Notes

  • Only valid shells listed in /etc/shells can 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.