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 keeps extra software apart from Ubuntu’s built-in apt system, so the two never overwrite each other’s files. Homebrew on Linux normally lives in /home/linuxbrew/.linuxbrew, which is the path the commands in this guide use. The Git method can also keep it in a folder inside your own home directory.
You need this tool whenever a program, or a newer version of one, is missing from the standard Ubuntu software channels. Running a single installation script in your terminal sets everything up within a few minutes. This guide covers the script method, the Git method, everyday package commands, and a full uninstall.
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 on Ubuntu 24.04, run the official setup script in the command line. It downloads and sets up everything in a few minutes. Run it as your normal user, not as root. The script usually asks for your sudo password, so the account must be allowed to use sudo.
- Open a terminal. On the Ubuntu desktop, press Ctrl+Alt+T.
- Paste the install command shown below into the terminal.
- Press Enter to start it.
- Type your password if the script asks for it. Nothing appears on screen while you type, which is normal.
The terminal should now list what the script is about to install and wait for your confirmation.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Read the list of folders and actions the script prints.
- Press Enter when the script asks you to continue.
The script then downloads and installs Homebrew. This can take several minutes, depending on your connection. When it finishes, it prints a “Next steps” message. Do not close the terminal yet, because the next step uses it.
The installer does not add the brew command to your shell on its own. Run the following commands in your terminal to finish setting up Homebrew and configure your environment. Without them, Ubuntu answers “command not found” when you type brew.
These commands establish Homebrew on Ubuntu and configure the system environment. Use the first command to add Homebrew to the `.bashrc` profile. Replace 'richard' with your actual username. The path points to your own home folder, so a wrong name will fail or edit the wrong file.
The command `eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"` sets up Homebrew in the `.bashrc` profile file. This makes sure Homebrew is ready to use every time a new terminal opens. Replace 'richard' with the correct username in all file paths. If you are not sure of your username, the prompt in your terminal normally shows it before the @ sign.
Run this command to add Homebrew to your PATH (the list of folders your system searches for executable programs). It applies to the terminal you are using right now, so you can use brew straight away. Terminals you open later pick it up from `.bashrc`.
(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. It displays the exact version installed, for example Homebrew 4.2.2. Your number will probably differ, because Homebrew updates often. A version line means the install worked. An error such as "No such file or directory" means the install did not finish, or you used a different path.
brew --version
Run the brew doctor utility to ensure proper system configuration. It checks your setup for problems that could break installs later.
If everything is fine, it says your system is ready to brew. If it prints warnings, read each one. Most explain what is wrong and how to fix it, and many are harmless.
brew doctor
Before proceeding with the Git method, ensure Homebrew's dependencies are installed when `sudo` access is available. Homebrew on Linux needs a few basics, such as build tools, curl and git. Installing them first avoids errors when you build packages later. Run the command below.
You can also install Homebrew from its source code on Git. This downloads the Homebrew repository to the computer. You then configure the shell afterward so the terminal recognizes Homebrew commands. Use this method if you prefer to see exactly what is downloaded, or if the curl script does not suit your setup.
- Open a terminal if one is not already open.
- Run the command below to download the Homebrew Git repository to the Ubuntu machine.
- Wait for the download to finish and the prompt to return.
git clone https://github.com/Homebrew/brew homebrew
Then run the command below to add Homebrew to the system's command-line environment. It tells your shell where the Homebrew files are. Open a new terminal window afterward so the change takes effect everywhere.
eval "$(homebrew/bin/brew shellenv)"
Check the installed Homebrew version by running the command below. If it prints a version number, the shell can find Homebrew. If it says the command is not found, open a new terminal and try again, then recheck the previous step.
brew --version
To finish the setup, run the command below to grant write access to the specified directory for data storage. Homebrew needs to write there when it installs and updates packages. Without it you may see permission errors later.
Homebrew on Ubuntu 24.04 streamlines software management. Installing a new program takes a single command, and updating or removing it follows the same pattern. The examples below show each action. You do not need sudo for normal Homebrew commands, because Homebrew works in its own folder.
brew install package_name
For example, to install the GCC package, run the command below. Homebrew downloads the package and any dependencies it needs, then installs them. Larger packages can take a few minutes.
brew install gcc
Replace install with upgrade to upgrade a package. Use the same package name you used when you installed it.
brew upgrade gcc
To uninstall a package, use the uninstall option with a command similar to the one below. Only the named package is removed. Homebrew itself and your other packages stay as they are.
brew uninstall gcc
How to Remove Homebrew
To remove Homebrew from your Ubuntu system completely, download and run the official uninstall script in your terminal. The script deletes Homebrew and cleans up the related files so nothing is left behind. Any packages you installed with Homebrew are removed along with it, so note down anything you want to reinstall later.
curl -fsSL -o uninstall.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
Then execute the script by running the command below.
bash uninstall.sh
When prompted, enter y for yes, then press Enter. The script lists what it will remove before it starts. If you are asked for your password, enter it.
Removing the relevant line from the `.bashrc` file is also necessary. This is the Homebrew line you added during setup. Leave it in place and your terminal will keep looking for a program that no longer exists. Open `.bashrc` in a text editor, delete that line, and save the file.
sudo nano .bashrc
Finally, delete the Homebrew folder with the command below. Check the path before you press Enter, because deleting a folder cannot be undone.
sudo rm -rf homebrew
Configuration cleanup is complete. Open a new terminal to confirm that brew is no longer found.
Conclusion:
Installing Homebrew on Ubuntu 24.04 makes it easier to get the tools you need. 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 Homebrew's own folder 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 keeps your workflow organized and gives you access to a broader range of software than the default Ubuntu repositories. Keep it up to date, run brew doctor when something misbehaves, and use the uninstall script if you ever want it gone.
Have a question about this guide?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!