3 Ways to Change a Users Default Shell in Linux

In this article, we will describe how to change a user’s shell in Linux. The shell is a program that accepts and interprets commands; there are several shells such as bash, sh, ksh, zsh, fish and many other lesser known shells available on Linux.

Bash (/bin/bash) is a popular shell on most if not all Linux systems, and it’s normally the default shell for user accounts.

Read Also: 5 Most Frequently Used Open Source Shells for Linux

There are several reasons for changing a user’s shell in Linux including the following:

  1. To block or disable normal user logins in Linux using a nologin shell.
  2. Use a shell wrapper script or program to login user commands before they are sent to a shell for execution. Here, you specify the shell wrapper as a user’s login shell.
  3. To meet a user’s demands (wants to use a specific shell), especially those with administrative rights.

When creating user accounts with the useradd or adduser utilities, the --shell flag can be used to specify the name of a user’s login shell other than that specified in the respective configuration files.

A login shell can be accessed from a text based interface or via a SSH from remote Linux machine. However, if you login via a graphical user interface (GUI), you can access the shell from a terminal emulators like xterm, konsole and many more.

Let’s first list all available shells on your Linux system, type.

# cat /etc/shells


Before you proceed any further, note that:

  • A user can change their own shell to any thing: which, however must be listed in the /etc/shells file.
  • Only root can run a shell not listed in /etc/shells file.
  • If an account has a restricted login shell, then only root can change that user’s shell.

Now let’s discuss three different ways to change Linux user shell.

1. usermod Utility

usermod is a utility for modifying a user’s account details, stored in the /etc/passwd file and the -s or --shell option is used to change the user’s login shell.

In this example, we’ll first check user tecmint’s account information to view his default login shell and then change its login shell from /bin/sh to /bin/bash as follows.

# grep tecmint /etc/passwd
# usermod --shell /bin/bash tecmint
# grep tecmint /etc/passwd
Change User Shell using Usermod
Change User Shell using Usermod

2. chsh Utility

chsh is a command line utility for changing a login shell with the -s or –shell option like this.

# grep tecmint /etc/passwd
# chsh --shell /bin/sh tecmint
# grep tecmint /etc/passwd
Change User Shell Using chsh
Change User Shell Using chsh

The two methods above all modify the shell specified in /etc/passwd file which you can edit manually as in the third method below.

3. Change User Shell in /etc/passwd File

In this method, simply open the /etc/passwd file using any of your favorite command line text editors and change a specific users shell.

# vi /etc/passwd
Change User Shell in Passwd File
Change User Shell in Passwd File

When your done editing, save and close the file.

Do not forget to read these related topics:

  1. Understanding Shell Initialization Files and User Profiles in Linux
  2. Understand Linux Shell and Basic Shell Scripting Tips – Part I
  3. How To Write and Use Custom Shell Functions and Libraries
  4. Understanding Different Classifications of Shell Commands and Their Usage

In this article, we described various ways of changing a user’s shell in Linux. To share any thoughts with us, use the comment section below.

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

1 thought on “3 Ways to Change a Users Default Shell in Linux”

  1. On some Linux distributions, some shells like tcsh aren’t installed by default, but you can probably install them.

    For instance on Fedora 31,

    # dnf install tcsh

    It is all you need to do (as root) to install tcsh.


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.