Last updated:
The Curl is a versatile and cross-platform command line utility that helps us transfer/share data over different protocols including FTP, HTTP, SCP, SFTP, and many others. The Curl is a client-side utility URL that empowers you to interact with the network resources to retrieve the data by harnessing the power of the “libcurl” library.
Quick answer
On Ubuntu 26.04 LTS and 24.04 LTS, install curl with sudo apt install curl and check it with curl --version. Ubuntu 26.04 packages curl 8.18.0 and Ubuntu 24.04 packages curl 8.5.0; the commands below work the same on both. Use curl URL to fetch a page, curl -O URL to save a file, curl -I URL to see only the headers, and curl -fsSL URL in scripts so errors are not hidden.
| Ubuntu release | curl package version (packages.ubuntu.com, 20 Oct 2026) |
|---|---|
| 26.04 LTS (resolute) | 8.18.0-1ubuntu2.8 |
| 24.04 LTS (noble) | 8.5.0-2ubuntu10.16 |
The screenshots in this guide were captured on Ubuntu 24.04. The package version numbers differ on 26.04, but the install command and the options used in the examples are the same.
How to Install Curl on Ubuntu 26.04 and 24.04
To install curl on Ubuntu 26.04 or 24.04, run the command below. If curl is already installed, this simply reports that it is the newest version. Curl is also a prerequisite for other setups, such as when you install kubectl on Ubuntu 24.04:
sudo apt install curl

To verify the installation, check the Curl utility’s version by executing the following command:
curl --version

How to Use the Curl on Ubuntu 24.04
Let’s understand the use of the Curl utility on Ubuntu 24.04 starting with its syntax.
Curl Command Syntax
curl [options] [URL]
Here,
- The “curl” invokes the Curl command.
- The “options” are specified to control the behavior of the Curl command. It includes a few flags or options that let us customize the output.
- The “URL” specifies the web address or the URL of the resource you are interacting with.
Let’s dig deeper into the Curl command using the following examples.
Example 1: Download a File Using the Curl on Ubuntu 24.04
To download a file from a server using the curl on Ubuntu 24.04, run the following command and replace the URL with the URL from where you want to download the file. This is the same approach used to fetch tarballs when you install Go on Ubuntu 24.04:
curl -O https://releases.ubuntu.com/jammy/ubuntu-22.04.5-desktop-amd64.iso

Note: The example file is a 4.4 GB ISO, so you can cancel it after a few seconds. The screenshots below show the earlier 22.04.4 file name; that file has since been replaced by 22.04.5 on the server, which is why the commands use the current name. You can stop or interrupt the downloads by pressing the Ctrl + C keys. These downloads can be resumed in the current session.
Example 2: Resume the interrupted Download
If your download is interrupted (when you press the Ctrl + C keys), you can resume it using the Curl command’s “-C” flag, as follows:
curl -C - https://releases.ubuntu.com/jammy/ubuntu-22.04.5-desktop-amd64.iso -O

Here, the “-C” flag specifies the Curl command to download the rest of the file from the specified URL.
Example 3: Download Data With the Progress Bar Using the Curl Command on Ubuntu
If you want to view a progress bar instead of the downloading stats (Total, Received, Xferd Average speed, etc), use the “-#” as follows:
curl -# -O https://releases.ubuntu.com/jammy/ubuntu-22.04.5-desktop-amd64.iso

Example 4: Do a Basic GET Request Using the Curl Command on Ubuntu 24.04
If you specify no options/flags for the Curl command, it treats everything as a URL and dumps its HTML code (if found) on the terminal, as illustrated below:
curl https://www.wikipedia.org

Example 5: Do a POST Request Using the Curl Command on Ubuntu 24.04
If you want to perform a POST request to a server using the Curl Command on Ubuntu, execute the following command and replace the credentials and replace the URL:
curl -X POST -d "name=name&[email protected]" https://your-server.com/submit_form.php
Example 6: Check HTTP Headers Using the Curl Command on Ubuntu 24.04
The HTTP Headers are the meta-data that accompany every request and response on the internet. You can view the HTTP Headers using the Curl command on Ubuntu 24.04 by executing the below command:
curl -I https://www.github.com

Example 7: Download the Files That Require Authentication Using the Curl Command on Ubuntu 24.04
For added security, there are many password-protected files on the servers. To download such password-protected files using the Curl command on Ubuntu 24.04, use the following command and add the credentials required to access the file:
curl -u username https://somewebsite.server.com/data.zip
Security note: if you write -u username:password on the command line, the password is saved in your shell history and is visible to other users in the process list while curl runs. With -u username alone, curl asks for the password at the prompt. For scripts, store credentials in a ~/.netrc file with chmod 600 and use curl -n.
Check the HTTP status code and fail on errors
By default curl prints an error page just like a success page and exits with 0, which can hide failures in scripts. Two options fix that. -w prints a value after the transfer, and -f (--fail) makes curl exit with code 22 on HTTP errors such as 404. These commands were run against a local test web server on Ubuntu 24.04 with curl 8.5.0:
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8099/index.html
200
curl -fsS http://localhost:8099/nope.html; echo "exit=$?"
curl: (22) The requested URL returned error: 404
exit=22
The usual combination for scripts is curl -fsSL URL: -f fail on HTTP errors, -s hide the progress meter, -S still show errors, and -L follow redirects. Without -L, curl stops at a 301 or 302 response instead of following it to the real page.
Common curl errors and what they mean
curl exits with a numeric code you can read with echo $? right after the command. The codes below were reproduced on Ubuntu 24.04 (curl 8.5.0), except 60, which is listed in the curl documentation.
| Message | Exit code | Likely cause and fix |
|---|---|---|
Command 'curl' not found |
127 (shell) | curl is not installed. Run sudo apt update && sudo apt install curl. |
Could not resolve host |
6 | DNS problem or a typo in the host name. Test with another site and check /etc/resolv.conf. |
Failed to connect to host port N |
7 | Nothing is listening on that port, or a firewall blocks it. Check the service and the port number. |
Operation timed out |
28 | The server is too slow or unreachable. Raise -m SECONDS only if the server is known to be slow. |
The requested URL returned error: 404 |
22 | Only appears with -f. The URL is wrong or the file was removed. |
SSL certificate problem |
60 | Expired or untrusted certificate, or a wrong system clock. Fix the certificate or run sudo apt install ca-certificates. Avoid -k except for temporary testing, because it turns off certificate checking. |
When curl is useful
Curl is most useful when you need to test a URL, download a file from Terminal, check headers, or send a quick request to an API without opening a browser. For a graphical way to build and save the same API requests, you can install Postman on Ubuntu 24.04.
If a command copied from a website uses curl with a pipe into another command, read it first. Curl is powerful, and piping downloaded scripts directly into a shell should only be done when you trust the source.