Side by Side
| wget | curl | |
|---|---|---|
| Default output | A file | The screen |
| Redirects | Followed | Only with -L |
| Recursive download | Yes, -r | No |
| Resume | -c | -C - |
| Retries | 20 by default | --retry |
| HTTP methods | GET, others with --method | Any, with -X |
| Uploads and forms | Limited | -T and -F |
| Protocols | HTTP, HTTPS, FTP | Many more |
| Library | None | libcurl |
curl is also a library, libcurl, which many programs and programming languages use for their own HTTP requests. That is one reason it is found on so many systems. On AlmaLinux and Rocky Linux the preinstalled build can be curl-minimal, which handles fewer protocols than the full package.
Download a File
wget https://example.com/files/app.tar.gz
curl -LO https://example.com/files/app.tar.gz
curl -L -o app.tar.gz https://example.com/files/app.tar.gz
wget saves under the name in the address with no options. curl needs -O to do the same, or -o to choose a name, and -L to follow redirects. The two common curl mistakes are forgetting -L, which saves a short redirect page instead of the file, and forgetting -O, which prints a binary file into the terminal. Each tool has its own guide: the wget command and how to download a file with curl.
Resume and Retry
wget -c https://example.com/files/big.iso
curl -L -C - -O https://example.com/files/big.iso
curl -L --retry 5 -O https://example.com/files/big.iso
Resuming works only when the server supports range requests; most file servers do.
What wget Does Best
- Mirroring: it follows links and saves a site or a folder tree with its structure. Use it only on sites you run or have permission to copy.
- Lists of files:
-i urls.txtdownloads every address in a file. - Long downloads:
-bsends it to the background and writes progress to a log file.
wget --mirror --convert-links --page-requisites --no-parent https://example.com/docs/
What curl Does Best
curl shows exactly what a web server answers, which makes it the first tool for checking your own site:
curl -I https://example.com
curl -sv -o /dev/null https://example.com
curl -s -o /dev/null -w "%{http_code} %{time_total}\n" https://example.com
curl --resolve example.com:443:203.0.113.10 -I https://example.com
The first line prints the response headers, the second the full exchange including the TLS handshake, and the third only the status code and total time. The last one sends the request to a server you name, which tests a site on a new server before you change DNS. curl also sends any method with a body: see how to send a POST request with curl.
Which One Is Installed?
command -v curl wget
The command prints the path of each tool it finds. curl is installed on most current server images; wget is often missing from minimal installs. Install what is missing with sudo apt install curl wget on Debian and Ubuntu, or sudo dnf install wget on AlmaLinux and Rocky Linux, where curl is already present. All of these releases ship GNU Wget 1.x as wget. A script meant to run on many servers is safer depending on curl.
Piping a Download into a Shell
Many install instructions pipe a script from curl or wget straight into sh. That runs whatever the server sends, as you, and as root when sudo is involved. Download it first, read it, then run it:
curl -fsSL -o install.sh https://example.com/install.sh
less install.sh
bash install.sh
-f makes curl fail on an HTTP error instead of saving the error page as the script.
Which to Use
- A plain download by hand: either; wget is shorter to type.
- Mirroring or many files: wget.
- APIs, headers, uploads, and testing a web server: curl.
- Scripts for many servers: curl, because it is more often present.