Downloading in Linux: curl and wget
Updated November 1, 2026
curl and wget reach the network from the terminal: they fetch files and send HTTP requests.
Common cases
curl https://example.com # print a page to the terminal
curl -O https://site/file.tar.gz # save to a file of the same name
curl -L -o out.html https://site # -L follow redirects, -o name
wget https://site/file.tar.gz # just download a file
curl -I https://site # response headers only
curl -fsSL https://site/script.sh # quiet, and fail on errorsSample output
$ curl -I https://example.com
HTTP/2 200
date: Sun, 26 Jul 2026 04:20:37 GMT
content-type: text/html
server: cloudflare
last-modified: Tue, 21 Jul 2026 07:16:00 GMT
...
$ curl -sI http://github.com
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Location: https://github.com/How it works: curl versus wget
wgetis built for one thing: download a file (and it can resume and mirror a whole site).curlis broader - a tool for any request: set the method, headers, body, and see the response. That is why curl shows up in scripts and when working with an API. The-fsSLflags on curl are a common set for install scripts:-ffail on an HTTP error,-squiet,-Sstill show the error,-Lfollow redirects. Do not run a downloaded script blindly - read it first.
Common mistakes
curl treats 404 as a normal answer. curl -s -o page.html https://example.com/nope; echo $? prints 0, and the error page lands in the file. The -f flag changes that: curl: (22) The requested URL returned error: 404 and exit code 22. wget works the other way round: wget -q https://example.com/nope exits 8 and writes ERROR 404: Not Found. Because of this difference, a script ported from wget to curl starts downloading junk without saying a word.
curl does not follow a redirect, wget does. curl -sI http://github.com returns HTTP/1.1 301 Moved Permanently with a Location: https://github.com/ header and an empty body, so without -L you save zero bytes. That is where the empty file comes from when you expected an archive.
-O and -o are different flags and people mix them up all the time. Capital -O saves under the name from the URL; small -o wants a name right after it. curl -so https://example.com eats the URL as a file name and answers curl: (2) no URL specified. And curl -O https://example.com/ on an address ending in a slash gives curl: Remote file name has no length plus curl: (23) Failed writing received data to disk/application: there is no name to take.
In the book
This topic is covered in full in the chapter The Linux network stack.