This article describes how to install and use CURL on Windows. Curl is a free command line utility used for transferring files using various protocols. Most commonly it is used for transferring files over HTTP(S).
cURL comes natively installed on Unix based operating systems such as MacOS and Linux. But windows is left out. Now that we have powershell on windows, you can get some of the functionality of cURL using various cmdlets like invoke-webrequest. However, if you are used to using a Unix tool set, you will be left wondering where you can find cURL.
Methods of Installing cURL
To install cURL on windows, you have five real options:
- Install using Chocolatey
- Download compiled Binaries
- Compile from source code
- Install Cygwin
- Install Windows Subsystem for Linux (WSL)
If you want to go the Chocolatey route, it is really simple, just run:
choco install curl -y
This will install cURL for you. However, you need to first install the Chocolatey package manager. You can find instructions on how to install Chocolatey here.
Download Compiled Binaries
cURL is supported on many platforms. And if you navigate here, you will see binaries you can download for many different platforms. All the way at the bottom of the page you will find the windows builds. They are all labeled as Win32 or Win64
I recommend you download the zip file in the Win64 – Generic section:
After you have downloaded and extracted the zip file, look in the src folder, you will find curl.exe. Copy curl.exe into your C:\windows\system32\ folder. I choose this folder because it includes all of the other system utilities. And it is already part of your PATH variable, so you don’t have to do anything to add it.
Compile from Source Code
This is the hardest method of installation. If you are trying to get things up quickly, you should skip over this section. But, for those who want to do it just for the experience, or those who absolutely need the latest version, building from source code might be the method for you. You can find instructions on how to install from source code here: https://curl.haxx.se/docs/install.html
CYGWIN is a Unix-like environment for Windows. You can’t natively run all of your favorite Unix tools on Windows. First you have to download the source code and compile it to run on windows. Just like in the previous section. CYGWIN is a project where someone has gone through the work to pre-compile many of your favorite Unix tools for you.
To use cURL as part of CYGWIN, you first download and CYGWIN installer from here. While you are going through the installer, you will encounter a list of packages you wish to install. Make sure you select the cURL package.
Install Windows Subsystem for Linux (WSL)
Starting with windows 10, Microsoft has released a product called Windows Subsystem for Linux (WSL). WSL gives you the bash command shell on windows, which is the same shell that runs on Linux/Unix. Installing WSL gives you a full Linux environment, unlike CYGWIN which is simply a collection of Unix utilities. WSL is based on Ubuntu Linux. So you will have tools like apt-get to install programs etc…. The main limitation of WSL is you don’t have a GUI. But that is fine for our purposes today.
Older builds of windows 10 will have to enable Developer mode before they can install the windows feature. You can find instructions on how to do that here.
Starting with the windows 10 Fall Creators update, you don’t have to enable Developer mode. However, it is still a two-step process. First you enable the windows feature. Then you install the Linux distribution from the windows store. instructions can be found here.
After you have installed WSL, go to your Start menu, click on Bash, and you can use all of your favorite Linux tools, including cURL.
As this guide is about installing cURL, I won’t go into great detail about using curl. However, here are some basics.
First you need to launch the appropriate command line environment. If you installed WSL or CYGWIN, you will need to go to your start menu and launch CYGWIN or BASH. Otherwise you can launch a command prompt or powershell window.
Next, type: curl —helpThe above command will show you all the different command arguments you can pass to cURL. This will be very important as you are learning how to use the tool.
Lets try pulling down the text of a webpage using curl with the following command:curl https://www.idkrtm.comYou should see all the HTML code from idkrtm.com scroll by…that means it is working.
Next, let’s just pull down the headers. This is useful for just checking if a web page is working:If you’re on Linux, OSX/MacOS, CYGWIN, or WSL, the command would be:
curl -s -D - https://www.idkrtm.com -o /dev/null
and the output would be similar to this:
HTTP/1.1 200 OKDate: Mon, 12 Feb 2018 15:25:35 GMTServer: ApacheX-Powered-By: PHP/5.5.38Link: ; rel=”https://api.w.org/”, ; rel=shortlinkTransfer-Encoding: chunkedContent-Type: text/html; charset=UTF-8
On windows Powershell, the same command would be:
curl -s -D - https://www.idkrtm.com -o $null
Or on Windows CMD, the same command would be:
curl -s -D - https://www.idkrtm.com -o nul