Using cURL and Wget to Download Files

12 December, 2023

As much as I preach about not needing jump to a terminal to effectively use Linux, there are times when a little knowledge of the command line comes in handy. One of those times is when you want to grab a file off the web.

Sure, you can do that in your web browser by right clicking on a link and choosing a save option. But if you can do that, and more, with two terminal commands: cURL and Wget. Let’s take a quick look at the basics of how to use both of them.

using cURL

In case you’re wondering, cURL is short for Client for URLs. cURL’s primary purpose in life is to move data between computers — like between a web server and your desktop or laptop.

How do you use it? Crack open a terminal window and from there, go to the directory in which you want to save the file you’re going to download. Then, enter this command:

curl -O [URL]

Replace [URL] with the full URL (along with the file name) of what you want to download.

Let’s say you want to download the file Super-Terrific-Demo.ogv from the website of online conglomerate CompuGlobalHyperMegaNet. To do that, use this command:

curl -O https://compuglobalhypermeganet.io/media/Super-Terrific-Demo.ogv

Some Useful Options

cURL has several other options that you might find useful. Here are two of them:

If your download stalls for whatever reason, you can re-run cURL with the -C option. The download restarts at the point at which it stalled.

You can also run cURL in the background by adding the -b option to command. That way, you can use the same terminal window (or the same tab in the terminal window) to do other tasks while a file is downloading.

Using Wget

Wget, short for World Wide Web get, differs from cURL in that you can use it to grab a single file, to download the contents of directories, or to grab entire websites.

To download a file using Wget, go to the command line and navigate to the directory in which you want to save what you’re going to download. Then, type this command:

wget [URL]

Replace [URL] with the full URL to the file that you want to download. If you don’t specify a file name, Wget pulls down the entire directory.

Two Handy Options

Here are two options that come in handy when you’re using Wget.

To download a file but save it on your computer with a different name, add the option –output-document=[new-file-name], where [new-file-name] is the name and extension that you want to give the file.

To resume a stalled or stopped download, add the –continue option to the command. Wget picks up from where the download stopped.

Getting More Information

This post just barely scratched the surface of what cURL and Wget can do. If you’re interested in diving more deeply into both, here’s some information that can help you:

Scott Nesbitt