Step-by-step how to change login shell using Linux chsh command.

 

Step by step example to change login shell using Linux chsh command.

 

   Using Linux chsh command on the bash shell command prompt to change login shell on Linux fedora core with example.  The article below show the step by step procedure to change shell for user on Linux Fedora Core operating system.

 

Linux command name:  chsh

 

Command Description:

   The Linux 'chsh' command is the command that usually used to change login shell on Linux operating system.

Command type:

   'file' disk file (external command)

 

   The example below demonstrate the use of Linux 'chsh' command to change the shell or login shell for user on the Linux system, all the example is execute on the Fedora Core Linux machine, the executed example may vary on for other Linux flavor.

 

What shell am I using?

 

   Below is the example on how to get information on the type of shell that you are using on the system.   The output of command below display your current shell.  Make sure you used this command to verify your shell changes.

 

[root@fedora ~]# echo $SHELL

/bin/bash

 

Get help for the cshs command.

 

The output of chsh command with the –help option below, prompt the usage of the chsh command.

 

[root@fedora ~]# chsh --help

Usage: chsh [ -s shell ] [ --list-shells ] [ --help ] [ --version ]

       [ username ]

 

Check type of shell available in the system.

 

   To list type of shell install and available on your Linux system.  The example below show the execution of  chsh commands to produce the same output that shows the number of different shell installed on the system.

 

[root@fedora ~]# chsh --list-shells

/bin/sh

/bin/bash

/sbin/nologin

/bin/ash

/bin/bsh

/bin/ksh

/usr/bin/ksh

/usr/bin/pdksh

/bin/tcsh

/bin/csh

/bin/zsh

 

or

 

[root@fedora ~]# chsh -l

/bin/sh

/bin/bash

/sbin/nologin

/bin/ash

/bin/bsh

/bin/ksh

/usr/bin/ksh

/usr/bin/pdksh

/bin/tcsh

/bin/csh

/bin/zsh

 

Step to change Linux login shell.

 

   The example below show the use of chsh command to change shell for current user.

 

[kambing@fedora ~]$ chsh

Changing shell for kambing.

Password:

New shell [/bin/bash]: /bin/csh

Shell changed.

 

[kambing@fedora ~]$ chsh -s /bin/bash

Changing shell for kambing.

Password:

Shell changed.

 

   The chsh command issue with no option and –s option with the full pathname of the desired shell, is used to change shell for the user and it will prompt user for their password (note: the password only prompt for non-root user).  In above example we change the shell to /bin/csh (C SHell) and to /bin/bash (Bourne-Again Shell).  NOTE: the changes will take effect after you logout and login again.

 

Step to change shell for other user.

 

[root@fedora ~]# chsh -s /bin/csh kambing

Changing shell for kambing.

Shell changed.

 

The example above show, the chsh command is issue by the root operator to change shell for another user in this case is for user kambing.

 

Need help or need more information use:

# info coreutils chsh

# man chsh

# chsh --help

 

Related:

1.  List of Linux Shell.

 

Keywords: change shell, chsh, chsh command, using chsh, login shell, linux shell, change user shell, using linux chsh command, chsh command, changing shell, shell example, change bash shell, change login prompt, linux shell, change fedora core shell.

 

3 comments

13
May

My shell changed

Hullo,
I have a problem with my shell.
I was trying to change the shell using the chsh command in ISOLINUX.
An incorrect shell was entered but till now I can not become root using the sudo su command. It tells me incorrect shell.
What can I do...
Ked Edgar eked290@gmail.com

22
Aug

Hi I have the same

Hi
I have the same problem
I'm using Debian, was trying out zsh. Initially entered a bad name but switched to zsh eventual. Now I switched back to bash but can't access root
When I hit su and password it returns "Cannot execute zsh: No such file or diretory", while apparently I'm using bash.
Can someone help please!

8
Jan

mess with my /bin/bash

Hi;

i just mix /usr/bin/bash and /bin/bash when i change my shell
now i can't be root anymore :(

Exemple:
$ su -
Password:
Cannot execute /usr/bin/bash: No such file or directory

I use Debian 7.

Anyway to restore that ?? :)
thx

aaaaaaaaaaa