Mac 升级bash 到4或者5版本

lookback MacOS评论1字数 1794阅读模式
[lookback@LookBack-MBP ~]$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.
[lookback@LookBack-MBP ~]$ 
# 安装brew
[lookback@LookBack-MBP ~]$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 安装bash
[lookback@LookBack-MBP ~]$ brew install bash
#替换bash
[lookback@LookBack-MBP ~]$ echo $(brew --prefix)/bin/bash | sudo tee -a /private/etc/shells
/usr/local/bin/bash
[lookback@LookBack-MBP ~]$ cat /private/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
/usr/local/bin/bash
#最后用chpass命令来更新用户的shell,下面我以lookback用户为例
[lookback@LookBack-MBP ~]$ sudo chpass -s /usr/local/bin/bash lookback

1. 验证 通过bash和sh命令查看版本:

[lookback@LookBack-MBP ~]$ bash --version
GNU bash,版本 4.4.23(1)-release (x86_64-apple-darwin17.5.0)
Copyright (C) 2016 Free Software Foundation, Inc.
许可证 GPLv3+: GNU GPL 许可证第三版或者更新版本 <http://gnu.org/licenses/gpl.html>

本软件是自由软件,您可以自由地更改和重新发布。
在法律许可的情况下特此明示,本软件不提供任何担保。
[lookback@LookBack-MBP ~]$ 
[lookback@LookBack-iMAC-10.15.7 ~]$ bash --version
GNU bash, version 5.0.18(1)-release (x86_64-apple-darwin19.6.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[lookback@LookBack-iMAC-10.15.7 ~]$ 
[lookback@LookBack-iMAC-10.15.7 ~]$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin21.1.0)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

MacOS最后更新:2023-4-2
  • 本文由 发表于 2018年10月4日 00:43:49
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
评论  0  访客  0
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定