How to Change a Users Shell in Linux


In this tutorial, we will show you how to change the shell of a user 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 is a Unix shell and command language for the GNU Project as a free software replacement for the Bourne shell. First released in 1989,it has been used as the default login shell for most Linux distributions.

We will illustrate how to change the user shell in three different methods:

Method (1): usermod Utility

usermod is a command typical of many Unix and Unix-like operating systems that modifies information associated with existing accounts . 

To run this command, you usually need to have administrator ( root ) privileges

  • First list all available shells on your Linux system
cat /etc/shells

Note: A user can change their own shell to any thing but must be listed in the /etc/shells file, Only root can run a shell not listed in /etc/shells file.

  • With usermod, you can use -s or –shell option is used to change the user’s login shell.


usermod --sell /bin/[shell]  [user]
usermod -s /bin/[shell]  [user]

For Example: We will change the shell of unixcop user from /bin/bash to /bin/nologin to prevent this user from accessing the server

grep unixcop /etc/passwd
usermod --shell /bin/nologin unixcop
grep unixcop /etc/passwd

Method(2): Change the Shell in /etc/passwd File

So, in this method you can edit manually to change the user shell.

  • So, open the /etc/passwd file and change the users shell.
vim /etc/passwd
  • Save and close the file.

Method(3): chsh Utility

chsh (an abbreviation of “change shell”) is a command on Unix-like operating systems that is used to change a login shell. Users can either supply the pathname of the shell that they wish to change to on the command line, or supply no arguments, in which case chsh allows the user to change the shell interactively.


chsh --sell /bin/[shell]  [user]
chsh -s /bin/[shell]  [user]

For Example:

chsh -s /bin/bash qadry


In this article, We showed you how to change a specific user shell in Linux with 3 different methods.

unixcop Admin


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook