Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Homebrew in linux

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use Homebrew in linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The Homebrew project was originally designed to provide an unofficial Linux-style package manager for Mac users. Users soon fell in love with its friendly interface and helpful tips, and it has been ported to Linux-which looks like a strange twist of fate.

At first, there were two separate projects for macOS and Linux (Homebrew and Linuxbrew), but now the two operating systems are managed by the Homebrew core. Since I'm switching from Mac to Linux, I've been studying how my most commonly used open source software at macOS performs on Linux, and in the end, I'm glad to find that Homebrew's support for Linux is amazing!

Why use Homebrew in Linux?

The first reaction of long-time Linux users to Homebrew is: "Why not use it directly?" ellipsis stands for one of their favorite Linux package managers. Debian-based systems have long had apt, Fedora-based systems have dnf and yum, and projects like Flatpak and AppImage run smoothly on both systems. I've spent a lot of time trying these technologies, and I have to say, they all have their strengths.

Then why do I insist on using Homebrew? First of all, I am very familiar with it. I've learned a lot about how to use it in the process of finding open source alternatives to proprietary software I used in the past, and keeping something familiar, such as Homebrew, allows me to focus on learning one thing at a time, rather than being overwhelmed by differences between different systems.

In addition, I don't see any package manager as user-friendly as Homebrew. Like the default help command, the command is in order:

$brew-hExample usage: brew search [TEXT | / REGEX/] brew info [FORMULA...] Brew install FORMULA... Brew update brew upgrade [FORMULA...] Brew uninstall FORMULA... Brew list [FORMULA...] Further help: brew commands brew help [COMMAND] man brew

Too short output may be misinterpreted as limited, but if you take a brief look at each subcommand, it has a wealth of functionality. Although the list above is only 23 lines, for advanced users, the subcommand install alone contains a full 79 lines of help:

$brew-- help | wc-L23 $brew install-- help | wc-l79

It can choose to ignore or install dependencies, or it can choose to compile with source code and what compiler to compile an exact upstream Git submission, or choose the official "filled" version of the application. All in all, Homebrew is suitable for both beginners and veterans.

Start using Homebrew in Linux

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

This command immediately starts installing Homebrew. If you are careful, you can use curl to download the file locally and run it after checking.

$curl-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh-- output homebrew_installer.sh$ more homebrew_installer.sh # review the script until you think it's all right $bash homebrew_installer.sh

The installation steps for Linux also include how to configure point files, ~ / .profile for Debian systems and ~ / .bash_profile for Fedora systems.

$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

To confirm that it has been installed, the Homebrew team provides an empty hello "secret recipe" for testing:

$brew install hello== > Downloading https://linuxbrew.bintray.com/bottles/hello-2.10.x86_64_linux.bottle.tar.gz######################################################################## 100.0% costs = > Pouring hello-2.10.x86_ 64_linux.bottle.tar.gz? / home/linuxbrew/.linuxbrew/Cellar/hello/2.10: 52 files 595.6KB

There seems to be no problem with the installation, so let me try more.

Command line tool Brew

Homebrew claims to be an app that only "installs what you need and [Linux] doesn't have" by default.

You can use the brew command to install any command-line software packaged in Homebrew. The definition files for these packages are called "secret recipe formula", and they are compiled and shared through "bottle bottle". There are still many terms for "beer" in the world of Homebrew, but the main purpose of this package manager is to make the software easy to use.

What kind of software do you have? The most convenient thing for a technical player like me (since you are already reading this article, I guess you are, too). For example, the convenient tree command can show the directory structure, or pyenv, which I use to manage different versions of Python in Mac.

You can use the search command to see all the "secret recipes" that can be installed, followed by the wc command to see how many there are:

#-l option to count rows $brew search | wc-l 5087

So far, there are more than 5000 "secret recipes", including a lot of software. It is important to note that not all "secret recipes" can be run on Linux. There is a section in the brew search-help output that mentions that software can be filtered by the operating system on which it runs. It opens the software repository for each operating system in the browser. I'm running Fedora, so I'll try it with it:

$brew search-fedora tree

The browser opened the URL https://apps.fedoraproject.org/packages/s/tree and showed me all the options available for Fedora. You can also browse it in other ways. "Secret recipes" are centrally organized into core repositories divided by the operating system (Mac in Homebrew Core,Linux and Linux Core). It can also be displayed on the web page through Homebrew API.

Even with these options, I still find a lot of new tools through the recommendations of other users. I've listed some of my favorite tools, and you can find some inspiration in it:

Pyenv, rbenv, and nodenv are used to manage (corresponding) Python, Ruby, and Node.js versions

Imagemagick is used for scripted editing pictures.

Pandoc is used to script document formats (I usually convert .docx files to .md or .html)

