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

3 Ways to Change User’s Login Shell in Linux

Linux TLDR
Last Updated: November 30, 2025
Reading time: 3 minutes

As an informed Linux user, you already know that, in addition to Bash, there are ZSH, KSH, Fish, and other lesser known shells that bring extra features and functionality to the table.

Still, many Linux distributions ship Bash as the default login shell, but they can’t stop you from playing with another shell.

The following are some reasons that might force users to change their login shell:

  • Blocking or disabling the user’s login using the nologin shell in Linux.
  • Utilizing the additional features or functionality of another shell.
  • Adding the user to the restricted bash shell.
  • Switching to a shell that supports the shell script and executes it before the user login.

While creating the user account using the useradd or adduser command, you have the β€œ-s” or β€œ--shell” flag to specify a custom login shell apart from the default.

Still, if you forget to do that, you can follow this article to learn different ways to change the user’s login shell in Linux.

Table of Contents

Toggle
  • Tutorial Details
  • Key Notes
  • Checking the Current User’s Login Shell
  • List Out All the Shells in Your System
  • Changing the User’s Login Shell
    • Method 1: Using the Usermod Command
    • Method 2: Using the Chsh Command
    • Method 3: Modifying /etc/passwd File
  • Final Tip!

Tutorial Details

DescriptionChanging User’s Login Shell
Difficulty LevelModerate
Root or Sudo PrivilegesYes
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisitesprintenv, echo, cat, usermod, chsh, vim, nano
Internet RequiredNo

Key Notes

The following are a few things you should know while changing the user’s login shell.

  • All the commands mentioned in this article will modify the β€œ/etc/passwd” file.
  • Users can only change to another shell that is listed in the β€œ/etc/shells” file; otherwise, root or sudo users have the privilege to change to an unlisted shell.
  • You can easily manage to change your own existing shell.
  • Changing another user’s login shells requires the root or sudo account.
  • If the account has a restricted login shell, then only the root or another sudo user has privileges to change the login shell.

Checking the Current User’s Login Shell

Always take a note of your existing login shell before changing to another to easily revert back in the future if things do not go as expected.

Execute any one of the following commands to check your existing login shell:

$ printenv SHELL

#OR

$ echo $0

Output:

Displaying the current user's login shell

As you can see, I have a Bash login shell as the default in my Linux system.

  • Listing All the Available Shells in Your Linux System

List Out All the Shells in Your System

Next, you need to make sure that the new login shell that you are about to switch is present in the β€œ/etc/shells” file by reading it using the cat command.

$ cat /etc/shells

Output:

Listing all the existing shells in Linux

Changing the User’s Login Shell

Once you have found your existing login shell and the new shell is present in the β€œ/etc/shells” file, you can follow any one of the following methods to change your existing login shell.

πŸ“
In the following method, I’ve used the β€œ$(which shellname)” command to pass the shell path; however, you can directly specify the full path without using the which command unless the path is present in the β€œ/etc/shells” file.

Method 1: Using the Usermod Command

The usermod command is used to change user account information by modifying the β€œ/etc/passwd” file and you can specify the new login shell path to β€œ-s” or β€œ--shell” flag with username to change.

For example, the following command will change the login shell from Bash to ZSH for the β€œlinuxtldr” user.

$ grep linuxtldr /etc/passwd                                               #Checking the current login shell
$ sudo usermod -s $(which zsh) linuxtldr                         #Changing to ZSH login shell
$ grep linuxtldr /etc/passwd                                               #Checking the record updated with new login shell

Output:

Changing the user's login shell using the usermod command

Method 2: Using the Chsh Command

The chsh command is a special tool to modify the user’s login shell using the β€œ-s” or β€œ--shell” flag.

$ grep linuxtldr /etc/passwd                                           #Checking the current login shell
$ chsh -s $(which zsh) linuxtldr                                      #Changing to ZSH login shell
$ grep linuxtldr /etc/passwd                                           #Checking the record updated with new login shell

Output:

Changing the user's login shell using the chsh command

Method 3: Modifying /etc/passwd File

In the previous two methods, you learn to change login shell using command-line utility but behind the scenes both are modifying the β€œ/etc/passwd” file with a new login shell path that you can also do manually using your choice of text editor like Vim or Nano.

$ sudo vim /etc/passwd

Output:

Modifying the passwd file with new login shell

Once you are done with editing, save and close the file.

Final Tip!

When you change the user’s login shell the changes will be applied immediately in the β€œ/etc/passwd” file; however, it is always recommended to logout and login to apply the changes properly.

So, that was all the possible ways to change the user’s login shell, except if you have any more tricks, then do let us know 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 🐧