How to Use cURL to Download Files

How to Use cURL to Download Files

When using the Terminal, there are usually two options for downloading files, using wget and using cURL to download files.

Of course, both have their own advantages and disadvantages, but cURL is typically used for downloading, especially in application installation tutorials.

However, if you want to try using cURL, here we will discuss a list of common commands used to download files using cURL.

Using cURL to Download Files Without Changing the Name

First, you can use cURL to download files without changing the name of the downloaded file. For example, if we are going to download a file from https://sin-speed.hetzner.com/100MB.bin, then the file will be saved as 100MB.bin.

To do this, you can add the parameter -O (capital O)

curl -O https://sin-speed.hetzner.com/100MB.bin

Using cURL to Download Files With a New Name

If you can use the capital O parameter to keep the name, you can use the lowercase o parameter to specify a new name, for example

curl -o wpgan-curl.bin https://sin-speed.hetzner.com/100MB.bin

Downloading Files from a Redirect

To download a file from a redirect, for example when you download WordPress, you will usually use the link https://wordpress.org/latest.zip, then you can use the parameter -L

curl -LO https://wordpress.org/latest.zip

You can also use the parameter -o to specify the name of the file to be saved

curl -Lo wordpress.zip https://wordpress.org/latest.zip

Downloading Files While Ignoring SSL

If the website you are accessing does not have SSL, you will usually get an error curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it.

To overcome this, you can use the parameter -k (lowercase k)

curl -kLO https://wordpress.org/latest.zip

Silent Download Using cURL

As you have seen in the previous examples, every time you run a cURL command, there will be information such as Average Dload, Speed Upload, Time Total, Time Spent, and others.

If you want to hide that information when using cURL, you can use the parameter -s (lowercase s)

curl -so wpgan-silent-curl.bin https://sin-speed.hetzner.com/100MB.bin

That is the list of commands you can use if you want to use cURL to download files. For other parameters that can be used, you can check them with one of the following commands

curl --help
curl -h
curl --manual

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...