Gice

Technology and General Blog

The Linux curl command is a utility that transfers details to and from a server more than the net. With the curl command, you can down load documents on the world-wide-web around a extensive array of supported protocols these kinds of as SCP, FTP, HTTP, and HTTPS just to point out a several. Between the alternatives delivered by the Linux curl command, this contains proxy assist, bandwidth restricting, and the ability to resume file downloads in circumstance of downtime. In this guide, we appear at the curl command and offer some of the case in point usages.

Simple Syntax

Curl command can take the syntax proven down below:

Installing Curl

Remarkably, the Linux curl command does not occur pre-installed in all Linux distributions. Just to confirm if curl is installed, you can operate the following command to look at the curl edition

From the output, I’m employing curl edition 7.68.

If curl is not set up, you may well face the mistake curl command not identified. To deal with this, you need to have to set up the curl command-line utility.

So, here’s how you can go about the installation.

Put in Curl on Ubuntu / Debian Distributions

If your Debian or Ubuntu distro does not arrive with curl, set up it as follows

$ sudo apt install curl (For newer versions of Ubuntu)

$ sudo apt-get install curl (For older versions of Ubuntu)

Set up Curl on RHEL/CentOS Distributions

If you are operating RHEL or CentOS, set up curl as follows:

Set up Curl on Fedora

For Fedora, set up curl as follows:

Down load a File Using the Curl Command

In its primary form, the curl command is made use of to down load documents over the web with the -O selection.

The -O option displays the development meter of a file download. Also, it will save the file in its authentic identify.

For illustration, to down load the newest WordPress compressed file, operate the command:

$ curl -O https://wordpress.org/hottest.tar.gz

Download Several Data files Employing the Curl Command

The curl command also gives you the selection of downloading several documents in a person command working with the syntax demonstrated under.

$ curl -O url_1  O url_2

For occasion, to obtain the compressed WordPress file and the Linux kernel tarball in just one command, run the command:

$ curl -O https://wordpress.org/newest.tar.gz -O https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.12.2.tar.xz

Resume an Interrupted File Down load

If you are downloading a file and your connection suddenly drops, do not fret. You can move the -C alternative to resume the file download.

If, for occasion, you were being downloading a file more than the world wide web as follows,

$ curl -O https://wordpress.org/most recent.tar.gz

In the celebration that the relationship drops, you can simply resume the down load with the -C alternative.

$ curl -C-O https://wordpress.org/most up-to-date.tar.gz

Limit the Obtain Level

Curl command can eat substantial amounts of your bandwidth. The velocity is typically in bytes/seconds without any arguments. Having said that, you can cap the facts transfer fee by using the –limit-charge possibility followed by the value as follows:

Kilobytes    – k or K

Megabytes – m or M

Gigabytes – g or G

$ curl –restrict-rate [value] [URL]

For illustration, the command down below restrictions the download fee of the Go binary file to 500 kilobytes/sec.

$ curl –limit-charge 500k -O https://golang.org/dl/go1.16.4.linux-amd64.tar.gz

Seize HTTP Headers of a URL

HTTP headers variety the core section of HTTP requests and contains details about the asked for webpage these kinds of as the style of the world-wide-web server, the model of HTTP being made use of, material style, material length and so substantially extra.

The -I possibility lets you print out the HTTP headers employing the syntax as follows:

For instance:

$ curl -I https://linuxways.internet

Transfer Documents Using FTP Protocol

Finally, the curl command presents you with the capability to download a file from an FTP server with authentication using the -u possibility.

$ curl -u username:password [FTP_URL]

To add a file to the FTP server, use the -T choice as proven:

$ curl -u username:password -T file FTP_URL

Conclusion

As you have observed, the curl command is fairly a multipurpose command-line utility that facilitates file transfer above various protocols. These are just a several examples. For more alternatives, head above to the documentation web site.

Leave a Reply

Your email address will not be published. Required fields are marked *