Shell – not able to change the shell with the chsh command

command lineshellUbuntu

I learned a new command, at least I thought, because this command : chsh, does not behave like described.

It was described to work like this:

  1. cat /etc/shells to know, which shells are installed,so you can choose among them.
  2. do echo $SHELL to know, which shell you are using.
  3. choose one of the shells and type chsh -s /path/to/shell
  4. enter password and verify with echo $SHELL, that you are in a new shell.

I have done this and I got no error message when entering the password, but I was still in the same shell.

% echo $SHELL
/bin/bash
% cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
% chsh -s /bin/sh
Password: 
% echo $SHELL
/bin/bash

Best Answer

Log out and log in again.

The chsh command will update the /etc/passwd file, but it does not change the current shell nor the value of the $SHELL variable in the current shell (it has no way of doing that). This is the reason you need to log in again; you have to start a new login session for a change to take effect.

Related Question