The Curl is a versatile and cross-platform command line utility that helps us transfer/share data over different protocols including FTP, HTTP, SCP, SFTP, and many others. The Curl is a client-side utility URL that empowers you to interact with the network resources to retrieve the data by harnessing the power of the “libcurl” library.

Quick answer

To install curl on Ubuntu 24.04, run sudo apt install curl. After that, use curl URL to fetch a page, curl -O URL to download a file, or curl options to test API and HTTP responses.

How to Install Curl on Ubuntu 24.04

To install the Curl utility on Ubuntu 24.04, execute the below command:

sudo apt install curl
Terminal output of sudo apt install curl on Ubuntu 24.04

To verify the installation, check the Curl utility’s version by executing the following command:

curl --version
Terminal output of curl --version on Ubuntu 24.04

How to Use the Curl on Ubuntu 24.04

Let’s understand the use of the Curl utility on Ubuntu 24.04 starting with its syntax.

Curl Command Syntax

curl [options] [URL]

Here, 

  • The “curl” invokes the Curl command.
  • The “options” are specified to control the behavior of the Curl command. It includes a few flags or options that let us customize the output.
  • The “URL” specifies the web address or the URL of the resource you are interacting with.

Let’s dig deeper into the Curl command using the following examples.

Example 1: Download a File Using the Curl on Ubuntu 24.04

To download a file from a server using the curl on Ubuntu 24.04, run the following command and replace the URL with the URL from where you want to download the file:

curl -O https://releases.ubuntu.com/jammy/ubuntu-22.04.4-desktop-amd64.iso
Terminal output of curl -O downloading Ubuntu ISO on Ubuntu 24.04

Note: You can stop or interrupt the downloads by pressing the Ctrl + C keys. These downloads can be resumed in the current session.

Example 2: Resume the interrupted Download

If your download is interrupted (when you press the Ctrl + C keys), you can resume it using the Curl command’s “-C” flag, as follows:

curl -C - https://releases.ubuntu.com/jammy/ubuntu-22.04.4-desktop-amd64.iso -O
Terminal output of curl -C resuming interrupted download on Ubuntu 24.04

Here, the “-C” flag specifies the Curl command to download the rest of the file from the specified URL.

Example 3: Download Data With the Progress Bar Using the Curl Command on Ubuntu

If you want to view a progress bar instead of the downloading stats (Total, Received, Xferd Average speed, etc), use the “-#” as follows:

url -# -O https://releases.ubuntu.com/jammy/ubuntu-22.04.4-desktop-amd64.is
Terminal output of curl -# download with progress bar on Ubuntu 24.04

Example 4: Do a Basic GET Request Using the Curl Command on Ubuntu 24.04

If you specify no options/flags for the Curl command, it treats everything as a URL and dumps its HTML code (if found) on the terminal, as illustrated below:

curl https://www.wikipedia.org
Terminal output of curl https://www.wikipedia.org showing HTML dump on Ubuntu 24.04

Example 5: Do a POST Request Using the Curl Command on Ubuntu 24.04

If you want to perform a POST request to a server using the Curl Command on Ubuntu, execute the following command and replace the credentials and replace the URL:

curl -X POST -d "name=name&[email protected]" https://your-server.com/submit_form.php

Example 6: Check HTTP Headers Using the Curl Command on Ubuntu 24.04

The HTTP Headers are the meta-data that accompany every request and response on the internet. You can view the HTTP Headers using the Curl command on Ubuntu 24.04 by executing the below command:

curl -I https://www.github.com
Terminal output of curl -I showing HTTP headers for github.com on Ubuntu 24.04

Example 7: Download the Files That Require Authentication Using the Curl Command on Ubuntu 24.04

For added security, there are many password-protected files on the servers. To download such password-protected files using the Curl command on Ubuntu 24.04, use the following command and add the credentials required to access the file:

curl -u username:password https://somewebsite.server.com/data.zip

When curl is useful

Curl is most useful when you need to test a URL, download a file from Terminal, check headers, or send a quick request to an API without opening a browser.

If a command copied from a website uses curl with a pipe into another command, read it first. Curl is powerful, and piping downloaded scripts directly into a shell should only be done when you trust the source.

Related Ubuntu 24.04 guides