Skip to content
Linux TLDR
  • 🏠 Home
  • 🐧 Topic
    • All in One
    • DevOps
      • Ansible
      • AWS
      • Docker
      • Git
      • Jenkins
      • Kubernetes
    • Hardware
      • Raspberry Pi
    • How to
    • Linux Commands
      • Builtin Commands
      • Curl Commands
      • Homebrew Commands
      • MySQL Commands
      • SSH Commands
    • Linux Distributions
      • Alma Linux
      • Debian
      • Fedora
      • Kali Linux
      • Linux Mint
      • Manjaro
      • Red Hat
      • Ubuntu
    • News & Updates
    • Package Installer
    • Programming
      • Bash Scripting
      • C/C++
      • Go Lang
      • Java
      • Javascript
      • Node Js
      • Php
      • Python
      • Ruby
    • Reviews
    • Tools
    • Troubleshooting
    • Tutorials
    • Weekly Roundup
    • What is
  • πŸ•΅οΈ Privacy Policy
  • πŸ“§ Contact Us
  • πŸ“– About
    • πŸͺΆ Write an Article
    • πŸ”— Follow Us
    • 🎁 Donate

Beginners Guide for Chsh Command on Linux

Linux TLDR
Last Updated: December 17, 2023
Reading time: 3 minutes

Many Linux distributions ship Bash as the default login shell, but if you want to replace it with another shell like ZSH or Fish, then you can use the chsh command to change the existing or specific user login shell.

In this article, you will learn the usage of the chsh command with practical examples.

Table of Contents

Toggle
  • Tutorial Details
  • Syntax of the Chsh Command
  • Listing the Existing Shells
  • Changing the User’s Login Shell (Interactive Mode)
  • Changing the User’s Login Shell (Non-Interactive Mode)
  • Reflecting the New Login Shell Changes
  • [Extra Tip] Changing into the Unspecified/Invalid Shell

Tutorial Details

DescriptionChsh (Change Shell)
Difficulty LevelLow
Root or Sudo PrivilegesYes
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisiteschsh
Internet RequiredNo

Syntax of the Chsh Command

The chsh command takes two arguments: one is the option, and the other is the login (username).

$ chsh [OPTION] [LOGIN]

The following is the list of known options:

OptionsDescription
"-s", "--shell"Take the path of the shell that will be used as a replacement for an existing or specified user login shell.
"-R", "--root"Apply the change and use the configuration files from the β€œCHROOT_DIR” directory.
"-h", "--help"Display the help section.

The β€œ/etc/passwd” file will be modified when the user login shell is changed.

  • Listing All the Available Shells in Your Linux System

Listing the Existing Shells

The only restriction applied while changing the default login shell is that the new login shell path must be listed in the β€œ/etc/shells” file, which can be checked using the cat command.

$ cat /etc/shells

Output:

Listing the existing login shells

If your new login shell path is not present in the above list of shells, then only the root user has permission to change the login shell by adding any value (referring to the shell path) while changing the user’s login shell.

An account with a restricted login shell also does not have permission to change its login shell; the only option is to ask another privileged user to change it for them.

Changing the User’s Login Shell (Interactive Mode)

The following command, without specifying the username with the β€œ-s” flag, will change the login shell for the currently logged-in user in interactive mode by asking for a new shell path.

$ chsh

Output:

Changing the current user login shell in interactive mode

Changing another user’s login shell requires root or sudo privileges; if you have them, then specify their username to change their existing login shell in interactive mode.

$ sudo chsh jake

Output:

Changing the another user's login shell in interactive mode

The above command will replace the β€œjake” user login shell with the β€œ/bin/zsh” shell.

Changing the User’s Login Shell (Non-Interactive Mode)

Use the β€œ-s” flag with the new login shell path (without specifying any username) to change the currently logged-in user login shell in non-interactive mode.

$ chsh -s $(which zsh)

#OR

$ chsh -s /bin/zsh

Output:

Changing the current user login shell to non-interactive mode

To change another user’s login shell, specify their username as root or sudo user.

$ sudo chsh -s $(which zsh) jake

#OR

$ sudo chsh -s /bin/zsh jake

Output:

Changing the other user's login shell to non-interactive mode

Reflecting the New Login Shell Changes

Restart the system or logout and login to reflect the new login shell changes for the current or specified user.

Then verify their existing shell using the following command:

$ echo $SHELL

#OR

$ echo $0

Output:

Verifying the existing login shell

[Extra Tip] Changing into the Unspecified/Invalid Shell

If the new login shell path is not present in the β€œ/etc/shell” file, then you will get the following error while changing the current user login shell.

Invalid shell

In this situation, you have to find the binary path of that shell using the which command or search in the β€œ/bin/” directory using the find or ls commands.

  • Also Read: What is Korn Shell (KSH) in UNIX/Linux System
$ ls -l /bin/ksh

Output:

Finding the binary path for an invalid shell

Once you have the binary path of the new login shell, use that path with the chsh command as a root or sudo user.

$ sudo chsh -s /bin/ksh

Output:

Changing the login shell to an invalid shell

The above command will change the login shell of the currently logged-in user. To change the login shell of another user, just specify their username after the shell path.

That’s all about the chsh command that an informed Linux user should know.

If you are facing any difficulty while changing the shell or have a tip that should be added to this article, then feel free to tell us in the comment section.

SHARE:

Recommended Articles

πŸ”—How to Install Zabbix Server on Ubuntu 24.04 (Noble Numbat)
πŸ”—Stellar Repair for MySQL – Product Review
πŸ”—How to Install RQuickShare (NearbyShare/QuickShare) on Linux
πŸ”—How to Install RabbitMQ Server on Linux (Quick Guide)
πŸ”—How to Use Chattr Command in Linux (for Beginners)
πŸ”—How to Setup SOCKS5 Proxy Server on Linux Using MicroSocks
πŸ”—Reset the WordPress Admin Password Using CLI (via 2 Methods)
πŸ”—How to Check Python Version in Linux (via 3 Methods)
πŸ”—How to Check PHP Version in Linux (via 4 Methods)
πŸ”—[Fixed] pkg-config script could not be found in Linux

Latest

Install zabbix server on ubuntu

How to Install Zabbix Server on Ubuntu 24.04 (Noble Numbat)

mysql database recovery tool

Stellar Repair for MySQL – Product Review

RQuickShare Linux

How to Install RQuickShare (NearbyShare/QuickShare) on Linux

Install RabbitMQ Server on Linux

How to Install RabbitMQ Server on Linux (Quick Guide)

chattr command

How to Use Chattr Command in Linux (for Beginners)

Newsletter

Explore the latest Linux news, tutorials, tips, and resources to master open-source technology.

Social Handles

quora

Your help is needed

AI and ad blockers are significantly impacting advertising revenue. Donate now to support funding for this independent site.

🎁 Make a Donation
Linux TLDR © 2026 - Discover, Learn, and Master Linux with Us 🐧