How to Change Your Default Linux Shell Using chsh – Step‑by‑Step Guide
This guide explains how to list available shells, identify the current login shell, and use the chsh command to switch the default shell on a Linux system—covering changes to zsh or bash, verification steps, and accessing chsh help options.
Overview
The article provides a practical tutorial for changing the default login shell on a Linux system using the chsh command, including how to list available shells, determine the current shell, switch to a new shell such as zsh, revert to bash, and view command‑line help.
List Available Shells
cat /etc/shellsYou can also filter the list with grep to check for specific shells, e.g., grep "zsh" /etc/shells or grep "fish" /etc/shells.
Find Your Current Shell
ps -p $$ printf "My current shell - %s
" "$SHELL" grep "^${USER}" /etc/passwdThese commands display the shell process and the shell path recorded in the user’s password entry.
Change Default Shell to zsh
type -a zsh # locate the full path of zsh chsh -s /bin/zsh # set zsh as the new login shellLog out and log back in, or use su - $USER, to apply the change.
Revert to bash
type -a bash chsh -s /bin/bashAfter changing, verify the entry in /etc/passwd and re‑login to confirm the shell has been restored.
Help for chsh
man chsh chsh --help-h: display the help message and exit.
-R CHROOT_DIR: apply the change inside the specified chroot directory.
-s /path/to/SHELL: specify the new login shell; leaving it empty lets the system use the default.
Conclusion
By following these steps, you can confidently list shells, identify the current one, switch to zsh or revert to bash, and consult the built‑in help for further options, enabling flexible shell management on Linux systems.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
