如何在macOS Catalina上将默认Shell更改为Bash

Terminal window on a macOS Catalina desktop.

With macOS Catalina, Apple is now using Zsh as the default shell. We love Zsh, but the trusty old Bash shell is still included with macOS, and you can quickly switch back to Bash if you prefer.

借助macOS Catalina ,Apple 现在使用 Zsh作为默认外壳。 我们喜欢Zsh ,但是可信任的旧Bash shell仍包含在macOS中,并且您可以根据需要快速切换回Bash。

Zsh is only the default shell on newly created user accounts, so any existing accounts you have on an upgraded  Mac will still use Bash by default unless you change it. Each user account has its own default shell preference.

Zsh只是新创建的用户帐户上的默认外壳程序,因此,默认情况下,除非您进行更改,否则在升级的Mac上拥有的所有现有帐户仍将使用Bash。 每个用户帐户都有其自己的默认外壳程序首选项。

从航站楼 (From the Terminal)

To change a user account’s default shell on macOS, simply run the chsh -s (change shell) command in a Terminal window.

要在macOS上更改用户帐户的默认外壳,只需在“终端”窗口中运行chsh -s (更改外壳)命令。

Change the default shell to Bash by running the following command:

通过运行以下命令将默认Shell更改为Bash:

chsh -s /bin/bash

You’ll have to enter your user account’s password. Finally, close the Terminal window and reopen it. You’ll be using Bash instead of Zsh.

您必须输入用户帐户的密码。 最后,关闭“终端”窗口,然后重新打开。 您将使用Bash而不是Zsh。

Changing the default shell to Bash on macOS Catalina.

Change the default shell back to Zsh by running this command:

通过运行以下命令,将默认shell更改回Zsh:

chsh -s /bin/zsh

Enter your password when prompted. After you close the terminal window and reopen it, you’ll be using Zsh.

出现提示时输入密码。 关闭终端窗口并重新打开它之后,您将使用Zsh。

Changing the default shell to Zsh on macOS Catalina.

You can see a list of included shells you can select by running the following command:

您可以通过运行以下命令来查看可以选择的包含外壳的列表:

cat /etc/shells
Listing available shells in macOS Catalina's terminal.

从系统偏好设置 (From System Preferences)

You can also change this option graphically from System Preferences if you prefer.

如果愿意,还可以从“系统偏好设置”以图形方式更改此选项。

Head to System Preferences > Users & Groups on your Mac. Click the lock icon and enter your password. Hold the Ctrl key, click your user account’s name in the left pane, and select “Advanced Options.”

转到Mac上的“系统偏好设置”>“用户和组”。 单击锁定图标,然后输入密码。 按住Ctrl键,在左窗格中单击您的用户帐户名称,然后选择“高级选项”。

Opening Advanced Options in Users & Groups on macOS.

Click the “Login Shell” dropdown box and select “/bin/bash” to use Bash as your default shell or “/bin/zsh” to use Zsh as your default shell. Click “OK” to save your changes.

单击“登录Shell”下拉框,然后选择“ / bin / bash”将Bash用作默认外壳,或选择“ / bin / zsh”将Zsh用作默认外壳。 单击“确定”保存更改。

Changing the default login shell graphically in macOS Catalina.

macOS上的Bash仍然过时 (Bash on macOS Is Still Outdated)

Note that the version of Bash (Bourne Again SHell) included with macOS is still pretty outdated, however. If you run bash --version , you’ll see that Catalina includes Bash 3.2.57 when Bash 5.0 is the latest version. Newer versions are licensed under the GPLv3 license, while Apple still distributes a version licensed under GPLv2.

请注意,macOS随附的Bash(Bourne Again SHell)版本仍然相当过时。 如果运行bash --version ,则当Bash 5.0是最新版本时,您会看到Catalina包括Bash 3.2.57。 较新的版本已获得GPLv3许可,而Apple仍在分发已获得GPLv2许可的版本。

In contrast, the version of Zsh (Z shell) included with macOS (check with zsh --version ), is Zsh 5.7.2, which is the latest version at the time of Catalina’s release.

相反,macOS附带的Zsh(Z Shell)版本(请使用zsh --version检查)为Zsh 5.7.2,这是Catalina发行时的最新版本。

Viewing the versions of Bash and Zsh on macOS Catalina.

If you want the latest version of Bash, you can install it yourself via Homebrew.

如果您想要最新版本的Bash,可以通过Homebrew自己安装

翻译自: https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值