How to use cURL

This article describes how to use the cURL program to transfer files from the command line.

When to use cURL

If you need to transfer a file quickly from the command line, the cURL program is often the easiest way to do so. For example, you might need to download a .zip file or .tar.gz file that contains a code library for a project you are working on. With cURL, you can download the file directly to your account, instead of having to use an FTP client to download and transfer the file to your account.

How to use cURL

To start cURL, log in to your A2 Hosting account using SSH, and then type the following command:

curl

However, this command by itself does not accomplish much. Let's download a page from the example.com test domain:

curl -O http://example.com/test.html

Curl downloads the page to the current working directory. The -O option instructs cURL to download the output and save it in a file name that has the same name as the source document. In this case, it is test.html. If you open the test.html file on your account, you can see the HTML source page for example.com/test.html.

If you want to download a file and assign it a specific filename, use the -o option. For example, to download the example.com/test.html file to a file on the local account named download.html, type the following command:

curl -o download.html http://example.com/test.html

More Information

There are many more options available for the cURL program. To learn about them, type the following command:

man curl

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.