暗无天日

=============>DarkSun的个人博客

linuxbrew让你在home目录下安装应用

普通用户想安装应用往往比较麻烦,他们没有写入 /etc/,/bin/,/sbin/ 等重要目录的权限,只能在configure时通过 --prefix=$HOME 来将应用安装在HOME目录下。

linuxbrew是著名MacOS包管理器homebrew的linux版,它可以让你很方便地安装应用到HOME目录下。

安装linuxbrew

  1. 安装linuxbrew

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
    
  2. 设置环境变量

    echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin/:$PATH"' >>~/.bashrc
    echo 'export MANPATH="/home/linuxbrew/.linuxbrew/share/man:$MANPATH"' >>~/.bashrc
    echo 'export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:$INFOPATH"' >>~/.bashrc
    
  3. 应用新设置的环境变量

    source ~/.bashrc
    

使用linuxbrew

运行 brew --help 就能列出帮助信息:

Example usage:
  brew search [TEXT|/REGEX/]
  brew info [FORMULA...]
  brew install FORMULA...
  brew update
  brew upgrade [FORMULA...]
  brew uninstall FORMULA...
  brew list [FORMULA...]

Troubleshooting:
  brew config
  brew doctor
  brew install --verbose --debug FORMULA

Contributing:
  brew create [URL [--no-fetch]]
  brew edit [FORMULA...]

Further help:
  brew commands
  brew help [COMMAND]
  man brew
  https://docs.brew.sh

比较常用的操作如下所示

搜索应用

brew search nano
==> Formulae
nano                           nanomsg                        nanomsgxx                      nanopb-generator

安装应用

brew install flac123
==> Installing dependencies for flac123: patchelf, m4, autoconf, automake, libogg, flac, libtool, pkg-config, libao and popt
==> Installing flac123 dependency: patchelf
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.9_1.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
==> Pouring patchelf-0.9_1.x86_64_linux.bottle.tar.gz
🍺  /home/lujun9972/.linuxbrew/Cellar/patchelf/0.9_1: 6 files, 1.2MB
==> Installing flac123 dependency: m4
==> Downloading https://linuxbrew.bintray.com/bottles/m4-1.4.18.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
==> Pouring m4-1.4.18.x86_64_linux.bottle.tar.gz
🍺  /home/lujun9972/.linuxbrew/Cellar/m4/1.4.18: 13 files, 1.1MB
==> Installing flac123 dependency: autoconf
....

列出已安装的应用

brew list
autoconf  automake  flac  flac123  gpatch  libao  libogg  libtool  m4  ncurses	patchelf  pkg-config  popt  zlib

卸载应用

brew uninstall flac123
Uninstalling /home/lujun9972/.linuxbrew/Cellar/flac123/0.0.12... (8 files, 63.1KB)

升级linuxbrew

brew update
Already up-to-date.