How to Install cURL on Linux Mint 21/20

cURL, which stands for Client for URLs, is a popular command-line tool for transferring data using various network protocols. It was created by Daniel Stenberg in 1997 and has since become an essential tool for web developers, system administrators, and network specialists. In this introduction, we will explore the key features and capabilities of cURL before diving into how to use it on Linux Mint.

Key Features and Capabilities:

  • Support for Multiple Protocols: cURL supports a wide range of protocols, including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, LDAP, LDAPS, DICT, TELNET, RTMP, and many more. This flexibility allows users to transfer data across different services and platforms seamlessly.
  • Cross-Platform Compatibility: cURL is available for various operating systems, including Linux, macOS, Windows, and numerous Unix-like systems. Its cross-platform nature makes it an ideal tool for users working in diverse environments.
  • Command-Line Interface: cURL operates as a command-line tool, providing users with a simple yet powerful way to perform data transfers. Users can issue commands with various options to customize the data transfer process, such as setting timeouts, following redirects, and specifying authentication credentials.
  • Scripting and Automation: Due to its command-line nature, cURL can be easily integrated into scripts and automation workflows. This capability makes it a valuable tool for developers and administrators looking to automate repetitive tasks or build custom data transfer solutions.
  • Proxy Support: cURL supports various types of proxies, such as HTTP, HTTPS, and SOCKS, allowing users to work behind firewalls or access restricted resources. Proxy configurations can be easily managed using command-line options.
  • SSL/TLS Support: cURL provides secure data transfer capabilities by supporting SSL/TLS encryption. This feature ensures that sensitive data remains protected during transfer, making it suitable for use in secure environments.
  • Verbose and Debugging Options: cURL offers a range of verbose and debugging options, making it easier for users to troubleshoot issues and optimize their data transfer processes. These options provide insight into the inner workings of the tool and the underlying protocols.

This guide will demonstrate how to use cURL on Linux Mint 21 or Linux Mint 20 with the command line and two separate methods with APT, the default repository, or using a Launchpad PPA containing the latest cURL versions available.

Section 1: Install cURL with Default Repository

Step 1: Update Linux Mint

Before proceeding, it’s essential to ensure your Linux Mint system is up-to-date with all existing packages. This ensures that you have the latest security patches and software updates. To update your system, execute the following command:

sudo apt update && sudo apt upgrade

This command will update the package list and upgrade all packages to their latest versions.

Step 2: Install the cURL Package

Once your system is updated, you can install the cURL package using the default repository. To do this, execute the following command:

sudo apt install curl

This command installs the cURL package along with its dependencies.

Step 3: Confirm cURL Installation

After installing cURL, you should verify that it has been installed correctly. To do this, execute the following command:

curl --version

Section 2: Install cURL from PPA

Step 1: Import cURL PPA

If you want to install the latest cURL version from a PPA (Personal Package Archive), you can use the following PPA. This PPA contains the most recent cURL versions available. To import the PPA, execute the following command:

sudo add-apt-repository ppa:savoury1/curl34 -y
sudo add-apt-repository ppa:savoury1/build-tools -y
sudo add-apt-repository ppa:savoury1/backports -y
sudo add-apt-repository ppa:savoury1/python -y
sudo add-apt-repository ppa:savoury1/encryption -y

In addition to the cURL repository, other PPAs maintained by the same developer are necessary since the cURL version relies on dependencies from these PPAs. These PPAs will also update additional packages, such as wget.

Step 2: Update Package List and Install or Upgrade cURL

Now that the PPA has been added, you should update your package list to include the new repository’s packages. After updating the package list, you can install or upgrade cURL to the latest version available in the PPA. To do this, execute the following commands:

sudo apt update
sudo apt install curl

These commands will update the package list and either install the latest cURL version or upgrade your existing cURL installation to the most recent version available in the PPA.

Step 3: Verify cURL Installation

After installing or upgrading cURL from the PPA, it’s essential to verify that it has been installed correctly. To do this, execute the following command:

curl --version

This command will display the cURL version and other relevant information, confirming a successful installation or upgrade.

Section 3: Common cURL Commands

This section will explore ten common cURL commands to help you start using cURL effectively.

