[Homebrew Series 3] Installing and Managing Packages

한국어 버전

Install and Manage CLI Packages

In Part 2, you installed Homebrew and made the brew command available in Terminal. In this part, you will use it on real packages so you can build a simple maintenance routine: install, inspect, upgrade, remove, and clean up.

What This Post Covers

  • Install and try tree, wget, and htop
  • Read package information with brew list, brew info, and brew deps
  • Understand the workflow behind brew update, brew outdated, and brew upgrade
  • Remove packages safely and clean up unused files

Before You Start

  • macOS with Homebrew already installed
  • Terminal access
  • Basic comfort running commands from Part 2

Key Terms First

Before the exercises, two Homebrew terms will appear several times in this post.

Term Meaning Example
Formula A CLI package managed by Homebrew tree, wget, htop
Dependency Another package a formula needs in order to work openssl, ca-certificates

When Homebrew installs a formula, it also installs any required dependencies for you.

Exercise 1: Install and Use tree

tree is a good first package because it is small, safe to experiment with, and easy to verify right away.

Install It

Installing tree zsh · ~/workspace
Ready. Press Replay to run the scripted session.

Your output may differ by Homebrew version, macOS version, or CPU architecture. The important part is the flow: download, install, then a success line.

Piece Meaning
Downloading Homebrew is fetching the package
Pouring Homebrew is unpacking and installing the bottle
🍺 Homebrew finished the install
/opt/homebrew/Cellar/... Where that formula version is stored

Try It

Run these commands in order so you can see what tree does.

# Check the installed version
tree --version

# Show the current directory tree
tree

# Show only folders
tree -d

# Include hidden files
tree -a

If you see a directory tree, the install worked.

Exercise 2: Install wget and Notice Dependencies

wget is useful because it downloads files from the web, and it also shows one of Homebrew's biggest benefits: automatic dependency management.

Install It

brew install wget

What To Notice

  • wget is the formula you asked for
  • Homebrew may also install dependencies such as openssl and ca-certificates
  • You do not need to install those one by one

That is what a dependency means here: software another package needs in order to work.

Inspect Its Dependencies

brew deps wget

Try It

# Download a file
wget https://example.com/file.png

# Save with a chosen name
wget -O mylogo.png https://example.com/file.png

The command structure matters more than the exact file. In real use, replace the example URL with a real download link.

Exercise 3: Install and Run htop

htop is a live system monitor. It gives you one more practice install and introduces a package you may actually keep.

Install and Run

brew install htop
htop

Basic Controls

  • Press q to quit
  • Press ? to open help inside htop
  • If your machine hides some process details, try sudo htop

Exercise 4: Inspect What Homebrew Installed

Now that you installed a few packages, inspect them instead of treating Homebrew like a black box.

List Everything Installed

brew list

List Installed Packages With Versions

brew list --versions

Show Details for One Package

brew info tree

Use brew info when you want a package description, install path, dependencies, and homepage.

Exercise 5: Learn the Update Workflow

Many beginners mix up update and upgrade. They are related, but they do different jobs.

What Each Command Does

Command What it does When to use it
brew update Refreshes Homebrew's local package definitions Run first, so Homebrew knows what versions exist
brew outdated Shows which installed packages are behind Run before upgrading if you want to inspect changes
brew upgrade <name> Upgrades one installed package Safest default for beginners
brew upgrade Upgrades all installed packages Use when you want to upgrade everything

When you want to update packages, use this order:

brew update
brew outdated
brew upgrade tree

That sequence means:

  1. Refresh Homebrew's package data
  2. Check what is outdated
  3. Upgrade the package you actually want to change

Practice

Update Workflow zsh · ~/workspace
Ready. Press Replay to run the scripted session.

If you run brew upgrade with no package name, Homebrew upgrades all installed packages. That is convenient, but package-by-package upgrades are easier to understand when you are still learning.

Exercise 6: Remove Packages and Clean Up

This exercise closes the full package lifecycle. Install a package, inspect it, then remove it cleanly.

Uninstall a Package

brew uninstall tree

Remove Unneeded Dependencies

brew autoremove

brew autoremove removes dependencies that are no longer needed by any installed formula.

Preview Cleanup

brew cleanup --dry-run

Clean Old Downloads and Old Versions

brew cleanup

brew cleanup is usually safe, but it removes cached downloads and old package versions. Use --dry-run first if you want to see what will be removed.

Exercise 7: Search Before You Install

Search is useful when you know roughly what you want but not the exact formula name.

Search by Keyword

brew search json

Confirm an Exact Formula Name

brew search tree

Use the result to confirm the exact formula name before installing.

Exercise 8: Install Multiple Packages At Once

Once you trust the basics, you can install several packages in one command.

brew install git node yarn jq ripgrep fd

Homebrew resolves dependencies first, then installs the formulas you requested. This is safe for common setups, but when you are learning, it is still worth understanding one package at a time first.

Common Mistakes

Never Use sudo With brew

Run this:

brew install tree

Do not run this:

sudo brew install tree

Homebrew is designed to manage its own permissions. Using sudo with brew is a common cause of permission problems.

If A Formula Name Is Wrong

brew search <keyword>

No available formula usually means the name is misspelled or that Homebrew does not provide that formula.

If An Install Looks Stuck

# Press Ctrl+C to stop, then retry with more detail
brew install <package> --verbose

Large downloads and slower networks can make an install feel stuck even when it is still working.

If You See Permission Errors

Do not try to fix Homebrew by running a broad chown command on the whole prefix. If you previously used sudo with Homebrew, the safer fix is usually to review the install with:

brew doctor

If the installation is badly broken, reinstalling Homebrew cleanly is usually safer than changing ownership recursively by hand.

If Another Homebrew Process Is Running

Wait for the other terminal window to finish first. Only clear lock files after you confirm no other Homebrew command is still active.

Quick Reference

Command When to use it
brew install <name> Install a package
brew uninstall <name> Remove a package
brew list See everything installed
brew list --versions See installed versions
brew info <name> Inspect one package
brew deps <name> See package dependencies
brew search <keyword> Find a package name
brew update Refresh package definitions
brew outdated Check what can be upgraded
brew upgrade <name> Upgrade one package
brew upgrade Upgrade all installed packages
brew autoremove Remove unused dependencies
brew cleanup Remove old cache files and old versions
brew doctor Check Homebrew health

Practice Checklist

  • Install and run tree
  • Install wget and inspect its dependencies with brew deps wget
  • Install and open htop
  • Use brew list to view installed packages
  • Inspect package details with brew info tree
  • Run brew update, brew outdated, and brew upgrade tree
  • Remove a package with brew uninstall
  • Clean up unused dependencies with brew autoremove
  • Preview cleanup with brew cleanup --dry-run
  • Search for packages with brew search

Wrap-Up

You now know the beginner Homebrew workflow that matters most in daily use: install a formula, inspect it, update package definitions, upgrade intentionally, and clean up when you are done.

In the next post, the series moves from CLI tools to GUI apps and Brewfile automation.

Homebrew Series 4: GUI Apps and Brewfile

💬 댓글

이 글에 대한 의견을 남겨주세요