---
layout: page
category-page: intermediate
category-title: Intermediate commands
tags: curl download http client crawler request online
author: Claudio Maggioni
title: curl
previous-page: pages/cmd/interm/chroot.html
next-page: pages/cmd/interm/fg.html
---
The curl
command is a fast and versatile shell program that can
request online content using various protocols, including HTTP,
FTP and POP3. Some example use cases for this utility are
the need to automate some remote call to a server, testing REST or
SOAP apis or simply download or display the HTML code of a
website.
The name, as mentioned in the
Evertything curl online book, stands for "client URL"
and the right pronunciation rhymes with "earl" or "girl". By this fact, the
reader is able to tell the author of this page to stop pronuncing it as
"cooorl", like if the name is some sort of word in the
Bergamasque
dialect.
curl
is a very complex command: if you want to learn it deeply,
please refer to the previously mentioned guide called
Evertything curl. Some basic
ways to use this command are shown below:
Example: Download the contents of the page "example.com" to "file.html"
curl example.com -o file.htmlExample: Download the contents of the page "en.wikipedia.org/wiki/Curl" to a file with the same name as the last element in the path (here "Curl")
curl -O en.wikipedia.org/wiki/CurlExample: Download the contents of the page "example.com" to "file.html"
curl example.com -o file.htmlExample: Download the contents of the page "example.com" following location redirects (
-L
flag)
curl -O -L example.comExample: Download the contents of the page "example.com" resuming a previous attempt (
-C
flag)
curl -O -C example.comExample: Do an HTTP DELETE request to "example.com" with a custom header (
-H
and -X
flags)
curl -H 'User-Agent: Tamagotchi' -X DELETE example.comExample: Print to stdout "example.com" making a request with HTTP basic authentication (
-u
flag)
curl -u bob:P@ssw0rd example.com