How to Install cURL on Ubuntu 22.04 or 20.04

cURL, a pivotal tool for transferring data with URL syntax, is renowned for its versatility and widespread use among developers and system administrators. If you need to install cURL on Ubuntu 22.04 Jammy Jellyfish or its older stable release of Ubuntu 20.04 Focal Fossa, understanding its core features and benefits is crucial.

Key Features of cURL:

  • Protocol Support: With support for numerous protocols like HTTP, HTTPS, FTP, and more, cURL facilitates interaction with various data sources and services.
  • Cross-Platform: Available on operating systems ranging from Windows and macOS to Linux, cURL ensures consistent functionality across different environments.
  • Command-Line Efficiency: The tool’s command-line interface is robust, allowing users to execute complex tasks, including sending customized HTTP requests and file transfers, with simple commands.
  • Libcurl Library: The underlying libcurl library is robust and supports multiple programming languages, making it an ideal choice for integrating cURL functionality into applications.

Why Choose to use cURL on Ubuntu?:

  • Customizable: With many command-line options, cURL can be tailored to meet specific user requirements for various requests and data transfers.
  • Performance: Known for its efficiency and speed, cURL is indispensable for managing large data volumes or working with applications where time is of the essence.
  • Reliability: With a legacy of stability and active maintenance since its inception, cURL is a reliable user tool.
  • Community Engagement: The active community around cURL contributes to its improvement and offers invaluable support and resources to users.

This introduction provides a glimpse into the capabilities of cURL. For detailed installation instructions, the following guide will walk you through the process to install cURL on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa using either the Ubuntu repository or a well-maintained PPA for the latest version.

Install cURL on Ubuntu 22.04 or 20.04 via APT

Step 1: Update Ubuntu Before cURL Installation

Before proceeding with this tutorial, ensuring your system is up-to-date with all existing packages is essential. Regularly updating your system helps maintain stability, security, and compatibility with the latest software.

To update your Ubuntu system, run the following command:

sudo apt update && sudo apt upgrade

This command first updates the package lists (with sudo apt update) and then upgrade installed packages to their latest versions (with sudo apt upgrade).

Step 2: Select Installation Option

In this step, you will choose between two installation options for cURL:

Method 1: Install cURL with Ubuntu Repository

The first method uses the default maintained version in your UbuntuThist users; this is satisfactory for most users recommended, especially in server-type environments. The Ubuntu repository contains a stable and tested version of cURL, ensuring compatibility and reliability.

To install cURL from the Ubuntu repository, run the following command:

sudo apt install curl

Method 2: Install cURL on Ubuntu 22.04 or 20.04 via PPA

To install cURL from a PPA, we will use the repository maintained by Rob Savoury. First, import the cURL PPA with the following command:

sudo add-apt-repository ppa:savoury1/curl34 -y

This command adds the specified PPA to your system’s package sources, enabling you to access the latest version of cURL provided by the repository.

Next, update your package lists to reflect the newly added PPA. This step ensures that your system recognizes the new source and retrieves the updated cURL package.

Run the following command to update your package lists:

sudo apt update

Now that you have added the PPA and updated your package lists, you can install the latest cURL version. If you have previously installed cURL using the Ubuntu repository, this step will upgrade your existing installation to the newer version.

To install or upgrade cURL from the PPA, run the following command:

sudo apt install curl

This command will either install cURL for the first time or update your existing installation to the latest version available in the PPA.

Step 3: Verify Installation of cURL on Ubuntu

Once you have installed cURL using either Method 1 or Method 2, verifying that the installation was successful is essential.

To verify the installation, run the following command:

curl --version

This command displays the installed version of cURL along with additional information, such as supported protocols and features. If the command outputs the cURL version details, the installation was successful.

Basic cURL Commands with Ubuntu 22.04 or 20.04

Now that you have successfully installed cURL, it’s time to learn some commands to help you get started with this versatile tool. This section will cover some basic cURL commands that demonstrate its capabilities and usage.

Retrieve a Web Page with cURL on Ubuntu

One of the most common tasks performed with cURL is retrieving a web page’s content. To do this, provide the URL of the page as an argument to the curl command:


This command fetches the HTML content of the specified web page and displays it in the terminal.

Save Output to a File with cURL on Ubuntu

If you want to save the output of a cURL command to a file instead of displaying it in the terminal, use the -o (output) option followed by the desired filename:

curl -o output.html

This command saves the HTML content of the specified web page to a file called output.html in the current directory.

Follow Redirects with cURL on Ubuntu

By default, cURL does not follow HTTP redirects. If you want cURL to follow redirects automatically, use the -L (location) option:

curl -L

This command fetches the content of the specified web page, following any redirects encountered along the way.

Send HTTP Headers with cURL on Ubuntu

To send custom HTTP headers with your request, use the -H (header) option followed by the header name and value in quotes:

curl -H "Accept-Language: en-US"

This command sends a custom Accept-Language header with the value en-US along with the request for the specified web page.

HTTP POST Requests with cURL on Ubuntu

cURL can also send HTTP POST requests with data. To send a POST request, use the -X (request) option followed by the POST method and the -d (data) option with the data you want to send:

curl -X POST -d "key1=value1&key2=value2"

This command sends an HTTP POST request with the specified data to the URL.

Closing Thoughts

This article outlined vital steps for installing or upgrading cURL on Ubuntu Linux. You’ve learned to update your system, select the appropriate installation method, and install cURL from either the official Ubuntu repository or a PPA for the newest version, along with mastering basic cURL commands showcasing its versatility. As you continue using cURL, leverage its robust and flexible utility for tasks ranging from simple data transfers to complex operations with authentication and file uploads, enhancing your projects’ diverse features.