Learn How to Use Curl with These Useful Curl Commands

curl is a powerful command-line utility to communicate with a web server via the terminal. Often, it gets confused with the popular wget command as both of them can upload and download contents to a server and they do work cross-platform. So, to clear things up, here are the differences between wget and curl and some popular curl commands that you should know to start off.

curl vs wget

On the surface, both curl and wget can be seen as a utility that can request and download content from the web servers. However, if you dig down deep, there is a lot to unravel. curl supports many more protocols ranging from HTTPS, SFTP to IMAP, POP3, etc whereas, wget only supports HTTP, HTTPS, and FTP.

Another major difference is that wget supports recursive download whereas curl doesn’t. So, wget will download everything from the webpage to pages it is linked with whereas curl won’t. On the other hand, curl is based on the libcurl library which provides APIs. Hence, it can be easily used in command-line scripting as well as GUI based apps. You can think of curl as a stripped-down command-line web browser which can upload and download contents from a web server.

extracted files of curl lib library

Installing curl onWindows

curl comes pre-installed on Unix-based or Unix-like Operating systems and hence it can be directly used on macOS. However, it can also be used on non-Unix systems like Windows with the help of a “libcurl” library.

In Windows, all we have to do is download the libcurl zip file and make a couple of changes to make it usable via the command prompt. Firstly, download thelibcurl zip filefor your Windows 32-bit or 64-bit accordingly. After you have downloaded the file, extract the contents in a folder. For context, the following is a screenshot of the extracted contents of the libcurl folder.

copy paste the curl.exe and cert file

Within the extracted folder, head over to thebinfolder and copy the following files –“curl.exe” and “curl-ca-bundle”.

Create a folder called “curl” within the “C:” drive and paste both the copied files. Once you have done this, you can directly use the curl command when you navigate to the “C:\curl” folder within the command prompt.

change to the curl directory via cd

Alternatively, if you would like to run curl directly from the cmd, I would recommend creating an environment variable. To do that, head over to the Start menu and type “Edit the system environment variables” and click on the first search.

On the System Properties pop-up window, click on the Environment variables button at the bottom.

search edit the environment variable on the start menu

On the environment variable screen, click on the New button on the upper half to add a user environment variable.

In the new User Variable screen, add the following entry. Post that, click on Ok and next Apply to save the changes.

add environment variables in windows

Once done, click on Ok under the Environment variable menu to save the changes. Post this, you should be able to use the curl command directly on the command prompt. To test it, enter the following command

Alternatively, you’re able to alsoenable WSL for Windowsand use theUbuntu bash shellto run curl commands from bash on Windows.

Best Curl Commands and How to Use It

Before we begin with the commands, do note that single quotes don’t work in the Windows command line. You would have to convert them to double-quotes. For the bash shell, it would work as usual with the single quotes as well.

  1. Browse HTML code

The most basic utility of curl is to browse the HTML code of a webpage. To do that, suffix the curl command with the web URL of the webpage.

This command will display the output on the terminal. You can also download the contents of the file by specifying the “-O” switch prior to the URL. This will save the file on your system with the same remote file name. For instance, if the HTML file name on the server is “home.html”, it will be saved locally as “home.html” as well.

Alternatively, you’re able to store the data with custom file names. For that, append the command with a smaller case “-o” followed by the file name.

You can also download multiple files by specifying multiple remote file URLs.

  1. Downloading files with curl

Similar to wget, you may download files using curl. You can use the -o switch and specify the file name or else the file will be saved with the remote file name.

For example, the following command will download the latest version of Linux mint from the webserver.

You can also use “-#” or “–progress-bar” to display the progress in the form of hashes.

3. Resuming Failed Download

Moreover, if the download is interrupted, you can resume by using the “-C -” switch. The command will look like as follows.

For example, the following command will resume the download from the last failed point.

4. IP Information

You can use the following curl command to get all the network information about a machine

Alternatively, if you know the IP address and you want other details like the location co-ordinates, city, timezone, etc, you may use the following variation of the command.

5. Send Emails

Since curl supports SMTP, POP3 protocol, you can even use it to send emails. Below is a sample of sending an email via Gmail.

Replace the email address and password in the following command accordingly.

Make sure youturn on access for less secure appsfor the Google account

6. Dictionary

The dict protocol provided by the libcurl can be used to easily find the meaning of a word. The source of the meaning isWordNet. Below is the command to do the same.

  1. POST commands

You can send POST requests to a web server with the help of a curl command. The syntax is as follows

The POST form data can also be sent in the form of a JSON file. Use the following command to do that.

8. Convert Files

Since curl supports multipart form data, you can use it to upload files and even get them converted instantly. For instance, I want to get this HTML file converted to a PDF. Hence, I will be using theDocverter APIto do this. The Docverter API supports multiple file-formats from HTML, Markdown and can convert them to Docx, PDF, ePub, etc.

Alternatively, you can also use theGoogle Drive API v3to convert excel spreadsheets, documents, etc.

Closing Words

curl is majorly used in programs for the sharing of data, files, forms. Apart from the above-mentioned command, there are various other APIs, combinations, or shell scripts you can use curl with. You can know more about this on the GitHub repos or Stack Overflow. For more issues or queries regarding any curl command, let me know in the comments below.

Also Read:14 Best Learn to Code Apps (Android & iOS)

Pratik works as an In-house writer and video host at TechWiser. Former Programmer, Current writer. Loves tech in any form, quite optimistic about AI, data science and IoT. Talks extremely less but you betcha can geek out over anything on Twitter.

Is New Camera Coach Feature on Pixel 10 Worth The…

What’s Coming and Leaving Hulu Soon (August 2025)

What’s Coming to Apple TV+ in August 2025

Today’s Jumble Answers (July 31, 2025)

Longest Snapchat Streak (August 2025) – And How to Keep…

Samsung One UI Status Bar Icons and Symbols Meaning

Safari Icons and Symbols Meaning – Complete Guide

What Do Icons and Symbols Mean on Slack? Complete Guide

Coffee Meets Bagel (CMB) Icons and Symbols Meaning? Complete Guide

What Do Icons and Symbols Mean on OkCupid? Complete Guide

You must belogged into post a comment.