In Unix and Linux systems, the $SHELL environment variable indicates the parent shell that initiated your current session. This can be useful for understanding the runtime environment, particularly when troubleshooting or scripting. It’s important to know that this value doesn’t always reflect your default login shell—it shows the shell that started your current session.
For example, if you start a new shell within your login shell, $SHELL still shows the original one. For more system-related insights, see our guide on how to install Kernel 6.15 on Ubuntu, learn useful grep tricks for ps, or explore the Linux yes command for automating responses.
Here’s a practical demonstration:
$ whoami
mike
$ echo $SHELL
/bin/bash
$ zsh
% echo $SHELL
/bin/bash
In this case, even after switching to zsh, the value of $SHELL remains /bin/bash. This is because it reflects the shell that started the session, not the current interactive shell.
Understanding Default Shells
- The system-wide default shell is usually defined in
/etc/default/useradd. - Each user’s default shell is listed in
/etc/passwd.
To check or change the default shell for a user:
Check:
$ grep mike /etc/passwd
Change using chsh:
$ chsh -s /bin/ksh mike
Or using usermod (requires root):
# usermod -s /bin/ksh mike
These commands allow users or administrators to specify which shell environment they prefer, which is essential for scripting, user experience, and system customization.






Pingback: ViM Trick: Split Screen in the Vim Text Editor - iDoLinux
Pingback: How to Change a User’s Default Shell in Linux - Open Source Software News
Pingback: useradd Ubuntu Command Line: How to Create Users in Linux - iDoLinux
Pingback: Mastering Linux User Management with usermod - iDoLinux