Changing the default shell in Linux tailors the command-line environment to match personal workflow and tooling preferences. Shells such as Bash, Zsh, and Fish provide different completion systems, prompt customization, and scripting features, so choosing the right default shell improves productivity and comfort on every login.
On a typical system, the list of valid login shells is stored in /etc/shells, and the chosen shell for each user is recorded in /etc/passwd. Tools such as chsh update the login shell by modifying the account entry, while environment variables like $SHELL or $0 reflect the active shell in a running session. Aligning the configured login shell with the installed binaries in /bin or /usr/bin ensures predictable behavior for interactive sessions and remote logins.
Changing the default shell affects all future logins for that account, including SSH sessions, graphical terminal emulators, and scheduled tasks that rely on the login shell. The new shell must be installed, present in /etc/shells, and referenced by its full path; using an invalid path or an unlisted shell can prevent logins or cause unexpected failures in account management tools.
Steps to set the default shell in Linux:
- Open a terminal session for the user that requires a different default shell.
$ whoami alice
- Display the current interactive shell from the environment variable.
$ echo "$SHELL" /bin/bash
The $SHELL variable usually reflects the login shell defined for the account.
- Show the login shell recorded in the account database.
$ getent passwd "$USER" alice:x:1000:1000:Alice:/home/alice:/bin/bash
The last field of the passwd entry indicates the configured login shell.
- List the shells that are allowed as login shells on the system.
$ cat /etc/shells /bin/sh /bin/bash /usr/bin/zsh /usr/bin/fish
Only shells present in /etc/shells should be used as login shells.
- Install the preferred shell package if it is not already available.
$ sudo apt update && sudo apt install --assume-yes zsh ##### snipped #####
On Fedora use sudo dnf install zsh, and on openSUSE use sudo zypper install --no-confirm zsh.
- Confirm the full path to the newly installed shell binary.
$ command -v zsh /usr/bin/zsh
- Change the login shell to the new shell path for the current user.
$ chsh -s /usr/bin/zsh Password: Changing shell for alice.
Configuring a non-existent or wrong shell path can prevent successful logins for the account until corrected by an administrator.
- Change the login shell for another account when running with administrative privileges if required.
$ sudo chsh -s /usr/bin/zsh bob Changing shell for bob.
The second argument to chsh selects which user account is modified.
- Close the current terminal session to end the existing shell.
Logging out of the graphical session or disconnecting any active SSH sessions ensures all new logins use the updated shell.
- Start a new terminal or SSH session so the updated shell runs as the default.
$ echo "$SHELL" /usr/bin/zsh
- Verify that the account database entry now references the new login shell.
$ getent passwd "$USER" alice:x:1000:1000:Alice:/home/alice:/usr/bin/zsh
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.
