Homebrew Introduction and Basic Use

One , What is Homebrew

Homebrew is a software package management tool under the Mac OS platform. It has many useful functions such as installation, uninstallation, update, viewing, and searching. Function. A simple instruction can realize package management without you having to care about various dependencies and file paths, which is very convenient and fast.

Quoting an official sentence: Is it again that the package is missing? Don’t worry, Homebrew is always there. Homebrew-an indispensable package manager for OS X.

2. Homebrew installation

1. Required

  • Intel CPU 1

  • OS X 10.9 or higher 2

  • Xcode command line tool 3

    $ xcode-select --install
    • 1
    • 2

    < p style="margin-top:0px;margin-bottom:1.7em;padding-top:0px;padding-bottom:0px;line-height:27.2px;">

  • Support shell (sh or bash) 4

2. Installation and uninstallation

  • Installation

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    < ul class="pre-numbering" style="margin:0px;padding:6px 0px 40px;list-style:none;line-height:23.8px;border-right-width:1px;border-right-style:solid; border-right-color:rgb(221,221,221);text-align:right;background-colo r:rgb(238,238,238);">

  • 1
  • 2
  • Uninstall< /p>

    $ cd `brew --prefix`$ rm -rf Cellar$ brew prune$ rm `git ls-files`$ rm -r Libraryrm -r Libraryrm span>/Homebrew Library/Aliases Library/Formula Library/Contributions$ rm -rf .git$ rm -rf ~/Library/Caches/Homebrew
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
  • Three, Homebrew basic use

    • Install any package

      $ brew install 
      • 1
      • 2

      Example: install wget

      $ brew install wget
      • 1
      • 2
    • Uninstall any package

      $ brew uninstall 
      • 1
      • 2

      Example: uninstall git

      $ brew uninstall git

      • 1
      • 2
    • Query Available packages

      $ brew search 
      • 1
      • 2
    • View the list of installed packages

      $ brew list
      • 1
      • 2
    • View any package information

      $ brew info 
      • 1
      • 2
    • Update Homebrew

      $ brew update
      • 1
      • 2
    • View Homebrew version

      $ brew -v
      • 1
      • 2
    • Homebrew help information

      $ brew -h
      • 1
      • 2

      Output example:

      Example usage: brew search [TEXT|/REGEX/] brew (info|home|options) [FORMULA...]  brew install FORMULA... brew update brew upgrade [FORMULA...] brew uninstall FORMULA... brew list [FORMULA...]Troubleshooting: brew config brew doctor brew install -vd FORMULABrewing: brew create [URL [--no-fetch]] brew edit [FORMULA...] https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Formula-Cookbook.mdFurther help: man brew brew help< span class="hljs-sqbracket" style="margin:0px;padding:0px;color:rgb(155,133,157);"> [COMMAND] brew home
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • li>

      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23

    Fourth, pay attention

    After Mac OS X 10.11, file reading and writing in system directories such as /usr/local/ requires system root privileges. If the installation path is not specified in the previous Homebrew installation, it will be installed by default in these system root users. Under the permission directory, some commands need to be executed by adding a sudo prefix. For example, upgrading Homebrew requires:

    $ sudo brew update
    • 1
    • 2

    If you don’t want to use the sudo command every time, you have two options:

    1. Root user authorization for reading and writing files in the /usr/local directory

      $ sudo chown -R $USER /usr/local
      • 1
      • 2

      Example:

      $ sudo chown -R wentianen /usr/local
      • 1
      • 2
    2. (recommended) When installing Homebrew, specify the installation path, and install it directly in a directory that can be read and written freely without the authorization of the system root user Down

       -e "$(curl -fsSL https://raw.githubusercontent.com /Homebrew/install/master/install)"
      • 1
      • 2

    Reference

    • Homebrew official recommended tutorial
    • install and uninstall homebrew
    • Official source code library

    Annotation


    1. The official description is that not all instructions have CPU or operating system requirements , If the system requirements are not met, guessing will encounter problems. In addition, you can check: Interesting Taps & Branches. ↩
    2. The official recommended system version is 10.9 or higher. 10.5-10.8 The official will try our best to support. For 10.4 and 10.5, see Tigerbrew. ↩
    3. Most commands require a compiler. A few need to install a full Xcode. You can install Xcode, or CLT, or both; Homebrew supports three configurations. Downloading Xcode in older operating systems may require an Apple developer account. You can register here for free. ↩
    4. The one-line installation method can be viewed brew.sh, but a compatible shell ( Such as bash or zsh). It should be noted that fish, tcsh, and csh will not be available. ↩


    1. It is officially stated that not all instructions have CPU or operating system requirements. If the system requirements are not met, it is guessed that there will be problems. In addition, you can check: Interesting Taps & Branches. ↩
    2. The official recommended system version is 10.9 or higher. 10.5-10.8 The official will try our best to support. For 10.4 and 10.5, see Tigerbrew. ↩
    3. Most commands require a compiler. A few need to install a full Xcode. You can install Xcode, or CLT, or both; Homebrew supports three configurations. Downloading Xcode in older operating systems may require an Apple developer account. You can register here for free. ↩
    4. The one-line installation method can be viewed brew.sh, but a compatible shell ( Such as bash or zsh). It should be noted that fish, tcsh, and csh will not be available. ↩

    Leave a Comment

    Your email address will not be published.