- How to Install Curl in Linux
- Install curl on Ubuntu/Debian
- Install curl on RHEL / CentOS / Fedora
- Install curl on OpenSUSE
- Install curl on ArchLinux
- How to Install cURL on Ubuntu 22.04 | 20.04
- Section 1: Install cURL
- Step 1: Update Ubuntu
- Step 2: Select Installation Option
- Method 1: Install cURL with Ubuntu Repository
- Method 2: Install cURL from PPA
- Step 3: Verify Installation
- Section 2: Basic cURL Commands
- Example 1: Retrieve a Web Page
- Example 2: Save Output to a File
- Example 3: Follow Redirects
- Example 4: Send HTTP Headers
- Example 5: HTTP POST Requests
- Closing Thoughts on Installing cURL on Ubuntu Linux
- Additional Resources and Links
- Установка curl в Ubuntu
- Установка curl в Ubuntu
- Выводы
How to Install Curl in Linux
In this article, you will learn how to install the curl command-line tool for transferring data to and from a server using various types of requests. It’s an alternative to downloading files other than using wget command.
The curl command downloads files that are served with FTP, HTTP, SCP, IMAP, and other various supported protocols. It’s an amalgamation of the words World Wide Web and it is used in Unix/Linux systems to download files and packages on the Linux terminal.
On this page
Install curl on Ubuntu/Debian
In modern systems, curl comes pre-installed. However, If you are running an instance of Ubuntu or Debian, issue the command.
To verify the curl installation, run.
Install curl on RHEL / CentOS / Fedora
To install curl on RHEL, CentOS and Fedora distros, log in via SSH as root and run the command.
To confirm the installation of curl, run.
Install curl on OpenSUSE
On OpenSUSE, install curl by running.
To confirm the installation of curl run.
Install curl on ArchLinux
To install Curl on ArchLinux, run.
And finally, to confirm its installation run the command.
To know more about curl command usage and examples, I suggest you read our following article that explains how you can use curl command-line utility for downloading files from the web.
And with that, we have come to the end of this guide. In this tutorial, you learned how to install curl in different Linux distributions.
How to Install cURL on Ubuntu 22.04 | 20.04
cURL, which stands for Client URL, is an essential command-line tool and library designed for transferring data using various network protocols. This powerful utility has become a favorite among developers and system administrators due to its flexibility, reliability, and ease of use. In this introduction, we will cover some of the key aspects that make cURL stand out from other similar tools.
Key Features:
- Wide Range of Protocols: cURL supports a vast array of protocols, including HTTP, HTTPS, FTP, FTPS, SFTP, SCP, TFTP, LDAP, LDAPS, SMTP, POP3, IMAP, and more. This makes it incredibly versatile for working with different data sources and services.
- Cross-Platform Compatibility: cURL is available for virtually every operating system, such as Windows, macOS, Linux, and even mobile platforms like iOS and Android. This ensures seamless integration across various platforms and environments.
- Powerful Command Line Interface: cURL provides an extensive set of command-line options, enabling users to perform complex tasks with just a single command. This includes sending HTTP requests with custom headers, cookies, and authentication, uploading or downloading files, and much more.
- Robust Library: The libcurl library, which powers the cURL command-line tool, is a solid and widely-used library for integrating cURL functionality into your applications. It offers bindings for multiple programming languages, such as C, C++, Python, PHP, Ruby, and more.
Why cURL over other alternatives?
cURL has several advantages over similar tools, making it a popular choice for many tasks:
- Highly Configurable: cURL offers an extensive set of command-line options, enabling users to customize their requests and transfers according to their specific needs.
- Performance: cURL is known for its speed and efficiency, which is essential for handling large volumes of data or working with time-sensitive applications.
- Reliability: cURL has a long history of stability and has been actively maintained since its inception, ensuring a reliable and up-to-date tool for users.
- Community Support: With its widespread adoption, there is a large and active community of users and developers contributing to cURL’s continuous improvement, as well as providing support and resources to help users get the most out of the tool.
This guide will demonstrate how to install cURL on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa using Ubuntu’s repository or for those that seek the latest version of cURL using a well-known maintained PPA that contains the latest version.
Section 1: Install cURL
Step 1: Update Ubuntu
Before proceeding with this tutorial, it is essential to ensure your system is up-to-date with all existing packages. 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 upgrades 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 Ubuntu repository. For most users, this is satisfactory and 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:
Method 2: Install cURL from 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 can retrieve the updated cURL package from it.
Run the following command to update your package lists:
Now that you have added the PPA and updated your package lists, you can proceed with installing the latest version of cURL. 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:
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
Once you have installed cURL using either Method 1 or Method 2, it’s essential to verify that the installation was successful. Doing so ensures that cURL is correctly installed and functioning as intended.
To verify the installation, run the following command:
This command displays the installed version of cURL along with some additional information, such as supported protocols and features. If the command outputs the cURL version details, the installation was successful.
Section 2: Basic cURL Commands
Now that you have successfully installed cURL, it’s time to learn some essential commands to help you get started with this versatile tool. In this section, we will cover some basic cURL commands that demonstrate its capabilities and usage.
Example 1: Retrieve a Web Page
One of the most common tasks performed with cURL is to retrieve the content of a web page. To do this, simply 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.
Example 2: Save Output to a File
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 https://example.com
This command saves the HTML content of the specified web page to a file called output.html in the current directory.
Example 3: Follow Redirects
By default, cURL does not follow HTTP redirects. If you want cURL to follow redirects automatically, use the -L (location) option:
This command fetches the content of the specified web page, following any redirects encountered along the way.
Example 4: Send HTTP Headers
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" https://example.com
This command sends a custom Accept-Language header with the value en-US along with the request for the specified web page.
Example 5: HTTP POST Requests
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" https://example.com/post
This command sends an HTTP POST request with the specified data to the given URL.
Closing Thoughts on Installing cURL on Ubuntu Linux
Throughout this article, we have covered the essential steps to install or upgrade cURL on Ubuntu Linux. By following these instructions, you have learned how to update your system, choose the right installation method, and install cURL from either the official Ubuntu repository or a PPA for the latest version. Additionally, we explored basic cURL commands that demonstrate the versatility of this powerful tool.
As you progress in your journey with cURL, remember that it is a powerful and flexible utility capable of handling various tasks, from simple data transfers to more complex operations involving authentication, file uploads, and more. Keep exploring its features and applying them to your projects to make the most of cURL’s capabilities.
Additional Resources and Links
To further enhance your understanding of cURL and learn more about its features, we have compiled a list of official resources and documentation:
- cURL Official Website: The official website for cURL provides comprehensive information about the project, including news, downloads, and documentation.
- cURL Documentation: This is the official documentation for cURL, which covers its features, command-line options, and use cases in detail. This resource is ideal for those who want to dive deeper into cURL’s capabilities.
- libcurl – The Multiprotocol File Transfer Library: libcurl is the library that powers cURL. This resource provides information on how to integrate libcurl into your applications to enable powerful data transfer capabilities.
Установка curl в Ubuntu
Если установочный скрипт выдаёт ошибку: bash: curl: command not found или bash: curl: команда не найдена. Это значит что такой команды нет в вашей системе. Решение простое – установить утилиту curl. Эта утилита для скачивания файлов хоть и не так популярна, как wget, но может предоставить больше возможностей, а также имеет в своём составе библиотеку, которую можно подключить к другим программам.
Мы рассмотрим как установить curl в Ubuntu 20.04. Но инструкция будет актуальна и для более новых или старых версий дистрибутива.
Установка curl в Ubuntu
Представим вполне реальную ситуацию. Вы решили установить приложение с помощью скрипта .sh. Для скачивания скрипта предлагают использовать команду curl, она также может оказаться и в самом скрипте. Однако по умолчанию эта утилита не установлена в Ubuntu 20.04, поэтому при попытке запуска скрипта вы увидите ошибку curl: команда не найдена. А если вы попробуете запустить непосредственно саму утилиту, то сообщение будет выглядеть следующим образом: bash: /usr/bin/curl: Нет такого файла или каталога. Для установки curl следует использовать такие команды:
После установки скрипт, содержащий команду curl, должен заработать. Для того чтобы узнать версию утилиты выполните:
Эта команда может быть важна, так как программа активно развивается и каждый раз исправляются десятки ошибок и добавляются новые функции. Для того чтобы скачать файл используйте такую команду:
curl -OC — https://releases.ubuntu.com/20.04.2.0/ubuntu-20.04.2.0-desktop-amd64.iso
О других аргументах и способах их использования можете узнать в нашем материале.
Выводы
Утилита curl получила широкое распространение. Она доступна на всех актуальных настольных операционных системах. В Ubuntu 20.04 утилита не предустановлена, но доступна в репозитории и теперь вы знаете как выполняется установка curl Ubuntu.
Описанная ошибка чаще всего встречается только на недавно установленном дистрибутиве. Так как библиотека libcurl используется большим количеством приложений и рано или поздно будет установлена в вашей системе вместе с curl.
Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.