– Quảng cáo –
Homebrew là một phần mềm quản lý gói để cài đặt các phần mềm khác nhau trên macOS, tuy nhiên, chúng tôi cũng có thể sử dụng nguồn mở này Bia trên Windows Các hệ điều hành WSL và Linux như Debian, Ubuntu, Linux Mint, Fedora, CentOS, RedHat và nhiều hơn nữa Homebrew là công cụ quản lý gói tốt nhất trên macOS. Trước đó, nó được gọi là Linuxbrew khi chạy trên Linux hoặc WSL.
Cài đặt HomeBrew trên Linux hoặc WSL
Nó cài đặt gói vào một thư mục riêng và liên kết các tệp của nó với / usr / local. Để đơn giản hóa, giống như chúng ta có apt và yum cho Linux để cài đặt các gói khác nhau; theo cách tương tự, Homebrew sẽ cài đặt và quản lý các gói phần mềm theo cách thống nhất cùng với các phụ thuộc cần thiết của các gói, mà không phải lo lắng về vị trí lưu trữ, v.v.
Note: Để sử dụng nó trên Windows hệ thống con cho Linux trước tiên thiết lập nó bằng hướng dẫn Ubuntu WSL này.
Bươc 1: Mở Terminal và chạy lệnh cập nhật hệ thống:
Theo bản phân phối Linux của bạn trên Máy tính để bàn hoặc máy chủ chạy lệnh cập nhật hệ thống, ở đây chúng tôi sẽ cho bạn biết những cái phổ biến nhất.
Các hệ thống dựa trên Ubuntu và Debian:
sudo apt update
Dựa trên RedHat hoặc CentOS:
sudo yum update
Bươc 2: Cài đặt phụ thuộc bia
Để thiết lập Brew, chúng ta cần có những thứ sau đây trên hệ thống của mình- GCC, Glibc và CPU 64-bit x86_64. Tôi chắc chắn rằng bạn đã có CPU 64 bit phổ biến hiện nay, đối với những thứ còn lại sử dụng các lệnh dưới đây theo hệ thống của bạn.
Đối với Debian, Linux Mint, Ubuntu hoặc hệ điều hành tương tự khác
sudo apt-get install build-Essential curl file git
Dành cho RedHat, Fedora, CentOS hoặc các loại HĐH Linux khác
sudo yum groupinstall 'Công cụ phát triển'sudo yum cài đặt tệp curl gitsudo yum cài đặt libxcrypt-compat
Bươc 3: Lệnh tải xuống và cài đặt HomeBrew
Bây giờ, chỉ cần sao chép và dán lệnh được đưa ra dưới đây sẽ tải xuống tệp tập lệnh chính cần thiết để thiết lập brew trên Linux hoặc WSL.
sh -c "$ (curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
Bươc 4: Thêm Homebrew vào hệ thống của bạn
Để chạy lệnh brew của trình quản lý gói này từ bất kỳ đâu trong thiết bị đầu cuối bất kể thư mục chúng ta đang ở đâu, chúng ta phải nói với hệ thống của chúng ta về nó bằng cách thêm nó vào thùng. Chạy từng lệnh sau trên hệ thống Linux của bạn từng cái một.
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.profile
Ví dụ để sử dụng lệnh Brew trên Linux hoặc Windows hệ thống con cho Linux
Vì vậy, bây giờ trình quản lý gói đã có trên hệ thống của chúng tôi, ví dụ, hãy thử cài đặt một số gói git hoặc trăn.
Đến cài đặt git bằng bia, lệnh sẽ như thế này:
brew install git
Đối với Python:
brew install python
Đầu ra cho lệnh git ở trên:
h2s@DESKTOP-9OOKS69:~$ brew install git Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 Toque (homebrew/cask). No changes to formulae. ==> Installing dependencies for git: ncurses, gettext, bzip2, zlib, pcre2, [email protected], curl, libbsd and expat ==> Installing git dependency: ncurses ==> Downloading https://linuxbrew.bintray.com/bottles/ncurses-6.1_1.x86_64_linux.bottle.tar.gz Already downloaded: /home/h2s/.cache/Homebrew/downloads/d4ea71074c7ccba18fb75489ae89e777e360d9621d19447f0336e1a02908c632--ncurses-6.1_1.x86_64_linux.bottle.tar.gz ==> Pouring ncurses-6.1_1.x86_64_linux.bottle.tar.gz 🍺 /home/linuxbrew/.linuxbrew/Cellar/ncurses/6.1_1: 3,860 files, 9.0MB ==> Installing git dependency: gettext ==> Downloading https://linuxbrew.bintray.com/bottles/gettext-0.20.1_1.x86_64_linux.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/72/724879481408d819c1b49787e14f95657fb1c6607b51c0a943773b773298e349?__gd ######################################################################## 100.0% ==> Pouring gettext-0.20.1_1.x86_64_linux.bottle.tar.gz 🍺 /home/linuxbrew/.linuxbrew/Cellar/gettext/0.20.1_1: 1,892 files, 20.2MB ==> Installing git dependency: bzip2 ==> Downloading https://linuxbrew.bintray.com/bottles/bzip2-1.0.8.x86_64_linux.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/e5/e5fce257b9fee119d28d0e7f7dac9332bd26b248fe35d983ba85104243e4bc2e?__gd ######################################################################## 100.0% ==> Pouring bzip2-1.0.8.x86_64_linux.bottle.tar.gz 🍺 /home/linuxbrew/.linuxbrew/Cellar/bzip2/1.0.8: 30 files, 521.3KB ==> Installing git dependency: zlib ==> Downloading https://linuxbrew.bintray.com/bottles/zlib-1.2.11.x86_64_linux.bottle.tar.gz ######################################################################## 100.0% ==> Pouring zlib-1.2.11.x86_64_linux.bottle.tar.gz 🍺 /home/linuxbrew/.linuxbrew/Cellar/zlib/1.2.11: 12 files, 396KB ==> Installing git dependency: pcre2 ==> Downloading https://linuxbrew.bintray.com/bottles/pcre2-10.34.x86_64_linux.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/49/497ae0c6e7f7e8bb9dd7555cf8a6aec0dd6a84b052751741fe8fb55ec70799db?__gd ######################################################################## 100.0% ==> Pouring pcre2-10.34.x86_64_linux.bottle.tar.gz 🍺 /home/linuxbrew/.linuxbrew/Cellar/pcre2/10.34: 235 files, 6.6MB ==> Installing git dependency: [email protected] ==> Downloading https://linuxbrew.bintray.com/bottles/[email protected]_1.x86_64_linux.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/01/010a4e5257eb685ac700f495208bed1e05155663f8083ab6ab2e4a91ef69c1cd?__gd ######################################################################## 100.0% ==> Pouring [email protected]_1.x86_64_linux.bottle.tar.gz ==> Downloading https://curl.haxx.se/ca/cacert-2019-10-16.pem ######################################################################## 100.0% ==> Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /home/linuxbrew/.linuxbrew/etc/[email protected]/certs and run /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/c_rehash [email protected] is keg-only, which means it was not symlinked into /home/linuxbrew/.linuxbrew, because this is an alternate version of another formula. If you need to have [email protected] first in your PATH run: echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile For compilers to find [email protected] you may need to set: export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/[email protected]/lib" export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/[email protected]/include" For pkg-config to find [email protected] you may need to set: export PKG_CONFIG_PATH="/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/pkgconfig" ==> Summary 🍺 /home/linuxbrew/.linuxbrew/Cellar/[email protected]/1.1.1d_1: 7,985 files, 20.8MB ==> Installing git dependency: curl ==> Downloading https://linuxbrew.bintray.com/bottles/curl-7.68.0.x86_64_linux.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/90/90f8495c253eccee411204ac859a90a99c145ffd13198b277e7304a2122f6ede?__gd ######################################################################## 100.0% ==> Pouring curl-7.68.0.x86_64_linux.bottle.tar.gz 🍺 /home/linuxbrew/.linuxbrew/Cellar/curl/7.68.0: 460 files, 3.7MB ==> Installing git dependency: libbsd ==> Downloading https://linuxbrew.bintray.com/bottles/libbsd-0.10.0.x86_64_linux.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/68/68ac94cf2b7530dcb4b678402d37d7fce907cd628821d5b7549b644146947951?__gd ######################################################################## 100.0% ==> Pouring libbsd-0.10.0.x86_64_linux.bottle.tar.gz 🍺 /home/linuxbrew/.linuxbrew/Cellar/libbsd/0.10.0: 261 files, 897.2KB ==> Installing git dependency: expat ==> Downloading https://linuxbrew.bintray.com/bottles/expat-2.2.9.x86_64_linux.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/5d/5d0281695b1febb80cb2dc3c64d61e586ebe1870202d4f763650ab127d2b9f01?__gd ######################################################################## 100.0% ==> Pouring expat-2.2.9.x86_64_linux.bottle.tar.gz 🍺 /home/linuxbrew/.linuxbrew/Cellar/expat/2.2.9: 18 files, 711.8KB ==> Installing git ==> Downloading https://linuxbrew.bintray.com/bottles/git-2.25.0_1.x86_64_linux.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/bf/bf6ec84bf7db2334df764e74dd146e5a4b3ac8b0d7271723989f1ddc3d2b7b2b?__gd ######################################################################## 100.0% ==> Pouring git-2.25.0_1.x86_64_linux.bottle.tar.gz ==> Caveats The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula. <--more--->
Bây giờ để sử dụng git chỉ cần gõ Git cùng với các tập tin bạn muốn sao chép hoặc cập nhật.
Xem thông tin phần mềm
Để biết thông tin của các gói đã cài đặt bằng homebrew, chỉ cần sử dụng gói này:
brew info
Đối với ví dụ trên, chúng tôi đã cài đặt git & python, do đó để biết về phiên bản của nó và các thông tin khác, chúng tôi sẽ sử dụng:
brew info git
Đầu ra sẽ như thế này:
h2s@DESKTOP-9OOKS69:~$ brew info git git: stable 2.25.0 (bottled), HEAD Distributed revision control system https://git-scm.com /home/linuxbrew/.linuxbrew/Cellar/git/2.25.0_1 (1,446 files, 50MB) * Poured from bottle on 2020-02-05 at 15:57:39 From: https://github.com/Homebrew/linuxbrew-core/blob/master/Formula/git.rb ==> Dependencies Required: gettext ✔, pcre2 ✔, [email protected] ✔, curl ✔, expat ✔, zlib ✔ ==> Options --HEAD Install HEAD version ==> Caveats The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula. Bash completion has been installed to: /home/linuxbrew/.linuxbrew/etc/bash_completion.d Emacs Lisp files have been installed to: /home/linuxbrew/.linuxbrew/share/emacs/site-lisp/git ==> Analytics install: 4,712 (30 days), 12,008 (90 days), 41,210 (365 days) install-on-request: 4,675 (30 days), 11,930 (90 days), 40,989 (365 days) build-error: 0 (30 days)
Xem phần mềm đã cài đặt
Nếu tại bất kỳ thời điểm nào, ai đó muốn biết phần mềm hoặc gói nào đã được cài đặt trên hệ thống bằng trình quản lý gói này, hãy sử dụng lệnh:
brew list
Gỡ cài đặt phần mềm
Để loại bỏ bất kỳ gói cài đặt, sử dụng gói này:
brew uninstall
Ví dụ, ở trên chúng tôi đã thiết lập git, do đó để loại bỏ tương tự, lệnh sẽ là
brew uninstall git
Nó không chỉ giới hạn ở Git, bạn có thể cài đặt Nginx và rất nhiều người khác. Tất cả các gói nhị phân của Homebrew được gọi là chai được xây dựng trên Hành động GitHub và được lưu trữ bởi Bintray.
Cách gỡ cài đặt Homebrew khỏi hệ thống
Nếu vì bất kỳ lý do nào bạn muốn xóa homebrew khỏi hệ thống của mình thì hãy chạy cú pháp dưới đây:
Đầu tiên, cài đặt ruby cho các hệ thống Ubuntu hoặc Debian
sudo apt install ruby
Trên RedHat hoặc CentOS
sudo yum install ruby
Chạy script gỡ cài đặt
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Để biết thêm về cách sử dụng lệnh của Brew, vui lòng tham khảo tài liệu chính thức:Tài liệu về nhàGiáo dục
Home Cask Homebrew Để tìm hiểu về nó. Để kích hoạt nó, chỉ cần gõ thùng bia.
Các bài viết khác: