How to Install Curl on Linux: A Step-by-Step Guide

install curl linux

Curl is a command-line tool that is used to transfer data from one server to another. It is widely used by developers and system administrators to download files, upload data, and interact with APIs. In this article, we will guide you through the process of installing curl on Linux.

Prerequisites

Before we proceed with the installation, make sure that you have the following prerequisites:

  • A Linux system (Ubuntu, CentOS, Debian, etc.)
  • A user account with sudo privileges
  • A terminal or SSH client

Step 1: Update the System

The first step is to update your Linux system to the latest version. Open your terminal and type the following command:

sudo apt update && sudo apt upgrade

This command will update the package lists and upgrade any outdated packages.

Step 2: Install Curl

Once the system is updated, you can install curl using the package manager of your Linux distribution. The following command will install curl on Ubuntu and Debian-based systems:

sudo apt install curl

If you are using a RedHat-based system like CentOS or Fedora, use the following command:

sudo yum install curl

Step 3: Verify the Installation

After the installation is complete, you can verify it by checking the version of curl. Open your terminal and type the following command:

curl --version

This will display the version of curl installed on your system.

Step 4: Using Curl

Now that curl is installed, you can start using it to download files, upload data, and interact with APIs. Here are some examples of how to use curl:

Download a File

To download a file using curl, use the following command:

curl -O https://example.com/file.zip

This will download the file and save it in the current directory.

Upload Data

To upload data using curl, use the following command:

curl -X POST -d '{"name":"John Doe","email":"johndoe@example.com"}' https://example.com/api

This will send a POST request to the API endpoint with the specified data.

Interact with APIs

To interact with an API using curl, use the following command:

curl https://api.example.com/users/1

This will send a GET request to the API endpoint and display the result in the terminal.

Conclusion

In this article, we have provided a step-by-step guide on how to install curl on Linux. We have also demonstrated how to use curl to download files, upload data, and interact with APIs. By following these instructions, you can start using curl in your development and system administration tasks.