Three golden questions: what, why, how
The manager of missing software packages for macOS (or Linux) - the documentation on the Homebrew official website will tell us in detail.
1: Check whether Homebrew is installed and downloaded:
Enter the command line brew in the terminal
(1) When the following picture appears, it means that the Mac is not installed. If necessary, you need to download Homebrew.
(2) When the following picture appears, it means that the Mac already has Homebrew and can be used normally.
Two: Download Homebrew
Enter The Missing Package Manager for macOS (or Linux) — Homebrew and copy the following command to the terminal.
It may not succeed on the first try, and an error code may appear.
Error example : LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443
Solution: This error is because the installation source is in a foreign country and the download is very slow. Just like npm, you only need to switch the domestic source and copy the following code to the terminal.
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Complete solution: Because GitHub's raw.githubusercontent.com
domain name resolution is contaminated, hosts
this problem can be solved through modification.
Step 1: Check the real IP of raw.githubusercontent.com from The Best IP Address, Email and Networking Tools - IPAddress.com website. 4 IPV4 and 4IPCV6 addresses:
Step 2: Add these IPs to local hosts, use Vi editor, modify hosts
sudo vim /etc/hosts
iOpen editing
# Homebrew Start
xxx.xxx.xxx.xxx raw.githubsercontent.com
xxx.xxx.xxx.xxx raw.githubsercontent.com
xxx.xxx.xxx.xxx raw.githubsercontent.com
xxx.xxx.xxx.xxx raw.githubsercontent.com
xxxx:xxxx:xxxx:xxx raw.githubsercontent.com
xxxx:xxxx:xxxx:xxx raw.githubsercontent.com
xxxx:xxxx:xxxx:xxx raw.githubsercontent.com
xxxx:xxxx:xxxx:xxx raw.githubsercontent.com
# Homebrew End
esc to exit editing, :wq to force save and exit.
Step 3: Finally, use the domestic image to install.
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Three: Common commands of Homebrew
View brew’s help brew –help
Install software brew install git
Uninstall software brew uninstall git (or brew remove git)
Search software brew search git
Display the list of installed software brew list
Update software, update all Formula directories, and mark * with an * for software that has been installed on the machine and has been updated. brew update
Update a specific software brew upgrade git
View software information brew [info | home] [FORMULA...]
Deleting programs is the same as upgrading, deleting individual software and deleting old versions of all programs.
brew cleanup git brew cleanup
Check which installed programs need updating brew outdated
Search brew search MySQL
Querying brew info mysql mainly depends on specific information, such as the current version, dependencies, post-installation precautions, etc.
Update brew update This will update Homebrew itself and make the next two operations meaningful
Check for obsolescence (whether there is a new version) brew outdated This will list all installed software that can be upgraded
Upgrade brew upgrade to upgrade all software that can be upgraded
Clean up brew cleanup to clean up unnecessary versions and installation package cache
Other Homebrew commands
brew list lists installed software
brew update update Homebrew
brew home * Open with browser
brew info * displays software content information
brew deps * show package dependencies
brew server * Start the web server. You can access http://localhost:4567/ through the browser to manage packages on the same web page.
brew -h brew help