How to install curl command in Linux Ubuntu 20.04? Learn how to use curl command in Linux Ubuntu to download a file. Here are the few curl command examples to understand the functioning of the command.
What is curl?
curl is used in command lines or scripts to transfer data. It is also used in cars, television sets, routers, printers, audio equipment, mobile phones, tablets, settop boxes, media players and is the internet transfer backbone for thousands of software applications affecting billions of humans daily.
It supports DICT, FILE, FTP, FTPS, Gopher, 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, NTLM, Negotiate and Kerberos), file transfer resume, proxy tunneling and more.
curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. As you will see below, the number of features will make your head spin!
curl is powered by libcurl for all transfer-related features.
How to Install Curl
The most recent stable version is 7.71.1, released on 1st of July 2020. The curl is included in the default Ubuntu 20.04 repositories. Run the following commands to install curl:
sudo apt update sudo apt install curl
Once the installation is complete, run the command “curl” to verify:
curl
Using Curl for Downloads
The URL syntax is protocol-dependent. You’ll find a detailed description in RFC 3986. You can specify multiple URLs or parts of URLs by writing part sets within braces as in:
http://site.{one,two,three}.com
or you can get sequences of alphanumeric series by using [] as in:
ftp://ftp.numericals.com/file[1-100].txt
ftp://ftp.numericals.com/file[001-100].txt (with leading zeros)
ftp://ftp.letters.com/file[a-z].txt
Using Curl: Examples
To retrieve a web page and display in the terminal
curl http://www.sourcedigit.com/index.htm
The command will fetch the file index.htm from www.sourcedigit.com using the HTTP protocol, and display it to standard output (on screen). Note that using this command is similar to as “view source” of the webpage.
To retrieve a web page and display header information
curl http://www.sourcedigit.com -i
To retrieve a web page and save to a file.
curl http://www.sourcedigit.com -0 sourcedigit.html
To download via a proxy server
curl -x proxy.example.com:3128 http://www.sourcedigit.com/unix/
Note: The curl command displays a progress meter during its operations and it indicates the amount of transferred data, transfer speeds and estimated time left, etc. The command curl when executed, it displays data in the terminal (by default).
More Info: https://curl.haxx.se/ and https://github.com/curl/curl