Change the Default Shell in Linux with chsh

Change the Default Shell in Linux with chsh

A Linux login starts a shell for your account, and you may want a different one to start next time. chsh changes the login shell saved for your account.

I’ll show you how to change that setting with chsh and check the account entry afterward.

TL;DR

Use chsh with the full path of an installed shell to change the current account’s login shell, then start a new login session to use it.

  • Check valid paths in /etc/shells.
  • Run chsh -s /path/to/shell for your own account.
  • Verify the account entry with getent passwd “$USER”.

What Is the Default Shell on Linux?

A default Linux shell is the program an account starts at login.

Shell choiceControlsWhen it applies
Account login shellThe user’s account recordWhen a login session starts
Shell launched from a promptThe current terminal processUntil that process exits
Terminal profile settingOne terminal applicationWhen that app opens a window

I ran two read-only checks for this example: cat /etc/shells lists candidate paths, while getent passwd shows an account’s configured shell.

Bash, Zsh and Fish have different features, so choose based on the interactive tools or syntax you want. Fish uses syntax that differs from Bash, a factor to weigh if you run Bash scripts.

Related: Linux shells and their differences and types of shell in Linux.

How to Change Your Default Shell with chsh

For your own account, chsh updates the login-shell field without requiring a manual edit of /etc/passwd. Choose the exact path shown for your preferred shell, then check the account record before logging out.

Step 1: Check the available shell paths

Read /etc/shells to see the full paths available for login shells.

cat /etc/shells
Valid login shells listed in /etc/shells
Terminal output from cat /etc/shells.

I ran cat /etc/shells and found /usr/bin/zsh listed twice. Unprivileged users are generally limited to paths in this file, though implementation settings vary.

# /etc/shells: valid login shells
/bin/sh
/usr/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/usr/bin/dash
/usr/bin/screen
/usr/bin/tmux
/bin/zsh
/usr/bin/zsh
/usr/bin/zsh

Step 2: Set the shell for your account

Replace /usr/bin/zsh with the path you found.

chsh -s /usr/bin/zsh

Authentication may be required. Enter your account password if prompted.

Step 3: Verify the configured login shell

getent queries the system’s account database, which can include sources beyond the local /etc/passwd file. The guide to listing users in Ubuntu explains that lookup scope.

getent passwd "$USER"
Account record showing the configured Bash login shell
getent displays the account entry and its configured shell path.

I ran getent passwd “$USER” for this check, which returned:

ubuntu:x:1001:1001:Ubuntu:/home/ubuntu:/bin/bash

In this example, $USER resolves to ubuntu, and the final field shows /bin/bash, the shell currently configured for that account.

A fresh login reads the updated shell setting.

What to Check If the New Shell Does Not Start

First, check the account entry because it separates an update failure from a login-time problem. Then check the shell path, permissions and server policy. Keep your working shell available until a new login succeeds.

SymptomWhat to checkNext step
chsh rejects the pathIs it listed in /etc/shells and installed?Choose a valid listed path. Distribution rules can differ.
SSH opens a different shellAccount entry from getent and server-side policyCheck with the administrator if accounts are centrally managed.
Shell command exists but login failsDoes the selected executable still exist?Use a working administrative recovery route to restore a valid path.

Do not edit /etc/passwd as a shortcut. Its fields are positional, and a nonexistent shell path can prevent login. Alpine Linux also documents distribution differences: chsh may require its shadow package, so check your distribution’s guidance if the command is missing.

These are separate controls. A terminal profile affects windows opened by that application, while SSH and text-console logins follow the account shell and any server-side policy.

Conclusion: Change the Login Shell Safely

Use chsh with a full path listed in /etc/shells, verify the account entry, and sign in again to test the change. It updates the account setting without a hand edit of the system account file.

For the next step, see the Zsh setup guide or the Fish shell guide.

FAQ

These answers cover common questions about changing a Linux login shell.

Does chsh change the shell in my current terminal?

No. It changes the account’s configured login shell. An already-running shell process continues until you exit it, and a new login session uses the updated setting.

Why must the shell path appear in /etc/shells?

Unprivileged chsh users are generally restricted to paths listed in /etc/shells. The accepted paths and policy can vary by implementation and distribution.

How can I check my default login shell?

Use getent passwd “$USER” and inspect the final colon-separated field. That field contains the account’s configured login-shell path.