cURL Command in Linux with examples

Reading Time: 2 minutes

cURL, which stands for client URL, is a command-line tool that developers use to transfer data to and from a server.

At the most fundamental, cURL lets you talk to a server by specifying the location (in the form of a URL) and the data you want to send.

cURL supports several different protocols, including HTTP and HTTPS, and runs on almost every platform.

This makes cURL ideal for testing communication from almost any device (as long as it has a command line and network connectivity) from a local server to most edge devices.

The most basic command in curl is curl http://example.com. The curl command is followed by the URL, from which we would like to retrieve some kind of data.

What’s curl used for?

CURL is used in command lines or scripts to transfer data.

CURL is also applied in cars, television sets, routers, printers, audio equipment, cell phones, tablets, settop boxes, media game enthusiasts and is the Internet transfer engine for hundreds of software program application applications in over ten billion installations.

Who makes curl?

The unique writer and lead developer is the Swedish developer Daniel Stenberg, who created cURL due to the fact he desired to automate the fetching of currency exchangefor IRC users. Curl is free and open sourcesoftware and exists thanks to thousands of contributors and our awesome sponsors.

Supports…

DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP.

curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, HTTP/2, HTTP/3, cookies, user+password authentication (Basic, Plain, Digest, CRAM-MD5, SCRAM-SHA, NTLM, Negotiate and Kerberos), file transfer resume, proxy tunneling and more.

Syntax:

curl [options] [URL…]

URL : The most basic uses of curl is typing the command followed by the URL.

curl http://www.example.com

URLs with numeric series collection may be written as:

curl ftp://ftp.example.com/file[1-20].jpeg

Progress Meter: curl presentations a development meter throughout use to signify the switch rate, quantity of information transferred, time left etc.

curl -# -o ftp://ftp.example.com/file.zip
curl --silent ftp://ftp.example.com/file.zip

If you want a development bar as opposed to meter, you may use the -# alternative as in the instance above, or –silent in case you need to disable it completely.

Options:

-o : saves the downloaded report at the neighborhood gadget with the call furnished withinside the parameters.

Syntax:

curl -o [file_name] [URL...]

-C – : This alternative resumes down load which has been stopped because of a few reason. This is beneficial while downloading massive documents and turned into interrupted.

Syntax:

curl -C - [URL...]

–limit-rate : This alternative limits the top sure of the rate of records switch and continues it across the given rate in bytes.

Syntax:

curl --limit-rate [value] [URL]

-u : curl also provides options to download files from user authenticated FTP servers.

Syntax:

curl -u {username}:{password} [FTP_URL]

-T : This option helps to upload a file to the FTP server.

Syntax:

curl -u {username}:{password} -T {filename} {FTP_Location}

If you want to append a already present FTP file you may use the -a or –append option.

-u : curl also provides options to download files from user authenticated FTP servers.

Syntax:

curl -u {username}:{password} [FTP_URL]

Written by 

Ashi Dubey is a Software Intern at Knoldus Inc Software. She has a keen interest toward learning new technologies. Her practice area is Devops. When not working, you will find her with a Book.