How to use Curl on Ubuntu Linux with examples

This brief tutorial shows students and new users how to install and use the curl command on Ubuntu 18.04 | 16.04.

Many tools and software are available in Ubuntu to download and upload files from and to remote servers.

Curl is one of those tools and works with one of these supported protocols: FTP, HTTP, IMAP, LDAP, POP3, SCP, SFTP, SMB, SMBS, SMTP, TELNET, and TFTP to transfer data to and from remote servers.

If you’re a student or new user looking for a Linux system to start learning on, the easiest place to start is Ubuntu Linux OS.

It’s a great Linux operating system for beginners and folks looking for easier Linux distribution to use.

Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.

Installing Curl on Ubuntu

Curl packages are included in Ubuntu default repositories and installing is very simple.

To install, simply run the commands below.

sudo apt install curl

After installing, you can check to see if it’s installed and ready by typing the commands below and pressing enter.


It should output a similar line as shown below:

curl: try 'curl --help' or 'curl --manual' for more information

That’s all to it!

Curl is now ready to be used on Ubuntu.

Use Curl

As we mentioned above, Curl comes with many options. To see all available options to use the Curl, type this command: Curl --help

In its simplest form, you can use Curl to print out a source code or a website by running the commands below:


One of the many usages of Curl is to download files. When you use Curl with the -o or --output option, you can download a file and write it into a name you specify.

The -o, –output <file> Write to file instead of stdout


curl -o linux.tar.xz

When you use  Curl with an uppercase O option, you can download and save the file, preserving its original name.

The -O, –remote-name Write output to a file named as the remote file


curl -O

You can use Curl with an- I option if you want to look up a website header.


curl -I

That command above will print out the BBC website header;

HTTP/2 200 
server: Apache
nel: {"report_to":"default","max_age":2592000,"include_subdomains":true,"failure_fraction":0.01}
x-cache-action: HIT
cache-control: max-age=60
x-cache-age: 34
content-type: text/html
report-to: {"group":"default","max_age":2592000,"endpoints":[{"url":"","priority":1}],"include_subdomains":true}
expires: Fri, 21 Feb 2020 22:35:33 GMT
content-language: en
etag: "de4ad647a27f51ce00628a8709ce5e58"
accept-ranges: bytes

Curl provides many more functions. If you want to see all the options, run the command below:

curl --help

These are just some of the functions available:

Usage: curl [options.] 
     --abstract-unix-socket  Connect via abstract Unix domain socket
     --anyauth       Pick any authentication method
 -a, --append        Append to target file when uploading
     --basic         Use HTTP Basic Authentication
     --cacert  CA certificate to verify peer against

That’s it!


This post showed you how to install and use Curl on Ubuntu 18.04 | 16.04. If you find any error above, please report it in the comment form below.