Bash shell lab : change of shell and output

Hello Team ,

In lab linux bash prompt the task in which it is expected to change the shell type this is what I found .

Q. Change the SHELL for Bob from bash to Bourne Shell
Bob’s password is caleston123

Hint : use the chsh command

Output

bob@caleston-lp10:~$ echo $SHELL
/bin/bash
bob@caleston-lp10:~$
bob@caleston-lp10:~$ chsh
Password:
Changing the login shell for bob
Enter the new value, or press ENTER for the default
Login Shell [/bin/dash]: /bin/sh
bob@caleston-lp10:~$
bob@caleston-lp10:~$ echo $SHELL
/bin/bash
bob@caleston-lp10:~$

After doing this the check passes .

When we do $echo $SHELL before and after this no change is being observed in the output. How come the check passes and what change has been implemented then ?

As it appears the shell is still the same which was before the change using chsh .

with best regards
Pradeep Nehe
[email protected]

To know the current shell do echo $SHELL and to change the particular user shell by command then do
sudo usermod -s /bin/sh bob . If before allocated to bash after this user modification it will change to sh shell.
or
If you want to do by command line and wanna make it permanent then entry user’s home directory bash profile.

Hello Tej,

I tried to change the shell but the default shell is not changing to /bin/sh even though I am in bob’s home directory.


.

Also on 2nd attempt, I am getting this error as shown in the image.


.

Hi @shoaibshakilshaikh

When you run chsh for a user, it does not change the shell immediately. It is from next time the user logs in.

All the chsh command does is update the value of the user’s shell in /etc/passwd file.

To validate immediately, you must re-login as bob

bob@caleston-lp10:~$ sudo chsh -s /bin/sh bob
[sudo] password for bob: 
bob@caleston-lp10:~$ echo $SHELL
/bin/bash
bob@caleston-lp10:~$ sudo -i
root@caleston-lp10:~# su - bob
$ echo $SHELL 
/bin/sh
$ 

To get back to the original bob login, enter exit twice

Hi I have the same problem.

<>
sudo chsh -s /bin/sh bob
Password:
chsh: PAM: Authentication failure
<>

This does not change the /etc/passwd file

I did try the process suggested in your response here by changing user and checking if chsh works and the error remained.

However I edited the /etc/passwd in vi to pass the check. request you to have a look

I am also getting the same error