Command 1: Download a File

To download a file using cURL, execute the following command:

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

This command downloads the specified file and saves it with the same name in the current directory.

Command 2: Upload a File

To upload a file using cURL, execute the following command:

curl -T file.zip ftp://ftp.example.com/ --user username:password

This command uploads the specified file to the FTP server using the provided username and password for authentication.

Command 3: Follow Redirects

To follow redirects when downloading a file, execute the following command:

curl -L https://example.com/redirect

This command will follow any HTTP redirects and download the target file.

Command 4: Send a GET Request

To send a GET request using cURL, execute the following command:

curl https://example.com/api/data

This command sends an HTTP GET request to the specified URL and displays the response in the terminal.

Command 5: Send a POST Request

To send a POST request with data using cURL, execute the following command:

curl -X POST -d "key=value&key2=value2" https://example.com/api/data

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

Command 6: Set a Custom User Agent

To set a custom user agent when sending a request, execute the following command:

curl -A "Custom User Agent" https://example.com

This command sends a request to the specified URL with a custom user agent in the request header.

Command 7: Set Request Headers

To set custom headers when sending a request, execute the following command:

curl -H "Authorization: Bearer token" -H "Content-Type: application/json" https://example.com/api/data

This command sends a request to the specified URL with custom headers, such as an authorization token and content type.

Command 8: Save the Response to a File

To save the response of a request to a file, execute the following command:

curl https://example.com/api/data -o response.json

This command sends a request to the specified URL and saves the response to a file named “response.json.”

Command 9: Limit Download Speed

To limit the download speed when using cURL, execute the following command:

curl --limit-rate 100K -O https://example.com/file.zip

This command limits the download speed to 100 KB/s while downloading the specified file.

Command 10: Resume an Interrupted Download

To resume an interrupted download using cURL, execute the following command:

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

This command resumes the download of the specified file from where it was interrupted.

Section 4: Additional Commands & Tips

This section will cover additional commands and tips related to cURL, including updating and uninstalling cURL.

How to Update cURL

Keeping your cURL installation up-to-date is essential for security and performance. The most effective method for checking for updates is using the terminal. Even if you have set up automatic updates, it is recommended to run the following command every so often to ensure updates are processed correctly:

sudo apt update && sudo apt upgrade

This command updates the package list and upgrades all the packages, including cURL, to their latest versions.

How to Remove (Uninstall) cURL

If you need to uninstall cURL for any reason, such as reverting to the original version or troubleshooting issues, follow these steps:

Step 1: Remove the Existing cURL Package

First, you need to remove the existing cURL package using the following command:

sudo apt remove curl

This command uninstalls cURL and any associated dependencies.

Step 2: Remove the PPA and GPG (If Applicable)

If you previously installed cURL from a PPA, you should remove the PPA. To do this, execute the following command:

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

Step 3: Update Package List

After removing the PPA and GPG key, you should update the package list to reflect the changes. To do this, execute the following command:

sudo apt update

This command updates the package list, removing any references to the removed PPA.

Step 4: Re-install cURL from the Default Repository (Optional)

If you wish to re-install cURL from the default repository, follow the installation steps outlined in Section 1: Install cURL with Default Repository.

Conclusion: Install cURL on Linux Mint

In conclusion, installing or upgrading cURL on Linux Mint is straightforward. By following the steps outlined in this guide, you can easily install cURL using the default repository or a PPA for the latest version. Keeping cURL up-to-date is crucial for maintaining the security and performance of your system. This guide has also provided essential cURL commands to help you use this versatile tool effectively.

Additional Resources and Links

Here are some additional resources and links to help you learn more about cURL and deepen your understanding of its features and capabilities:

  • cURL Official Website: The official cURL website provides extensive information about the tool, its features, and its development.
  • cURL Documentation: This official documentation contains comprehensive guides and tutorials on using cURL effectively. It covers various topics, from basic usage to advanced techniques.
  • cURL Frequently Asked Questions (FAQ): This official FAQ page addresses common questions and issues related to cURL, providing valuable insights and solutions.
  • cURL GitHub Repository: The official GitHub repository for cURL, where you can find the source code, contribute to the project, or report issues.