1. I want to know which shells have been installed on my machine?
You can view the following two methods:
First:
[Rocrocket @ wupengchong ~] $ CHSH-l
/Bin/sh
/Bin/bash
/Sbin/nologin
/Bin/zsh
Second:
[Rocrocket @ wupengchong ~] $ CAT/etc/shells
/Bin/sh
/Bin/bash
/Sbin/nologin
/Bin/zsh
In fact, CHSH-L is also used to view this file.
2. I want to know which shell I am currently using?
[Rocrocket @ wupengchong ~] $ Echo $ Shell
/Bin/bash
Note that shell must be capitalized. As you can see, the current shell I use is/bin/bash.
3. After zsh is executed, I can check whether the current shell type is still/bin/bash?
Please note that although we have executed zsh, the so-called "Current Shell" is a big environment concept for a logged-on user. We only started a zsh interpreter to execute zsh. Program But it has not changed the big environment. If you want to change the "current shell", you still need to use CHSH.
4. I want to change my shell to zsh!
[Rocrocket @ wupengchong ~] $ CHSH-S/bin/zsh
Changing shell for rocrocket.
Password:
Shell changed.
[Rocrocket @ wupengchong ~] $
Use CHSH and the option-s to modify the logon shell!
You will find that the output is still/bin/bash after executing echo $ shell, because you need to restart your shell to fully invest in zsh.
5. Where has CHSH-s been modified?
Tell you the secret. CHSH-s actually modifies the line corresponding to your user name in the/etc/passwd file. Now let's check:
[Rocrocket @ wupengchong ~] $ CAT/etc/passwd | grep ^ rocrocket
Rocrocket: X: 500: 500: rocrocket, China:/rocrocket/PSB/Home:/bin/zsh
Look! You can find that the last part of the output content has become/bin/zsh! Next time you restart, Linux will read this command to start your shell!
Now, I want to resume normal operation. I will be familiar with/bin/bash when I modify the shell!
[Rocrocket @ wupengchong ~] $ CHSH-S/bin/bash
Changing shell for rocrocket.
Password:
Shell changed.