How to install Homebrew on Ubuntu 24.04
Homebrew is a package manager that lets you install and manage command-line tools on Ubuntu 24.04 without altering your main system files. It puts extra software inside your personal folder at /home/yourusername/.brew rather than mixing with Ubuntu’s built-in apt system.
You need this tool whenever specific programs or newer versions are missing from standard software channels. Running a single installation script in your terminal sets everything up within a few minutes.
Install Homebrew on Ubuntu 24.04 by running the official installation script: `/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”`. Follow the on-screen prompts, then add Homebrew to your PATH by running `eval “$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)”`.
Install Brew
To install Homebrew Ubuntu 24.04 users can run the official setup script directly in the command line. This method downloads and sets up everything you need in just a few minutes. Open your terminal, paste the install command, and press Enter to start the installation process.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
When prompted during the script, hit Enter to install Homebrew to your home directory on Ubuntu.
Run the following commands in your terminal to finish setting up Homebrew and configure your system environment.
These commands establish Homebrew on Ubuntu and configure the system environment. Use the first command to establish Homebrew in the `.bashrc` profile, replacing ‘richard‘ with the actual username.
Running the command `eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"` sets up Homebrew in the `.bashrc` profile file. This command ensures Homebrew is ready to use every time a new terminal opens. Replacing 'richard' with the correct username in all file paths is necessary.
Run this command to add Homebrew to your PATH (the list of folders your system searches for executable programs).
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/richard/.bashrc
Verifying the version number confirms a successful installation. Check Homebrew's version by running the `/home/linuxbrew/.linuxbrew/bin/brew --version` command in the terminal. This command displays the exact version installed, for example, Homebrew 4.2.2.
brew --version
Run the brew doctor utility to ensure proper system configuration.
brew doctor
Before proceeding with the Git method, ensure Homebrew's dependencies are installed when `sudo` access is available:
Installing Homebrew on Ubuntu can happen by using source code directly from Git. This process involves downloading the Homebrew Git repository to the computer. Configuring the system afterward ensures the command-line interface recognizes Homebrew commands.
Download the Homebrew Git repository to the Ubuntu machine by running the command below.
git clone https://github.com/Homebrew/brew homebrew
Then, run the command below to add Homebrew into the system’s command-line environment.
eval "$(homebrew/bin/brew shellenv)"
Check the installed Homebrew version by running the command below.
brew --version
Homebrew on Ubuntu 24.04 streamlines software management. Installing new programs requires a single command. Updating or removing installed programs follows the same efficient pattern. This approach handles system software quickly and effectively.
brew install package_name
For example, to install the GCC package, run the command below.
brew install gcc
Replace install with upgrade to upgrade a package.
brew upgrade gcc
To uninstall a package, use the uninstall option with a command similar to the one below.
brew uninstall gcc
How to Remove Homebrew
To remove Homebrew from your Ubuntu system completely, you need to download and run the official uninstall script in your terminal. This script automatically deletes Homebrew and cleans up all related files from your computer so nothing is left behind.
curl -fsSL -o uninstall.sh https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh
Then, execute the script by running the command below.
bash uninstall.sh
When prompted, enter y for yes.
Removing the relevant line from the `.bashrc` file is also necessary.
sudo nano .bashrc
Finally, delete the Homebrew folder.
sudo rm -rf homebrew
Configuration cleanup is complete.
Conclusion:
Installing Homebrew on Ubuntu significantly enhances the development experience. Review these key points for reference:
- User-Friendly: Homebrew simplifies package management and offers a consistent user experience across macOS and Linux.
- Installing software in your home directory prevents conflicts with system-managed packages.
- Up-to-date Software: Access newer software versions that may not be available through the default Ubuntu package manager.
- Flexible Installation: Provides multiple methods of installation (curl or Git) to suit your preference.
- Simple Package Commands: Easily install, upgrade, and uninstall packages with straightforward commands.
- Easy Uninstallation: Homebrew comes with an uninstall script, making it simple to remove when needed.
Using Homebrew streamlines workflows and keeps the system organized while providing access to a broader range of software options.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!