Hub provides GitHub users with a better Git experience

Tldr shows examples of the use of command tools

To learn more about Homebrew, check out the trldr page, which is much friendlier than the man page of the application. Use the search command to confirm that you can install:

$brew search tldr== > Formulaetldr ✔

Great! The check box indicates that you can install it. So go on:

$brew install tldr== > Downloading https://linuxbrew.bintray.com/bottles/tldr-1.3.0_2.x86_64_linux.bottle.1.tar.gz######################################################################## 100.0% costs = > Pouring tldr- 1.3.0_2.x86_64_linux.bottle.1.tar.gz? / home/linuxbrew/.linuxbrew/Cellar/tldr/1.3.0_2: 6 files 63.2KB

Homebrew provides compiled binaries, so you don't have to compile from source code on your local machine. This saves a lot of time and does not have to listen to the noise of the CPU fan. Another thing I admire about Homebrew is that you don't fully understand the meaning of each option and it doesn't affect normal use. If you want to compile it yourself, you can add the-s or-- build-from-source flag to the brew install command so that you can compile the "secret recipe" from the source code (even if there is already a "bottle").

Similarly, the underlying complexity of the software is also interesting. Using info, you can view the dependency management of tldr software, where the source code of "secret recipes" is stored on disk, and even view public analysis.

$brew info tldrtldr: stable 1.3.0 (bottled), HEADSimplified and community-driven man pages https://tldr.sh/Conflicts with: tealdeer (because both install `tldr` binaries) / home/linuxbrew/.linuxbrew/Cellar/tldr/1.3.0_2 (6 files, 63.2KB) * Poured from bottle on 2020-06-08 at 15:56:15From: https://github.com/Homebrew/linuxbrew-core/blob/master/Formula/tldr.rb==> DependenciesBuild: pkg-config ✔ Required: libzip ✔ Curl ✔ = > Options--HEAD Install HEAD version== > Analyticsinstall: 197 (30 days), 647 (90 days), 1546 (365 days) install-on-request: 197 (30 days), 646 (90 days), 1546 (365 days) build-error: 0 (30 days) one deficiency from Mac to Linux

The cask ("barrel") subcommand in macOS,Homebrew allows users to install and manage the entire application using the command line. Unfortunately, cask is not yet available on any Linux distribution. I found this when I installed an open source tool:

$brew cask install tuskError: Installing casks is supported only on macOS

I asked on the forum and soon got feedback from other users. To sum up, the plan is as follows:

Copy the Homebrew project, build this feature, and then show its value to others

Write a "secret recipe" for the software and compile it from the source code

Create a third-party warehouse for the software

The last one is what I am most interested in. Homebrew manages third-party warehouses by creating and maintaining "faucet tap" (another term affected by beer). As you become more familiar with the system and want to join the ecosystem, the faucet is worth studying.

Back up the installation record of Homebrew

One of my favorite Homebrew features is that you can back up your installation records like any other version control tool to back up files. To do this, Homebrew provides the bundle ("bind") subcommand, which controls a subcommand called dump ("dump") to generate a Brewfile. This file contains a list of all your currently installed tools and can be reused.

$cd ~ / Development/dotfiles # This is my dotfile folder$ brew bundle dump$ ls BrewfileBrewfile

When I change my machine and want to install the same software, go to the folder containing Brewfile and reinstall:

$ls BrewfileBrewfile$ brew bundle

It will install all the listed "secret recipes" on my new machine.

Manage Brewfile at the same time as Mac and Linux

Brewfile is perfect for backing up your current installation records, but what if some software running on Mac doesn't run on Linux? Or is it just the opposite? I've found that whether it's Mac or Linux, Homebrew gracefully ignores that line if the software doesn't run on the current operating system. If it encounters an incompatible request (such as when installing "barrel cask" on Linux using brew), it chooses to skip it and continue with the installation process:

Brew bundle-file=Brewfile.example Skipping cask licecap (on Linux) Skipping cask macdown (on Linux) Installing fishHomebrew Bundle complete! 1 Brewfile dependency now installed.

To keep the configuration file concise, I used the same Brewfile on both operating systems, because it only installs operating system-related versions, so I haven't had any problems.

Use Homebrew to manage software packages

Homebrew has become a must-have command-line tool for me, and because I'm familiar with it, the experience on Linux is fun. Homebrew keeps my tools organized and up-to-date, and I appreciate the balance between utility and functionality more and more. I prefer to keep the details of package management to a minimum that users need to know, and most people will benefit from it. If you are already familiar with the Linux package manager, Homebrew may make you feel basic, but if you look a little deeper, you will find that its advanced options go far beyond the content of this article.

The above is all the content of the article "how to use Homebrew in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report