How to Install HomeBrew/LinuxBrew in Ubuntu 16.04/18.04 Linux
This post will guide you how to install Homebrew package manager for Ubuntu 16.04/18.04 Linux. How do I Install and Use LinuxBrew on an Ubuntu Linux server. How to install brew on Ubuntu Ruby on Rails on 16.04 or 18.04.
- What is HomeBrew or LinuxBrew?
- Installing LinuxBrew
- Installing Packages with LinuxBrew
- Adding a New Repository
- List All Brew Repositories
- Updating HomeBrew Repository
What is HomeBrew or LinuxBrew?
Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system and Linux. The name means building software on your Mac depending on taste. And the LinuxBrew package manager is a linux fork of the HomeBrew package manager. So you can use the LinuxBrew to install packages from source on your Ubuntu or CentOS Linux. You can also use the LinuxBrew to build your own repositories. And LinuxBrew does not require sudo permission when installing packages.
Installing LinuxBrew
If you want to install LinuxBrew package manager tool in your Ubuntu Linux, just do the following steps:
#1 installing the dependency packages with the following commands:
$ sudo apt update $ sudo apt upgrade -y $ sudo apt -y build-essential make cmake scons curl git \ ruby autoconf automake autoconf-archive \ gettext libtool flex bison \ libbz2-dev libcurl4-openssl-dev \ libexpat-dev libncurses-dev
Outputs:
devops@devops-osetc:~$ sudo apt update [sudo] password for devops: Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease Hit:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease Hit:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease Hit:4 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease Hit:5 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease Reading package lists... Done Building dependency tree Reading state information... Done 9 packages can be upgraded. Run 'apt list --upgradable' to see them. devops@devops-osetc:~$ sudo apt upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages were automatically installed and are no longer required: libllvm6.0 x11proto-dri2-dev x11proto-gl-dev Use 'sudo apt autoremove' to remove them. The following packages will be upgraded: apport apport-gtk extlinux linux-libc-dev python3-apport python3-problem-report syslinux syslinux-common unattended-upgrades 9 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 2,710 kB of archives. After this operation, 4,096 B of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 python3-problem-report all 2.20.9-0ubuntu7.6 [9,884 B] Get:2 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 python3-apport all 2.20.9-0ubuntu7.6 [81.7 kB] Get:3 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 apport all 2.20.9-0ubuntu7.6 [124 kB] Get:4 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 apport-gtk all 2.20.9-0ubuntu7.6 [9,704 B] Get:5 http://mirrors.aliyun.com/ubuntu bionic-proposed/universe amd64 extlinux amd64 3:6.03+dfsg1-2ubuntu0.18.04.2 [132 kB] Get:6 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 linux-libc-dev amd64 4.15.0-46.49 [998 kB] Get:7 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 syslinux amd64 3:6.03+dfsg1-2ubuntu0.18.04.2 [143 kB] Get:8 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 syslinux-common all 3:6.03+dfsg1-2ubuntu0.18.04.2 [1,172 kB] Get:9 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 unattended-upgrades all 1.1ubuntu1.18.04.9 [40.0 kB] Fetched 2,710 kB in 10s (283 kB/s) Preconfiguring packages ... (Reading database ... 231625 files and directories currently installed.) Preparing to unpack .../0-python3-problem-report_2.20.9-0ubuntu7.6_all.deb ... Unpacking python3-problem-report (2.20.9-0ubuntu7.6) over (2.20.9-0ubuntu7.5) ... Preparing to unpack .../1-python3-apport_2.20.9-0ubuntu7.6_all.deb ... ...... Setting up python3-apport (2.20.9-0ubuntu7.6) ... Setting up apport (2.20.9-0ubuntu7.6) ... apport-autoreport.service is a disabled or a static unit, not starting it. Setting up apport-gtk (2.20.9-0ubuntu7.6) ... devops@devops-osetc:~$ devops@devops-osetc:~$ sudo sudo apt-get install -y build-essential make cmake scons curl git \ > ruby autoconf automake autoconf-archive \ libbz2-dev libcurl4-openssl-dev \ libexpat-dev libncurses-dev> gettext libtool flex bison \ > libbz2-dev libcurl4-openssl-dev \ > libexpat-dev libncurses-dev Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'libexpat1-dev' instead of 'libexpat-dev' Note, selecting 'libncurses5-dev' instead of 'libncurses-dev' autoconf is already the newest version (2.69-11). autoconf set to manually installed. automake is already the newest version (1:1.15.1-3ubuntu2). automake set to manually installed. build-essential is already the newest version (12.4ubuntu1). libexpat1-dev is already the newest version (2.2.5-3). libexpat1-dev set to manually installed. libtool is already the newest version (2.4.6-2). libtool set to manually installed. make is already the newest version (4.1-9.1ubuntu1). curl is already the newest version (7.58.0-2ubuntu3.6). gettext is already the newest version (0.19.8.1-6ubuntu0.1). git is already the newest version (1:2.17.1-1ubuntu0.4). git set to manually installed. The following packages were automatically installed and are no longer required: libllvm6.0 x11proto-dri2-dev x11proto-gl-dev Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: bzip2-doc cmake-data fonts-lato javascript-common libbison-dev libfl-dev libfl2 libjs-jquery libjsoncpp1 librhash0 libruby2.5 libtinfo-dev libuv1 rake ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.5 rubygems-integration Suggested packages: bison-doc cmake-doc ninja-build flex-doc libcurl4-doc libidn11-dev libkrb5-dev libldap2-dev librtmp-dev libssh2-1-dev ncurses-doc ri ruby-dev bundler The following NEW packages will be installed: autoconf-archive bison bzip2-doc cmake cmake-data flex fonts-lato javascript-common libbison-dev libbz2-dev libcurl4-openssl-dev libfl-dev libfl2 libjs-jquery libjsoncpp1 libncurses5-dev librhash0 libruby2.5 libtinfo-dev libuv1 rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.5 rubygems-integration scons 0 upgraded, 30 newly installed, 0 to remove and 0 not upgraded. Need to get 13.8 MB of archives. After this operation, 67.3 MB of additional disk space will be used. Get:1 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 autoconf-archive all 20170928-2 [668 kB] Get:2 http://mirrors.aliyun.com/ubuntu bionic/main amd64 flex amd64 2.6.4-6 [316 kB]
#2 install LinuxBrew package with type the following command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
Outputs:
devops@devops-osetc:~$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" ==> Installing Ruby to /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 100 26.9M 100 26.9M 0 0 341k 0 0:01:20 0:01:20 --:--:-- 357k ==> Installing successful ==> /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/current/bin/ruby ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-linux] ==> Add Ruby to your PATH by running: PATH=/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/current/bin:$PATH ==> This script will install: /home/linuxbrew/.linuxbrew/bin/brew /home/linuxbrew/.linuxbrew/share/doc/homebrew /home/linuxbrew/.linuxbrew/share/man/man1/brew.1 /home/linuxbrew/.linuxbrew/share/zsh/site-functions/_brew /home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew /home/devops/.cache/Homebrew/ /home/linuxbrew/.linuxbrew/Homebrew ==> The following new directories will be created: /home/linuxbrew/.linuxbrew/bin /home/linuxbrew/.linuxbrew/etc /home/linuxbrew/.linuxbrew/include /home/linuxbrew/.linuxbrew/lib /home/linuxbrew/.linuxbrew/sbin /home/linuxbrew/.linuxbrew/share /home/linuxbrew/.linuxbrew/var /home/linuxbrew/.linuxbrew/opt /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions /home/linuxbrew/.linuxbrew/Cellar /home/linuxbrew/.linuxbrew/Caskroom /home/linuxbrew/.linuxbrew/Frameworks Press RETURN to continue or any other key to abort ==> /usr/bin/sudo /bin/mkdir -p /home/linuxbrew/.linuxbrew/bin /home/linuxbrew/.linuxbrew/etc /home/linuxbrew/.linuxbrew/include /home/linuxbrew/.linuxbrew/lib /home/linuxbrew/.linuxbrew/sbin /home/linuxbrew/.linuxbrew/share /home/linuxbrew/.linuxbrew/var /home/linuxbrew/.linuxbrew/opt /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions /home/linuxbrew/.linuxbrew/Cellar /home/linuxbrew/.linuxbrew/Caskroom /home/linuxbrew/.linuxbrew/Frameworks ==> /usr/bin/sudo /bin/chmod g+rwx /home/linuxbrew/.linuxbrew/bin /home/linuxbrew/.linuxbrew/etc /home/linuxbrew/.linuxbrew/include /home/linuxbrew/.linuxbrew/lib /home/linuxbrew/.linuxbrew/sbin /home/linuxbrew/.linuxbrew/share /home/linuxbrew/.linuxbrew/var /home/linuxbrew/.linuxbrew/opt /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions /home/linuxbrew/.linuxbrew/Cellar /home/linuxbrew/.linuxbrew/Caskroom /home/linuxbrew/.linuxbrew/Frameworks ==> /usr/bin/sudo /bin/chmod 755 /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions ==> /usr/bin/sudo /bin/chown devops /home/linuxbrew/.linuxbrew/bin /home/linuxbrew/.linuxbrew/etc /home/linuxbrew/.linuxbrew/include /home/linuxbrew/.linuxbrew/lib /home/linuxbrew/.linuxbrew/sbin /home/linuxbrew/.linuxbrew/share /home/linuxbrew/.linuxbrew/var /home/linuxbrew/.linuxbrew/opt /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions /home/linuxbrew/.linuxbrew/Cellar /home/linuxbrew/.linuxbrew/Caskroom /home/linuxbrew/.linuxbrew/Frameworks ==> /usr/bin/sudo /bin/chgrp devops /home/linuxbrew/.linuxbrew/bin /home/linuxbrew/.linuxbrew/etc /home/linuxbrew/.linuxbrew/include /home/linuxbrew/.linuxbrew/lib /home/linuxbrew/.linuxbrew/sbin /home/linuxbrew/.linuxbrew/share /home/linuxbrew/.linuxbrew/var /home/linuxbrew/.linuxbrew/opt /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions /home/linuxbrew/.linuxbrew/Cellar /home/linuxbrew/.linuxbrew/Caskroom /home/linuxbrew/.linuxbrew/Frameworks ==> /usr/bin/sudo /bin/mkdir -p /home/devops/.cache/Homebrew ==> /usr/bin/sudo /bin/chmod g+rwx /home/devops/.cache/Homebrew ==> /usr/bin/sudo /bin/chown devops /home/devops/.cache/Homebrew ==> /usr/bin/sudo /bin/chgrp devops /home/devops/.cache/Homebrew ==> Downloading and installing Linuxbrew... remote: Enumerating objects: 16, done. remote: Counting objects: 100% (16/16), done. remote: Compressing objects: 100% (16/16), done. Receiving objects: 100% (119441/119441), 28.31 MiB | 351.00 KiB/s, done. Resolving deltas: 100% (87276/87276), done. From https://github.com/Homebrew/brew * [new branch] master -> origin/master * [new tag] 0.1 -> 0.1 ...... HEAD is now at 32d1c688a Merge pull request #5795 from Homebrew/dependabot/bundler/Library/Homebrew/json-2.2.0 ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Tapping homebrew/core Cloning into '/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core'... remote: Enumerating objects: 4993, done. remote: Counting objects: 100% (4993/4993), done. remote: Compressing objects: 100% (4784/4784), done. remote: Total 4993 (delta 50), reused 804 (delta 15), pack-reused 0 Receiving objects: 100% (4993/4993), 4.19 MiB | 348.00 KiB/s, done. Resolving deltas: 100% (50/50), done. Checking out files: 100% (5009/5009), done. Tapped 3 commands and 4772 formulae (5,034 files, 13MB). Already up-to-date. ==> Installation successful! ==> Homebrew has enabled anonymous aggregate formulae and cask analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics.html ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Next steps: - Install the Linuxbrew dependencies if you have sudo access: Debian, Ubuntu, etc. sudo apt-get install build-essential Fedora, Red Hat, CentOS, etc. sudo yum groupinstall 'Development Tools' See http://linuxbrew.sh/#dependencies for more information. - Configure Linuxbrew in your ~/.profile by running echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >>~/.profile - Add Linuxbrew to your PATH eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) - We recommend that you install GCC by running: brew install gcc - Run `brew help` to get started - Further documentation: https://docs.brew.sh Warning: /home/linuxbrew/.linuxbrew/bin is not in your PATH.
Note: you need to press Enter key to continue the installation process. And the installation scripts will install LinuxBrw to /home/linuxbrew/.linuxbrew directory.
#3 After Installation is completed, you need to add LinuxBrew directory to your current PATH variable. And also need to add LinuxBrew to your bash shell profile script, ~/.profile and ~/.bash_profile. Just run the following command:
$ 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
#4 You can test installation of LinuxBrew to ensure that the above change take effect. Type the following command:
$ which brew
Or
$ echo $PATH
Outputs:
devops@devops-osetc:~$ which brew /home/linuxbrew/.linuxbrew/bin/brew devops@devops-osetc:~$ echo $PATH /home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/devops/bin:/home/devops/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Installing Packages with LinuxBrew
After installed LinuxBrew package manager on your Ubuntu Linux, you can try to install a package with LinuxBrew. If you want to install a package, you just need to run the following command:
$ brew install PackageName
For Example, you want to install a package named hello, just type the following command:
$ brew install hello
The output should be appeared as below:
devops@devops-osetc:~$ brew install hello Updating Homebrew... ==> Installing dependencies for hello: patchelf ==> Installing hello dependency: patchelf ==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.9_1.x86_64_linux.bottle.tar.gz -=O=- # # # # ######################################################################## 100.0% ==> Pouring patchelf-0.9_1.x86_64_linux.bottle.tar.gz /home/ubuntu/.linuxbrew/Cellar/patchelf/0.9_1: 6 files, 1.2MB ==> Installing hello ==> Downloading https://linuxbrew.bintray.com/bottles/hello-2.10.x86_64_linux.bottle.tar.gz ######################################################################## 100.0% ==> Pouring hello-2.10.x86_64_linux.bottle.tar.gz /home/ubuntu/.linuxbrew/Cellar/hello/2.10: 52 files
If you want to see the list of all available packages that can be installed, just use brew search command to check. For example, if you want to see all the packages which contain gc word, just type:
$ brew search wget
Outputs:
devops@devops-osetc:~$ brew search gc ==> Formulae apple-gcc42 gcc@7 jfrog-cli-go pkg-config bdw-gc gcc@8 kubernetes-service-catalog-client pngcheck emacs-clang-complete-async gconf libgcrypt pngcrush gcab gcore libsigc++ spring-completion gcal gcovr libsvg-cairo svgcleaner gcc gcsfuse logcheck uggconv gcc@4.9 gcutil opentracing-cpp xml-tooling-c gcc@5 gcviewer pcb2gcode zxing-cpp gcc@6 i386-elf-gcc pgcli
Adding a New Repository
LinuxBrew repositories is also called TAPS. and You can add a new repository for LinuxBrew package manager. You can get serveral common repositories from the HomeBrew Github page.
For example, you want to add the homebrew-livecheck repository for linuxbrew, just type the following commmand:
$ brew tap Homebrew/homebrew-livecheck
Outputs:
devops@devops-osetc:~$ brew tap Homebrew/homebrew-livecheck
Updating Homebrew...
==> Tapping homebrew/livecheck
Cloning into '/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-livecheck'...
remote: Enumerating objects: 903, done.
remote: Counting objects: 100% (903/903), done.
remote: Compressing objects: 100% (876/876), done.
remote: Total 903 (delta 25), reused 821 (delta 24), pack-reused 0
Receiving objects: 100% (903/903), 138.63 KiB | 259.00 KiB/s, done.
Resolving deltas: 100% (25/25), done.
Tapped 1 command (920 files, 532.1KB).
List All Brew Repositories
If you want to list all available brew repositories or tabs, type:
$ brew tap
Outputs:
devops@devops-osetc:~$ brew tap Updating Homebrew... homebrew/core homebrew/livecheck
Updating LinuxBrew Repository
If y want to fetch the newest version of Homebrew and all formulae from GitHub and perform any necessary migrations, type the following command:
$ brew update
If you want to upgrade packages to the latest version, type:
$ brew upgrade packageName
Conclusion
You should know that how to install and use LinuxBrew package manager on Ubuntu 16.04 or 18.04 from this guide. And if you see more information about linuxbrew, you can go the below offical web site of linuxbrew directly.
See Also: