What Is cURL and Why Would You Use It?

Use cURL to download content from web pages

Screenshot of the curl command in Ubuntu

 Screenshot

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

For example, if you ran the cURL command with the web address set to:

https://www.lifewire.com/curl-definition-2184508

the linked page will be downloaded.

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

The -o filename part of the cURL command lets you specify the output name of whatever you download.

Should I Use cURL Or Wget?

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

The Wget command is used to download 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 lots of files.

The cURL command lets you use wildcards to specify the URLs you wish to retrieve. So if you know there is a valid URL called:

http://www.mysite.com/images/image1.jpg

and

http://www.mysite.com/images/image2.jpg

Then you can download both images with a single URL specified with the cURL command.

The Wget command can recover when a download fails whereas the cURL command cannot.

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

While you're downloading with cURL a progress bar will appear with a download or upload speeds, how long the command has spent running thus far, and how much time remains. The cURL command works on large files over 2 GB for both downloading and uploading, so this progress bar helps offer context for time-intensive file operations.