How to change Login Shell CentOS / Fedora / Redhat / Ubuntu / Scientific Linux

A normal user may only change the login shell for own account but root user change the login shell for any account. To change the Linux Login Shell you can use ‘ chsh ‘ command with option ‘ -s ‘


To Change Login shell for CentOS / Fedora / Redhat / Scientific Linux / Ubuntu:

To check which shell am i using:

[root@localhost ~]# echo $SHELL
/bin/bash
[root@localhost ~]#

Now we check available shells in our server:

[root@localhost ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh
[root@localhost ~]#

 

Now we change the login user shell:

[root@localhost ~]# chsh
Changing shell for root.
New shell [/bin/bash]: /bin/tcsh
Shell changed. 

    Or

[root@localhost ~]# chsh -s /bin/bash
Changing shell for root.
Shell changed.
[root@localhost ~]#

To check login shell:

 [root@localhost ~]# cat /etc/passwd | grep root
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin

To change the Login Shell  for other user :

[root@localhost ~]# chsh -s /bin/tcsh dev1
Changing shell for dev1.
Shell changed.

To check login shell for user dev1:

[root@localhost ~]# cat /etc/passwd | grep dev1
dev1:x:1002:1010::/home/dev1:/bin/tcsh

All command line options  used with the ‘chsh ‘ command are shown below

________________________________________________________________________

Options:                                                           Description

________________________________________________________________________


-s, –shell <shell>                                 specify login shell
-l, –list-shells                                       print list of shells and exit
-u, –help                                                display this help and exit
-v, –version                                          output version information and exit

_________________________________________________________________________

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s