How to download files with wget or curl

Overview

wget is convenient for saving files, while curl transfers URLs and prints response bodies by default. Install either with APT if it is missing.

Examples

wget https://example.com/file.zip
wget -O archive.zip https://example.com/download
curl -O https://example.com/file.zip
curl -L -o archive.zip https://example.com/download
curl -I https://example.com

Useful options

  • wget -c attempts to continue a partial download
  • wget -O name chooses the output filename
  • curl -L follows redirects
  • curl -o name writes to a chosen filename
  • curl -O uses the remote filename
  • curl -I requests response headers

Safety

A successful download does not make a file trustworthy. Verify the site, HTTPS URL, checksum, or signature before opening or executing it.

Avoid patterns such as downloading a script and piping it directly to sudo sh; inspect downloaded scripts first.