How to install Homebrew on Ubuntu 24.04
Homebrew on Ubuntu 24.04 is installed by running a simple command in your terminal.
Homebrew acts like an app store for Linux, making it easy to install and manage programs. It originally came from macOS but now works on Linux systems too, helping you get the newest software versions.
This tool puts packages into your personal folder, typically at `/home/yourusername/.brew`. This helps prevent clashes with Ubuntu’s own software installer, called `apt`.
Developers often use Homebrew when they need newer or specific tools that aren’t easily found otherwise.
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
The easiest way to install Homebrew on Ubuntu 24.04 is with the official setup script. Copy and paste one command into your terminal. This script handles downloading and setting up Homebrew, making the process quick.
/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.
After completing the Homebrew installation script, you’ll be prompted to run several commands on your terminal.
These commands are crucial for setting up Homebrew on Ubuntu and configuring your system. Use the first command to establish Homebrew in your `.bashrc` profile, replacing ‘richard‘ with your actual username.
Running the command `eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"` sets up Homebrew in your `.bashrc` profile file. This command ensures Homebrew is ready to use every time you open a new terminal. Remember to replace 'richard' with your actual username in any file paths where it appears.
Run this command in your terminal to add Homebrew to your PATH. This ensures Homebrew functions correctly by setting specific environment variables (settings that tell your system how to behave).
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/richard/.bashrc
Homebrew’s version number confirms a successful installation. Check Homebrew’s version by running the `/home/linuxbrew/.linuxbrew/bin/brew –version` command in your terminal. This command displays the exact version installed, for example, Homebrew 4.2.2.
brew --version
Run the brew doctor utility to ensure everything was set up correctly.
brew doctor
Before proceeding with the Git method, ensure you have Homebrew’s dependencies installed if you have `sudo` access:
You can install Homebrew on Ubuntu by using its source code directly from Git. This process involves downloading the Homebrew Git repository to your computer. Then, you set up your system so your computer can easily find and use Homebrew commands.
Download the Homebrew Git repository to your Ubuntu machine by running the command below.
git clone https://github.com/Homebrew/brew homebrew
Then, run the command below to add Homebrew into your 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 makes managing software simple. You can install new programs with one command. Updating or removing installed programs is also easy. This approach handles your system's software quickly and efficiently.
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
Removing Homebrew from your Ubuntu machine is straightforward using its special uninstall script. Download the script and run it in your terminal. The script then handles removing Homebrew and cleaning up any related files from your system.
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.
You’ll also want to remove the relevant line from your `.bashrc` file.
sudo nano .bashrc
Finally, delete the Homebrew folder.
sudo rm -rf homebrew
That should do it!
Conclusion:
In summary, installing Homebrew on Ubuntu can significantly enhance your development experience. Here are key points to remember:
- 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 can streamline your workflows and keep your 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!