↑↓ move Enter open Esc close

How to Download a File with curl in Linux

Download files with curl while preserving the remote filename and handling redirects.

curl is a flexible HTTP client as well as a download tool. For a simple file download, `-L` and `-O` solve the two common problems: redirects and choosing an output filename.

Step by step

1 Download using the remote filename

$ curl -LO https://example.com/file.zip

Follows redirects and writes file.zip in the current directory.

2 Choose the output filename

$ curl -L https://example.com/file.zip -o release.zip

The lowercase -o option lets you choose the local path.

3 Resume a partial download

$ curl -L -C - -o release.zip https://example.com/file.zip

The -C - option asks curl to resume from the existing local file size when the server supports it.

4 Inspect headers only

$ curl -I https://example.com/file.zip

A HEAD request can reveal redirects, content type and other response headers without downloading the body.

Tips worth knowing

Frequently asked questions

How do I download a file with curl?

Use `curl -LO URL` when you want to follow redirects and keep the remote filename.

What is the difference between -o and -O?

`-o` chooses the local filename; `-O` uses the remote filename.

Why does curl save an HTML page instead of my file?

Check redirects, authentication and the response headers; use `curl -I` or `curl -fL` to diagnose.

The commands behind it

More how-to guides