这里的 brew
是指 Homebrew ,是 MacOS 上一个免费的开源软件包管理器,相似于 Linux 中的 yum
(RedHat系列) 和 apt-get
(Debian系列)命令。
php
安装 Apple 没有预装但 你须要的东西。
html
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
在终端执行上面的代码便可轻松完成安装。
Homebrew 会将软件包安装到独立目录,并将其文件软连接至 /usr/local 。mysql
$ cd /usr/local $ find Cellar Cellar/wget/1.16.1 Cellar/wget/1.16.1/bin/wget Cellar/wget/1.16.1/share/man/man1/wget.1 $ ls -l bin bin/wget -> ../Cellar/wget/1.16.1/bin/wget
Homebrew 会把安装的软件统一放在 /usr/local/Cellar 目录,软件的安装目录也会连接到 /usr/local/opt 目录中,默认全部软件的 bin 目录执行文件都会连接到 /usr/local/bin 目录中。
git
$ brew -v # 安装完成后能够查看版本 $ brew --help # 简洁命令帮助 $ man brew # 完整命令帮助 $ brew search git # 搜索软件包 $ brew info git # 查看软件包信息 $ brew home git # 访问软件包官方站(用浏览器打开) $ brew install git # 安装软件包(这里是示例安装Git版本控制) $ brew uninstall git # 卸载软件包 $ brew list # 显示已经安装的全部软件包 $ brew list --versions # 查看你安装过的包列表(包括版本号) $ brew update # 同步远程最新更新状况,对本机已经安装并有更新的软件用*标明 $ brew outdated # 查看已安装的哪些软件包须要更新 $ brew upgrade git # 更新单个软件包 $ brew deps php # 显示包依赖 $ brew cleanup # 清理全部已安装软件包的历史老版本 $ brew cleanup git # 清理单个已安装软件包的历史版本 $ brew cleanup -n # 查看哪些软件包要被清除
$ brew services run mysql # 开启 MySQL 服务 $ brew services start mysql # 开启 MySQL 服务,并注册开机自启 $ brew services stop mysql # 中止 MySQL 服务,并取消开机自启 $ brew services restart mysql # 重启 MySQL 服务,并注册开机自启(相似 stop + start 两个命令) $ brew services list # 查看使用brew安装的服务列表 $ brew services cleanup # 清理无效的 plist 文件删除(已卸载应用的无用的配置)
HomeBrew是经过源码的方式来安装软件,可是有时候咱们安装的软件是GUI程序应用宝(.dmg/.pkg),这个时候咱们就不能使用HomeBrew了。(本人比较少用此方式安装软件,就不在此展开详细说明了,有兴趣了解的同窗自行 Google)github
$ brew install brew-cask-completion $ brew cask # 验证是否完成安装 Homebrew Cask provides a friendly CLI workflow for the administration of macOS applications distributed as binaries. Commands: --cache display the file used to cache the Cask audit verifies installability of Casks cat dump raw source of the given Cask to the standard output create creates the given Cask and opens it in an editor doctor checks for configuration issues edit edits the given Cask fetch downloads remote application files to local cache home opens the homepage of the given Cask info displays information about the given Cask install installs the given Cask list with no args, lists installed Casks; given installed Casks, lists staged files outdated list the outdated installed Casks reinstall reinstalls the given Cask style checks Cask style using RuboCop uninstall uninstalls the given Cask upgrade upgrades all outdated casks zap zaps all files associated with the given Cask See also "man brew-cask"
Homebrew cask 经常使用命令和 Homebrew 的区别不是很大,参考Homebrew 的就好了。
Homebrew cask 没有提供更新软件的命令,因此咱们更新软件得先卸载再安装
命令以下sql
$ brew cask uninstall APP && brew cask install APP
P.S.: Homebrew官网地址 点击跳转。