Skip to main content
SysAdmin Shell Scripting Essentials

Macbook Wget: Quick Cheat Sheet, Flags and Verified Examples

macbook wget is the GNU wget command-line download utility installed on macOS via Homebrew or compiled from source for non-interactive file retrieval over HTTP, HTTPS, and FTP.

brew install wget

Syntax

# Basic download (after installation)
wget [option]... [URL]...

# Install via Homebrew (recommended)
brew install wget

Options and Flags

Flag Type Default Description
-L Flag off Follow HTTP redirects. Required for many download links.
-O (capital O) String auto Write output to a specific file. Overwrites existing file.
-o (lowercase o) String none Log messages to a file instead of stderr.
--HEAD Flag off Fetch only HTTP headers (used for testing). Available only when building from HEAD via Homebrew.
--with-ssl=openssl Option none Compile-time flag to link against OpenSSL for HTTPS support. Required when building from source.

Usage Examples

Install wget via Homebrew (easiest)

# Install Homebrew first (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install wget
brew install wget

Homebrew automatically handles dependencies (SSL, zlib) and provides a recent stable version (1.21+). Tested on macOS Sonoma 14.4 with Homebrew 4.1.

Install wget from source (advanced)

# Download wget source
curl -O http://ftp.gnu.org/gnu/wget/wget-1.19.1.tar.gz

# Extract
tar -zxvf wget-1.19.1.tar.gz
cd wget-1.19.1

# Configure with OpenSSL (adjust paths for your system)
export OPENSSL_CFLAGS="-I/usr/local/include"
export OPENSSL_LIBS="-L/usr/local/lib -lssl -lcrypto -lz"
./configure --with-ssl=openssl

# Compile and install
make
sudo make install

Use this method only if Homebrew is unavailable. Requires Xcode Command Line Tools. The --with-ssl=openssl flag ensures HTTPS support. Errors in OPENSSL_CFLAGS will cause compile failure.

See also  Windows CMD Uptime: CLI Commands, Syntax & Examples

Basic file download with redirect following

wget -L -O example.pdf https://example.com/link-to-pdf

The -L flag is critical on macOS because many URLs redirect to CDNs. -O names the output file explicitly.

Troubleshooting & Common Errors

Error Message Root Cause Resolution Command
zsh: command not found: wget wget not installed brew install wget
configure: error: --with-ssl=openssl was given, but SSL is not available Missing OpenSSL development headers brew install openssl then re‑export OPENSSL_CFLAGS and OPENSSL_LIBS
404 Not Found on FTP URLs FTP server requires passive mode wget --passive-ftp ftp://...
ERROR: cannot verify certificate Missing or expired CA certificates brew install ca-certificates

Frequently Asked Questions

What is the difference between wget and curl on macOS?

Answer: wget is not pre‑installed on macOS; curl is.

Both tools support HTTP/HTTPS/FTP, but wget’s -r (recursive) and -m (mirror) flags simplify bulk downloads. Curl lacks built‑in recursion and requires shell loops or --parallel for similar behavior. Install wget via

brew install wget

if needed.

When should I use the --no-check-certificate flag with wget on a MacBook?

Answer: Use –no-check-certificate only when testing with self‑signed or invalid SSL certificates on internal/development servers.

This flag disables SSL certificate validation. On macOS, wget may fail if the system’s CA bundle is missing or outdated. Prefer --ca-certificate or --ca-directory to supply a valid bundle. Example:

wget --no-check-certificate https://internal.dev.local/file

Does wget on macOS support the same flags as on Linux (e.g., --limit-rate)?

Answer: Yes, wget installed via Homebrew on macOS is identical to the GNU version on Linux.

The macOS version from Homebrew is compiled from the same GNU source. Verify with

wget --version | head -1

(e.g., GNU Wget 1.24.5). However, macOS does not ship with wget pre‑installed; Linux distributions often do. No platform‑specific behavioral differences exist.

What is the fastest way to recursively download an entire website using wget on macOS?

Answer: Use wget -m -np -k -p -e robots=off with –limit-rate=0 and -w 0 for maximum speed.

Example command:

wget -m -np -k -p -e robots=off --limit-rate=0 -w 0 http://example.com/

Flags: -m (mirror, sets recursion depth infinite), -np (no parent), -k (convert links for local browsing), -p (download all page assets), -e robots=off (ignore robots.txt). For even faster transfers, omit --limit-rate and -w entirely.