You can run the CHSH command to change the shell used during login. If no parameter or user name is specified, CHSH is set in reply mode.

Command syntax

CHSH [option][parameter]

Command options

-s<shell name > or --shell<shell name > : Changes the system's default shell environment. ; -l or --list-shells: Lists the shells available in the system. -u or --help: online help; -v or -version: displays the version information.Copy the code

The command parameter

User name: The user who wants to change the default shell.

Two ways to see which shells are installed on your system

The first:

> chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/bin/zsh
Copy the code

The second:

> cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/zsh
Copy the code

In fact, chsh-L is also to view this file.

View the shell currently in use:

> echo $SHELL
/bin/bash
Copy the code

Note that the SHELL must be capitalized. As you can see, the shell currently used is /bin/bash

Put myshelltozsh

> chsh -s /bin/zsh
Changing shell for rumenz.
Password:
Shell changed.
Copy the code

Use CHSH with the -s option to change the login shell! You’ll notice that you still get /bin/bash after echo $SHELL because you need to reboot your SHELL to fully embrace ZSH. CHSH -s changes the line in /etc/passwd that corresponds to your user name. Now check it out:

> cat /etc/passwd|grep ^rumenz
rumenz:x:1001:1002::/home/rumenz:/bin/zsh
Copy the code

You can see that the last part of the output has changed to /bin/zsh. The next time you reboot, Linux will read this command to start the shell!

theshellChange back to/bin/bash

> chsh -s /bin/bash
Changing shell for rumenz.
Password:
Shell changed.
Copy the code

Original link :rumenz.com/rumenbiji/l… Wechat official account: entry station