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:

  1. Check your current shell:

    • Open Terminal and type:
      1
      echo $SHELL
    • This will show you the path to your current login shell.
  2. 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.
➜  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
  1. 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
2
3
4
5
➜  openwrt-24.10.0-rc5 chsh -s /bin/bash
Changing shell for mvpbang.
Password for mvpbang:
➜ openwrt-24.10.0-rc5 echo $SHELL
/bin/zsh

notice: must exit all terminal,open new terminal to effective

64ffdb6354a0fe2c607295a861ab0403.png