从Ubuntu系统切换到Mac os系统,常用的命令工具发生了变化,比如brew的命令安装如下。
Last login: Sat Jul 8 15:15:24 on console
mac@MACdeMacBook-Pro-5 ~ % su
Password:
su: Sorry
mac@MACdeMacBook-Pro-5 ~ % sudo
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
[command]
usage: sudo [-AbEHknPS] [-C num] [-D directory] [-g group] [-h host] [-p prompt]
[-R directory] [-T timeout] [-u user] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C num] [-D directory] [-g group] [-h host] [-p prompt]
[-R directory] [-T timeout] [-u user] file ...
mac@MACdeMacBook-Pro-5 ~ % brew install sunnyyoung/repo/wechattweak-cli
zsh: command not found: brew
mac@MACdeMacBook-Pro-5 ~ % brew
zsh: command not found: brew
mac@MACdeMacBook-Pro-5 ~ % $ brew install sunnyyoung/repo/wechattweak-cli
zsh: command not found: $
mac@MACdeMacBook-Pro-5 ~ % brew install
zsh: command not found: brew
mac@MACdeMacBook-Pro-5 ~ % /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
开始执行Homebrew自动安装程序
[cunkai.wang@foxmail.com]
['2023-07-13 15:51:05']['12.1']
https://zhuanlan.zhihu.com/p/111014448
请选择一个下载brew本体的序号,例如中科大,输入1回车。
源有时候不稳定,如果git克隆报错重新运行脚本选择源。
1、中科大下载源
2、清华大学下载源
3、北京外国语大学下载源
4、腾讯下载源
5、阿里巴巴下载源
6、跳过下载brew去配置下载源
请输入序号:
你选择了中国科学技术大学brew本体下载源
!!!此脚本将要删除之前的brew(包括它下载的软件),请自行备份。
->是否现在开始执行脚本(N/Y) Y
--> 脚本开始执行
Mac os设置开机密码方法:
(设置开机密码:在左上角苹果图标->系统偏好设置->用户与群组->更改密码)
(如果提示This incident will be reported. 在用户与群组中查看是否管理员)
==> 通过命令删除之前的brew、创建一个新的Homebrew文件夹
请输入开机密码,输入过程不显示,输入完后回车
Password:
开始执行
-> 创建文件夹 /opt/homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /opt/homebrew
此步骤成功
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /opt/homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown mac /opt/homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /opt/homebrew
git version 2.33.0
下载速度觉得慢可以ctrl+c或control+c重新运行脚本选择下载源
==> 从 https://mirrors.ustc.edu.cn/brew.git 克隆Homebrew基本文件
未发现Git代理(属于正常状态)
Cloning into '/opt/homebrew'...
remote: Enumerating objects: 251501, done.
remote: Total 251501 (delta 0), reused 0 (delta 0), pack-reused 251501
Receiving objects: 100% (251501/251501), 68.59 MiB | 13.55 MiB/s, done.
Resolving deltas: 100% (186168/186168), done.
此步骤成功
--创建Brew所需要的目录
运行代码 ==> The following existing directories will be made group writable:
/opt/homebrew/bin
/opt/homebrew/bin/brew
运行代码 ==> The following existing directories will have their owner set to mac:
/opt/homebrew/bin
/opt/homebrew/bin/brew
运行代码 ==> The following new directories will be created:
/opt/homebrew/etc
/opt/homebrew/include
/opt/homebrew/lib
/opt/homebrew/sbin
/opt/homebrew/share
/opt/homebrew/var
/opt/homebrew/opt
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/var/homebrew
/opt/homebrew/var/homebrew/linked
/opt/homebrew/Cellar
/opt/homebrew/Caskroom
/opt/homebrew/Frameworks
运行代码 ==> /usr/bin/sudo /bin/chmod u+rwx /opt/homebrew/bin /opt/homebrew/bin/brew
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /opt/homebrew/bin /opt/homebrew/bin/brew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown mac /opt/homebrew/bin /opt/homebrew/bin/brew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
运行代码 ==> /usr/bin/sudo /bin/chmod ug=rwx /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
运行代码 ==> /usr/bin/sudo /bin/chmod go-w /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions
运行代码 ==> /usr/bin/sudo /usr/sbin/chown mac /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R mac:admin /opt/homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /Users/mac/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /Users/mac/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R mac /Users/mac/Library/Caches/Homebrew
--依赖目录脚本运行完成
==> 创建brew的替身
brew下载完成。
如果需要Core、Cask、services的话,输入Y继续克隆
不需要的回车跳过:
==> 配置国内镜像源HOMEBREW BOTTLE
此处如果显示Password表示需要再次输入开机密码,输入完后回车
sed: /Users/mac/.zprofile: No such file or directory
有些电脑xcode和git混乱,再运行一次,此处如果有error正常。
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Homebrew已经安装成功,接下来配置国内源。
请选择今后brew install的时候访问那个国内镜像,例如阿里巴巴,输入5回车。
1、中科大国内源
2、清华大学国内源
3、北京外国语大学国内源
4、腾讯国内源
5、阿里巴巴国内源
请输入序号:
你选择了中国科学技术大学国内源
环境变量写入->/Users/mac/.zprofile
此步骤成功
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /opt/homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown mac /opt/homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /opt/homebrew
==> 安装完成,brew版本
Homebrew 4.0.28-63-g1b7f3a7-dirty
Homebrew前期配置成功
电脑系统版本:12.1
==> brew update-reset
==> Fetching /opt/homebrew...
==> Resetting /opt/homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.
Homebrew自动安装程序运行完成
国内地址已经配置完成
桌面的Old_Homebrew文件夹,没有你需要的可以删除。
初步介绍几个brew命令
查看版本:brew -v 更新brew版本:brew update
查找:brew search python(其中python替换为要查找的关键字)
安装:brew install python 安装完成输入 python3 -h 查看
本地软件库列表:brew ls
欢迎右键点击下方地址-打开链接 点个赞吧
https://zhuanlan.zhihu.com/p/111014448
安装成功 但还需要重启终端 或者 运行 source /Users/mac/.zprofile 否则国内地址无法生效
mac@MACdeMacBook-Pro-5 ~ % source /Users/mac/.zprofile
mac@MACdeMacBook-Pro-5 ~ % brew -v
Homebrew 4.0.28-63-g1b7f3a7
mac@MACdeMacBook-Pro-5 ~ % brew search python
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles-portable-ruby/portable-ruby-2.6.10_1.arm64_big_sur.bottle.tar.gz
########################################################################## 100.0%
==> Pouring portable-ruby-2.6.10_1.arm64_big_sur.bottle.tar.gz
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api/formula
# #-=O#- #
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api/cask.jw
##=#=-#
==> Formulae
app-engine-python python-markdown python@3.7
boost-python3 python-tabulate python@3.8
bpython python-tk@3.10 python@3.9
ipython python-tk@3.11 reorder-python-imports
micropython python-tk@3.9 wxpython
ptpython python-toml pythran
python-build python-typing-extensions jython
python-gdbm@3.11 python-yq cython
python-launcher python@3.10
python-lsp-server python@3.11
==> Casks
mysql-connector-python
mac@MACdeMacBook-Pro-5 ~ %
命令安装
运行命令,输入序列号时 直接回车
输入大写字母:Y
输入mac密码,运行脚本
等待安装完成即可
安装成功 但还需要重启终端 或者 运行 source /Users/mac/.zprofile 否则国内地址无法生效
brew -v 验证