Linux curl Command With Examples

The curl command line utility transfers files from or to the server. It allows the user to upload and download the data or files by utilizing any supported protocols such as HTTP, FTP, POP3, SMTPS, TFTP, and many others. It works without any user interaction. This command solves the query URLs mentioned in the command line.

This guide illustrates the Linux curl command purpose and works with examples. The table of content of this guide is defined here:

Let’s start with the installation of the “curl” utility.

Prerequisites: Install curl Utility

The “curl” command line tool is mostly available in the latest Linux distributions. However,  if it is not installed by default, then follow the below-mentioned commands to install it according to the Linux distributions:

For Fedora & CentOS

$ sudo yum install curl

For Ubuntu and Debian Based Systems

Install the “curl” command in the entire Ubuntu system by executing the specified command:

$ sudo apt install curl

As the output displays the “curl” command is already installed having the newest version “7.18.0”.

Tip: Check the installed “curl” version with the help of the “curl –version” command.

How Does the curl Command Work in Linux?

The working of the “curl” command relies on its syntax.


$ curl [option] [URL]

The syntax contains the following components:

  • curl: This main keyword represents the “curl” command.
  • option: Denotes the options or arguments supported by the “curl” command.
  • URL: specific URL that needs to be downloaded via the “curl” utility.

Run the “curl –help” command to get its essential options list that is helpful to perform specific tasks:

$ curl --help

The “output” shows the “Usage(syntax)” and “options” of the “curl” utility

As you can see in the “curl –help” page each option has its own functionality. To understand the functionalities of these options, follow the below-mentioned practical examples.

Example 1: Download a File

Simply, the “curl” command displays the URL’s content in the terminal without any argument. For downloading a single file, use the “-O” option of the “curl” command. In this example, the “curl” command downloaded the “asterisk-16-current” file as shown in the screenshot:

$ curl -O

Note: The user can also download more than one file at the same time by following the syntax:

$ curl -O -O

Example 2: Save the Downloaded File

The “-o” option helps to save the particular URL content into the new file with the specific name. To perform this action, type the “curl” command with the “-o” option and the specified filename and URL:

$ curl -o "google"

The above “curl” command displays the output in table format having nine columns. This format is known as a “progress meter”. It holds the complete package information in columns “Total”, “Received”, “xfered”, “Average”, “Speed”, and others.

On the other side, the capital “-O” argument saves the downloaded file with its default URL name:

$ curl -O

Example 3: Download Resume/Interrupted File

When the downloading of large files is stopped due to some reason, then utilize the “-C” option of the “curl” command. It will download the resumed file from where it stopped:

$ curl -C - --output output.pdf

The resumed file has been downloaded and saved with the name “output.pdf”.

Example 4: Show Headers of URL

Headers are a sort of indication for metadata or the request sent from the client to the server. The headers contain key values having information like decoding, type content, user information, and much more.

The “-I” option is useful for getting the headers of the mentioned URL:

$ curl -I --http2

The output only displays the “Ubuntu” headers.

Example 5: Follow the Redirection

By default, the “curl” command does not follow the redirection without any argument. But its “-L” argument tells the “curl” utility to follow any displayed redirects until the utility reaches its final destination.

$ curl -L

The output displays the response redirection of “” with the “-L” argument.

Example 6: Set the Rate Limit Speed

The “–limit-rate” option is used to set the “rate limit”, which is the percentage of speed that the “curl” command will use for downloading. The speed may be in KB, MB, GB, etc.

In this example, “20K” speed is set to download the specified URL:

$ curl --limit-rate 20k

In the above output, the column “Average Speed Dload” identifies that the current URL is downloading at the rate “20k”.

Example 7: Download a URL from FTP Server

The “-u” flag helps download the file from the FTP server. For this purpose, use the “-u” flag with the username, password, and the FTP URL:

$ curl -u demo:password -O

The output verifies that the “readme.txt” file has been downloaded from the FTP server.

That’s all from the curl command.


Linux offers the “curl” command utility to download or transfer the file from or to the server. It supports a wide range of protocols. The generalized syntax of the “curl” command is “$ curl [option] [URL]”. However, it provides a list of supported options that can be obtained via the “curl –help” command. This guide explains the curl command in detail with various practical examples.