What Is cURL and Why Would You Use It?

Use cURL to download content from web pages

The cURL command transfers data to or from a server using one of more than two dozen different protocols, and without direct user intervention.

How to Use the cURL Command

When you run the cURL command with a web address, for example, https://www.lifewire.com/curl-definition-2184508, the linked page is downloaded, and the source displays in the terminal window. You need the -o flag to download it to a file.

Linux cURL website download

Use cURL to download physical web pages, images, documents, and files. For example, to download the 16.04 version of Ubuntu Linux run the following command:

curl -o ubuntu.iso http://releases.ubuntu.com/16.04.1/ubuntu-16.04.1-desktop-amd64.iso
Linux cURL downloading file

Use the -o filename part of the cURL command to specify the output name of whatever you download.

Should I Use cURL Or Wget?

Whether you use cURL or Wget depends on what you want to achieve.

The Wget command downloads files from networks such as the internet. The main benefit of using the Wget command is that it recursively downloads files. Therefore, if you want to download an entire website, you can do so with one simple command. The Wget command is also good for downloading several files.

You can use the cURL command with wildcards to specify the URLs you wish to retrieve. For example, when there are valid URLs called http://www.mysite.com/images/image1.jpg and http://www.mysite.com/images/image2.jpg, you can download both images with a single URL specified with the cURL command.

curl http://www.mysite.com/images/image[1-2].jpg

The Wget command recovers when a download fails, whereas the cURL command doesn't.

The cURL command supports more protocols than the Wget command, and it provides better support for SSL. It also supports more authentication methods than Wget. The cURL command works on more platforms than the Wget command.

While downloading with cURL, a progress bar appears with a download or upload speed, how long the command has run, and how much time remains. The cURL command works on large files over 2 GB for both downloading and uploading, so this progress bar offers context for time-intensive file operations.