1. [For Beginners] How to Install curl on Ubuntu (apt & snap)
What is curl?
curl is an open-source command-line tool for transferring data. It supports various protocols such as HTTP, HTTPS, and FTP, making it useful for sending API requests, downloading files, and more.
Benefits of Using curl on Ubuntu
Ubuntu does not always come with curl pre-installed. However, since curl is essential for downloading software and interacting with APIs, setting it up early can be beneficial. Additionally, curl is easy to use with simple commands and is well-suited for scripting and automation.
2. [Method 1] Installing curl with apt
What is apt?
apt (Advanced Package Tool) is Ubuntu’s package management system. It allows you to install, update, and remove software from the official Ubuntu repository, which provides a stable version of curl.
Steps to Install curl Using apt
- Update the package list
sudo apt update
- Install curl
sudo apt install curl
- Verify the installation
curl --version
Pros and Cons of Installing with apt
Pros | Cons |
---|---|
Stable version provided by the official Ubuntu repository | May not be the latest version |
Security updates are applied automatically | Some features may be limited |
3. [Method 2] Installing curl with snap
What is snap?
snap is a modern package management system available for Ubuntu and other Linux distributions. It manages dependencies independently, reducing compatibility issues between different software versions.
Steps to Install curl Using snap
- Check if snap is enabled
snap --version
- Install curl using snap
sudo snap install curl
- Check the installed curl version
curl --version
Pros and Cons of Installing with snap
Pros | Cons |
---|---|
Always provides the latest version | Requires the snap environment (not pre-installed by default) |
Less affected by system dependencies | May have slower startup times |
4. [Basic Guide] How to Use curl
Once curl is installed, try using some basic commands.
Fetching a Web Page
Use the following command to retrieve the HTML data of a specified URL.
curl https://example.com
Downloading a File
Use the -O
option to download a file.
curl -O https://example.com/sample.txt
Sending API Requests
To send API requests, use the -X
option.
curl -X GET https://api.example.com/data
If you need to retrieve data in JSON format, you can specify headers.
curl -X GET https://api.example.com/data -H "Content-Type: application/json"
5. [Troubleshooting] Common curl Installation Errors and Solutions
curl: command not found
Error
Solution:
- Check if curl is installed on Ubuntu:
which curl
- If it is not installed, reinstall it using
sudo apt install curl
.
Could not resolve host
Error
Solution:
- Check your network connection and DNS settings.
- Use
ping google.com
to verify connectivity.
Outdated Version of curl
Solution:
- If you need the latest version, install the snap version instead.
6. [FAQ] Frequently Asked Questions
Q1: How can I update curl to the latest version?
A1: You can either wait for an update in the Ubuntu official repository or install the snap version.
Q2: What is the difference between curl and wget?
A2:
- curl: Suitable for API requests and data transfers.
- wget: Primarily designed for downloading files.
Q3: Can curl send HTTPS requests?
A3: Yes, curl supports HTTPS. You can disable certificate verification using the -k
option.

7. Conclusion
In this guide, we covered how to install curl on Ubuntu (using apt and snap), its basic usage, and troubleshooting common issues.
Key Takeaways
✅ curl is not always pre-installed on Ubuntu.
✅ Installing via apt is the standard method, but snap is useful for getting the latest version.
✅ curl is a versatile tool for API requests and file downloads.
✅ When encountering issues, check error messages and troubleshoot accordingly.
curl is a highly useful tool for Ubuntu users, so installing and understanding its usage will be beneficial.