How can I download ZIP file with curl command? I tried curl -sO, but error occurred. I want to download zip file from address: http://github.com/ziyaddin/xampp/archive/master.zip

but can't. What must I type?

  • What's the error message? Feb 19, 2017 at 21:56
  • Does anybody else see the irony in downloading a zip file which has the zip command on it. So once you've download it. Then you can use zip command inside the zip file to unzip the zip command you need to unzip the zip. Ok cool ;) Mar 24, 2022 at 15:38

8 Answers 8


I used curl -LO and it worked fine. wget works too.

  • Worked for me. using Windows 7
    – fedmich
    Dec 10, 2014 at 7:08
  • Worked for me on Windows 11 using curl v8.0.1
    – Jan
    May 15, 2023 at 6:17
  • Worked also for me in wsl Linux subsytem of Windows 10 using wget Jun 30, 2023 at 12:00
  • The L flag is to follow redirects: -L, --location Follow redirects
    – icc97
    Oct 3, 2023 at 15:11

Try wget instead of curl: wget http://github.com/ziyaddin/xampp/archive/master.zip

  • 3
    Can the downvoter explain? Or is the other poster?
    – don.joey
    Apr 26, 2013 at 19:47
  • 10
    Could you explain why wget instead of curl?
    – j--
    Dec 9, 2014 at 17:52
  • 1
    less command lines (if you care) - which means less options, But the biggest difference is that wget support recursive download May 8, 2015 at 15:14
  • Don't know why, but I had an error issuing unzip on the file downloaded with curl, and it worked fine with wget
    – Dinei
    May 7, 2017 at 19:16
  • @Dinei you need to try curl -OL <URL> once I added -L it fixed it for me.
    – Mark
    Mar 11, 2023 at 19:12

You can use:

curl https://github.com/ziyaddin/xampp/archive/master.zip -O -J -L

Saves as: xampp-cli-master.zip

  • use -L in case there is a redirect found.
  • use -O for remote filenames (master.zip)
  • use -J (use with -O) to allow remote header filename (xampp-cli-master.zip)

Or use -o to create your own filename:

curl https://github.com/ziyaddin/xampp/archive/master.zip -L -o MyFilename.zip

Saves as: MyFilename.zip

Note: (GitHub supports SSL - use https://)

You could also use a curlrc config file or alias the CURL command to use curl -O -L to allow it to work similar to WGET.

Consult: https://curl.haxx.se/docs/manpage.html#OPTIONS (See: -O, -J, -L, -o)

Note the warning of using CURL with the -J option:

There's no attempt to decode %-sequences (yet) in the provided file name, so this option may provide you with rather unexpected file names.

WARNING: Exercise judicious use of this option, especially on Windows. A rogue server could send you the name of a DLL or other file that could possibly be loaded automatically by Windows or some third party software.

  • 1
    Lol, this wins just because you get to do the J.Lo curl: curl -JLO ...
    – icc97
    Oct 3, 2023 at 15:15
  • @icc97 LOL. Never occurred to me - that might be easier to remember, too..
    – B. Shea
    Oct 4, 2023 at 13:31

If you want to download the file use wget [option]... [URL]... instead.

For more information regarding the options, just type this into your Terminal: man wget

For you purpose:

wget http://github.com/ziyaddin/xampp/archive/master.zip

Note that the .zip file will be saved in the current directory you are in.

  • 1
    It would be helpful to explain the advantages of using wget over of curl. For anyone wondering the differences between the two see here.
    – j--
    Dec 9, 2014 at 17:50
  • @JorgeBucaran I read the comparison written by the author of curl who also contributes to wget in a minor role. One glaring omission (based on my one time small project) is that wget is 10 times faster than curl (<2 seconds vs. 12 seconds) retrieving sunrise and sunset times from https://www.timeanddate.com Mar 3, 2017 at 2:49
  • So, sometimes when you use wget and the file is not served directly but instead the url tells a service where to locate and serve the file, what you end up downloading is a html. So curl is better for some files instead May 28, 2019 at 11:51

To download files in GitHub (or any other site that make redirects) using curl, you must pass -L (Follow redirects), so use:

curl -L http://github.com/ziyaddin/xampp/archive/master.zip -o xampp.zip


"curl -LOk" makes it using insecure protocols (-k), disabling SSL certificate checks (which fail because of the incorrect path not matching the certificate), and create the output file using the filename (-O) proposed from the remote server (also insecure). In my opinion, the server should better be configured create local redirecting aliases where needed, to avoid having to pass this non conforming part of the URL. But the redirection is made using an HTTP redirect only (HTTP error 30x), which causes problems to curl that does not follow (by default) this (unsecure) redirection, and option (-k) disables this security check. So instead of using HTTP redirects (moved permanently), please add some internal link on the filesystem of the server. If this is needed because the URL is in fact hosted on another physical server with no direct access between their filesystems, you should use another DNS name for this host, so that clients will query the correct one directly, without any redirect. Then fix your web pages (you may use your webserver logs to see where HTTP 30x redirects are returned and which webpages may need to be checked and updated). Forcing clients to use unsecure/unchecked protocols is not a good option.

So this is definitely a problem of very bad configuration on the web server: try contacting their admin to fix that.


well, you can use Axel as well. axel is a light command line download accelerator. it supports HTTP, HTTPS, FTP and FTPS protocols. its nice and faster alternative.

install axel using :

apt-get install axel

then download your file by:

axel http://github.com/ziyaddin/xampp/archive/master.zip

Use the option -L to follow redirects, you can use also the --output option to give a path and a name to the zip file. For example:

sudo curl -L https://github.com/CISOfy/lynis/archive/master.zip --output /etc/lynis.zip

Note: Use sudo if you don't have permissions to write to the target folder.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .