卸载homebrew_Homebrew基础教程

本文介绍了Homebrew,它是MacOSX系统下的包管理工具,用于安装系统未预装但用户需要的软件。文章详细阐述了如何解决安装过程中遇到的问题,如通过修改hosts文件来解决连接错误,以及如何使用阿里云镜像加速软件包下载。此外,还提供了Homebrew的基础命令语法,包括安装、更新、卸载和清理软件包的方法。最后,讲述了如何恢复Homebrew的默认配置。
摘要由CSDN通过智能技术生成
025ff8093d87a6e4191db74d085c75d5.png

介绍

经常使用Linux系统的人们,应该非常熟悉使用yum或apt-get来管理软件包。苹果Mac OSX既拥有Windows一样易用的图形操作界面,也拥有Linux强大的命令行操作。


Homebrew是Mac OSX下使用的包管理工具,用来安装OSX系统中没有预装但是你需要的东西。它将软件包安装到独立目录,并在/usr/local目录下创建软链接。

安装Homebrew

安装

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

解决 “curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused” 错误
前往www.ipaddress.com网站查询raw.githubusercontent.com主机的真实IP

9a083e08755862d3909152b94f93cf51.png


修改/etc/hosts文件,添加以下内容:

199.232.68.133 raw.githubusercontent.com

使用阿里云镜像加速软件包下载

# 替换brew.gitcd "$(brew --repo)"git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git# 替换homebrew-core.gitgit clone git://mirrors.ustc.edu.cn/homebrew-core.git/ "$(brew --repo)/Library/Taps/homebrew/homebrew-core" --depth=1cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git# 生效brew update# 替换homebrew-bottlestouch ~/.bash_profileif [ -f ~/.bash_profile ];thenecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profilesource ~/.bash_profilefitouch ~/.zshrcif [ -f ~/.zshrc ];thenecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrcsource ~/.zshrcfi

使用Homebrew

基础语法

# 查看版本号brew --version# 执行子命令brew 子命令 [--verbose|-v] [选项]

安装软件包

brew install 软件包名# 例如:安装wgetbrew install wget

更新软件包

brew upgrade 软件包名# 例如: 更新wgetbrew upgrade wget

卸载已安装的软件包

brew uninstall 软件包名# 例如:卸载wgetbrew uninstall wget

清理旧版本软件包

brew cleanup

列出所有已安装的软件包

brew list

获取已安装软件包详情

brew info 软件包# 例如:获取wget详情brew info wget

查询可用软件包

# 按文本查询brew search 软件包名# 正则表达式查询brew search /正则表达式/# 例如:查询PHP可用包brew search php

显示软件包依赖列表

brew deps 软件包名# 例如:显示PHP的依赖brew deps php

检测Homebrew是否有问题

brew doctor

更新Homebrew

brew update

恢复默认配置

出于某些场景, 可能需要回退到默认配置, 你可以通过下述方式回退到默认配置。执行命令

# 重置brew.git:$ cd "$(brew --repo)"$ git remote set-url origin https://github.com/Homebrew/brew.git# 重置homebrew-core.git:$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git

从以下文件中删掉 HOMEBREW_BOTTLE_DOMAIN 环境变量

~/.bash_profile

~/.zshrc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值