Curl On Ubuntu

clientURL, or simply curl, is a command-line tool used to exchange data between a client and a server. It supports various protocols including HTTP/HTTPS, FTP, and SMB.

On Ubuntu, it’s one of the two main CLI tools for downloading files (the other being wget). We’ll cover how you can install and get started with curl on Ubuntu in this article.

Installing Curl on Ubuntu

If you simply enter curl into the terminal, you’ll encounter some messages stating that you can install curl with snap and apt. The latest versions available through both methods will also be mentioned there.

If you want the bleeding edge version, you can install the curl snap like so

sudo snap install curl

If you prefer installing curl with apt instead, update your package index first. This’ll ensure you get the latest version currently available in the Ubuntu repo.

sudo apt update

Then, install the curl package like so

sudo apt install curl

In either case, you can verify the installation by checking the curl version.

curl -V

Using Curl to Download Files

Curl’s output option is used to save received data into a local file, and it can be used in two ways. Generally, you’ll use the upper case variant (-O). This’ll save the file as it is received from the server.

For instance, when setting up GitLab, most people use the official installation script. You can download it like so

curl -O

Sometimes, you’ll want to download a file but save it with a custom name. You can use the lowercase output option (-o) to do this.  

curl -o latestkernel.tar.xz

For instance, the above command downloads the linux-6.1.34.tar.xz file but saves it with the name latestkernel.tar.xz.

If you want to download multiple files at once, use the output flag with each URL like so 

curl -O -O -O

Similarly, if you have a partially downloaded file, you can use the continue (-C -) option to resume the download like so

curl -O -C -

The location (-L) option is also worth learning. If a resource has been moved to a new URL, the server may return an HTTP redirect response. In this case, you can use the -L option to instruct curl to follow the redirect.

For instance, let’s go back to our first example. If the GitLab install script is moved to a new location and curl gets redirected, including the -L flag ensures the file will be downloaded from the new URL.

curl -LO

Other Curl Use-Cases

As I said, curl is primarily used to download files but that’s not its only use. By default, curl retrieves content from the specified URL and prints it to the standard output.


You can view the URL’s HTTP response headers with the -I option.

curl -I

You can use the -L flag as explained earlier to follow redirects.

curl -L

Finally, you can use the verbose (-v) flag if you want to see more detailed info on the request (response headers, IP, TLS handshake, etc.).

curl -v

If you want to explore more possibilities with curl, I recommend checking the curl help page (curl --help) or the man page (curl --manual).

Managing Curl on Ubuntu

If you installed the curl snap, you won’t need to worry about updating it as snaps auto-update. If you want to remove the curl snap instead, you can use

sudo snap remove curl

With the apt version, you can update the curl package with the following one-liner.

sudo apt update && sudo apt install --only-upgrade curl

If you want to uninstall curl instead, you can use

sudo apt remove curl
Anup Thapa

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.