Installing Curl

The curl package is pre-installed on most Linux distributions today.

To check whether the Curl package is installed on your system, open up your console, type curl, and press enter. If you have curl installed, the system will print _curl: try 'curl --help' or 'curl --manual' for more information_. Otherwise, you will see something like _curl command not found_.

If curl is not installed you can easily install it using the package manager of your distribution.

Install Curl on Ubuntu and Debian

sudo apt update
sudo apt install curl

Install Curl on CentOS and Fedora

sudo yum install curl

How to Use Curl

The syntax for the curl command is as follows:

curl [options] [URL...]

Copy

In its simplest form, when invoked without any option, curl displays the specified resource to the standard output.

For example, to retrieve the example.com homepage you would run:

curl example.com

The command will print the source code of the example.com homepage in your terminal window.

If no protocol is specified, curl tries to guess the protocol you want to use, and it will default to HTTP.

Save the Output to a File

To save the result of the curl command, use either the -o or -O option.

Lowercase -o saves the file with a predefined filename, which in the example below is vue-v2.6.10.js:

curl -o vue-v2.6.10.js https://cdn.jsdelivr.net/npm/vue/dist/vue.js

Uppercase -O saves the file with its original filename:

curl -O https://cdn.jsdelivr.net/npm/vue/dist/vue.js
Curl Command in Linux with Examples
2.10 GEEK