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.
The libcurl library powers the Curl, enabling it to act as a high-level interface that simplifies complex network tasks. This binding energy between the libcurl library and the Curl utility provides a flexible solution for network communication on Ubuntu 24.04.
The Curl is mostly pre-installed on various Linux flavors and some may not have it. If you are using Ubuntu 24.04 and want to employ the Curl utility, follow this detailed guide to install and learn to use the Curl on Ubuntu 24.04.
How to Install Curl on Ubuntu 24.04
To install the Curl utility on Ubuntu 24.04, execute the below command:
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:
curl -O https://releases.ubuntu.com/jammy/ubuntu-22.04.4-desktop-amd64.iso
Note: 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.4-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:
url -# -O https://releases.ubuntu.com/jammy/ubuntu-22.04.4-desktop-amd64.is
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:password https://somewebsite.server.com/data.zip
Final Words
To install Curl on Ubuntu 24.04, execute the “sudo apt install curl” command. The Curl is a cross-platform & open source command line utility that allows you to transfer data via the Terminal by employing various file transfer protocols. Using the Curl utility, you can download & upload files, perform an HTTP GET or HTTP POST request, and more, as discussed in the above guide.