mac chsh切换shell
chsh
(change shell) is a command on macOS (and other Unix-like systems) that allows you to change the login shell for your user account. Here’s how you can use chsh
on a Mac:
env
- macos-15.2
chsh help
➜ openwrt-24.10.0-rc5 chsh -h
chsh: illegal option -- h
usage: chpass [-l location] [-u authname] [-s shell] [user]
Basic Usage:
Check your current shell:
- Open Terminal and type:
1
echo $SHELL
- This will show you the path to your current login shell.
- Open Terminal and type:
List available shells:
- To see a list of shells that are configured on your system:
1
cat /etc/shells
- This file lists all the shell programs that can be used as login shells on your system.
- To see a list of shells that are configured on your system:
➜ openwrt-24.10.0-rc5 cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
- Change your shell:
To change your login shell, use:
1
chsh -s /path/to/shell
For example, to switch from bash to zsh (which became the default in macOS Catalina), you would use:
1
chsh -s /bin/zsh
You will be prompted to enter your password to make this change.
1 | ➜ openwrt-24.10.0-rc5 chsh -s /bin/bash |
notice: must exit all terminal,open new terminal to effective