How to Change User Login Shell Safely in Linux

Updated: Jan 30

On Linux a login shell is a shell given to a user upon login into their user account. Today we will look at how to change the default login shell safely for one specific user.

Change user login shell safely

To set the particular shell, the shell entry must be present in /etc/shells file.

[root@host ~]# cat /etc/shells 

If it is a new user, we can use useradd -s to set the shell for this user.

# useradd -s /bin/bash testuser

To change existing user's shell, below two commands can be used:

# chsh -s /bin/bash testuser
# usermod --shell /bin/bash testuser

It is not a safe way to change the user login shell by changeing file /etc/passwd directly. We don't recommend this way.

We can use the following two ways to verify the shell for this user.

# echo $SHELL /bin/bash
# cat /etc/passwd | grep testuser 


Join our mail group. Get a free Linux account on Cloud.

Never miss a post!

Want a free Linux account?  This account can be used to login to our cloud server and practice Linux commands.


✔ Linux Commands   ✔ Linux Skills    ✔ LinuxPerformance   ✔ Linux Interview

Some articles are from the public internet. If you find your article misused or undesired here and you don't want us to display it, please let us know and we'll remove it immediately.