How/Command to change the login shell for a user – Unix/Linux

We have already discussed one method to change the login shell of a user by changing the shell value in /etc/passwd file by using the command USERMOD. Shell is a program that takes your commands from the keyboard and gives them to the operating system to perform. Here I am explaining one another simple method to change the login shell of a user with help of the command ‘chsh‘.

All shells are listed in /etc/shells, see the example below:

[email protected] [~]# cat /etc/shells

The ‘chsh‘ command usage with examples:

# chsh [options] [user]

1, -s, –shell
Specify your login shell.

2, -l, –list-shells
Print the list of shells listed in /etc/shells and exit.

3, -u, –help
Print a usage message and exit.

4, -v, –version
Print version information and exit.

How to change the login shell of a user?

# chsh -s /new/shell username


[email protected] [~]# grep crybit /etc/passwd
[email protected] [~]# chsh -s /sbin/nologin crybit
Changing shell for crybit.
Shell changed.
[email protected] [~]# grep crybit /etc/passwd

That’s it !!! 🙂

Related Links:
Command to find out the current shell
[USERMOD]How to change the shell for an already existing user – Unix/Linux
The usermod

Post navigation

Arunlal Ashok

Operations Engineer at Endurance International Group. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team
We like to travel. Our travelogues are published at Trip Mentor

Leave a Reply

Your email address will not be published. Required fields are marked *