Operations 5 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Change Your Default Linux Shell Using chsh – Step‑by‑Step Guide

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/shells

You 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/passwd

These 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 shell

Log out and log back in, or use su - $USER, to apply the change.

Revert to bash

type -a bash
chsh -s /bin/bash

After 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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxShellcommand-lineSystem Administrationchsh
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.