Skip to content
-
Subscribe to our Howsnip.com website & never miss our best posts. Subscribe Now!
howsnip_logo How Snip

Tech Tips You Can Trust

  • Home
  • About Us
  • Pages
    • Privacy Policy
    • Write For Us
    • Terms and Conditions
  • Sitemap
  • Contact Us
Advertise
Home » How to Download Files Using cURL on Linux
cURL Command Howsnip
Posted inLinux

How to Download Files Using cURL on Linux

Posted by Carly Medina October 17, 2026

cURL is one of the most useful command-line tools available on Linux. It allows you to transfer data and download files from URLs using protocols such as HTTP, HTTPS, FTP, and SFTP, all without opening a web browser.

In this tutorial, you’ll learn how to download files using cURL, save files with custom names, follow redirects, resume interrupted downloads, limit download speeds, authenticate with protected servers, and more.

Prerequisites

Before getting started, make sure:

  • You have cURL installed on your Linux system.
  • You have access to a terminal.
  • You have a valid URL for the file you want to download.

Note: If you run curl without any file-saving options, the downloaded content is displayed directly in the terminal (stdout) instead of being saved to disk.

Save a File to Disk

cURL provides two commonly used options for saving downloaded files:

  • -O (uppercase O) saves the file using its original filename from the URL.
  • -o (lowercase o) lets you choose your own filename.

Use -O to Keep the Original Filename

If you want cURL to save the file using the filename already present in the URL, use the -O option.

curl -O https://httpbin.org/robots.txt

Download Curl Howsnip

This command downloads the file and saves it as:

robots.txt

What this does:

  • Downloads the file from the specified URL.
  • Automatically uses the filename found in the URL path.

Use -o to Specify Your Own Filename

Use the lowercase -o option when you want to save the file with a custom name.

curl -o my-robots.txt https://httpbin.org/robots.txt

Download Curl Howsnip

This saves the downloaded file as:

my-robots.txt

Why use this option?

  • Helpful when URLs contain long query strings.
  • Makes filenames easier to identify.
  • Useful for organizing downloaded files.

Follow Redirects with -L

Some URLs redirect visitors to another location using HTTP status codes such as 301 or 302. By default, cURL does not automatically follow these redirects.

To instruct cURL to follow redirect chains and download the final file, use the -L option.

curl -L -o latest.tar.gz https://tinyurl.com/example-release

Download Curl Howsnip

What this does:

  • Follows one or more redirects automatically.
  • Downloads the final destination file.
  • Saves it as latest.tar.gz.

This is particularly useful when working with shortened URLs, download mirrors, or content delivery networks (CDNs).

Important: Without -L, you may download the redirect response instead of the intended file.

Resume an Interrupted Download with -C –

Large downloads can fail because of network interruptions. Instead of starting over, cURL can continue downloading from the point where the transfer stopped.

curl -C - -o big-file.zip https://example.com/big-file.zip

Download Curl Howsnip

What this does:

  • Checks the size of the partially downloaded file.
  • Resumes downloading from the last downloaded byte.
  • Prevents wasting bandwidth and time.

The second dash (-) tells cURL to automatically determine where the previous download ended.

Display a Simple Progress Bar with -#

By default, cURL displays transfer statistics while downloading. If you prefer a cleaner progress indicator, use the -# option.

curl -# -o release.zip https://example.com/release.zip

Download Curl Howsnip

What this does:

  • Replaces the standard statistics output.
  • Displays a visual progress bar.
  • Makes download progress easier to monitor.

This option is useful when downloading large files interactively.

Run Silently While Still Showing Errors with -sS

When using cURL inside shell scripts, excessive output can clutter logs. The -s flag suppresses progress information, while -S ensures error messages are still displayed.

curl -sS -o config.yml https://example.com/config.yml

Download Curl Howsnip

What this does:

  • Hides the progress meter.
  • Displays errors if the download fails.
  • Produces cleaner script output.

This combination is commonly used in automation scripts and CI/CD workflows.

Tip: Using only -s may hide useful error information during troubleshooting.

Download Multiple Files at Once

You can download multiple files in a single command by pairing each URL with its own -O option.

curl -O https://example.com/readme.md -O https://example.com/license.txt

Download Curl Howsnip

What this does:

  • Downloads both files sequentially.
  • Saves each file using its original filename.
  • Reduces the need to run multiple commands.

Useful Notes

  • Each -O applies to the URL immediately following it.
  • Original filenames are preserved.
  • You can also use -K to read download instructions from a configuration file.

Limit Download Speed with –limit-rate

Sometimes a large download can consume all available bandwidth. To prevent that, cURL allows you to set a speed limit.

curl --limit-rate 2m -o iso-image.iso https://example.com/ubuntu-24.04.iso

Download Curl Howsnip

What this does:

  • Limits the download speed to 2 MB/s.
  • Helps keep the network responsive for other applications.
  • Reduces bandwidth usage during large transfers.

Common Rate Suffixes

  • k = Kilobytes per second
  • m = Megabytes per second

Example: 500k limits downloads to approximately 500 KB/s.

Authenticate with a Username and Password Using -u

Some FTP servers and protected web endpoints require authentication before allowing downloads. Use the -u option to provide credentials.

curl -u user:pass -O ftp://example.com/private-file.zip

Download Curl Howsnip

What this does:

  • Sends the username and password to the server.
  • Allows access to protected resources.
  • Works with supported protocols such as FTP and HTTP authentication.

More Secure Approach

On shared systems, avoid putting passwords directly into commands. Instead, provide only the username:

curl -u username -O ftp://example.com/private-file.zip

Download Curl Howsnip

cURL will prompt you to enter the password securely.

Warning: Passwords entered directly on the command line may be stored in shell history.

Quick Reference: Common cURL Download Options

  • -O – Save the file using the original filename from the URL.
  • -o filename – Save the file with a custom filename.
  • -L – Follow HTTP redirects automatically.
  • -C – – Resume an interrupted download.
  • -# – Display a progress bar.
  • -sS – Run silently while still showing errors.
  • –limit-rate – Limit the download speed.
  • -u user:pass – Authenticate with a username and password.

Conclusion

cURL is a powerful and flexible tool for downloading files directly from the Linux command line. By learning a few essential options such as -O, -o, -L, and -C -, you can handle common download tasks efficiently. Additional features like download resumption, authentication, speed limits, and silent execution make cURL especially useful for automation, scripting, and server administration.

For more advanced capabilities such as proxy support, cookies, TLS settings, and API requests, refer to the cURL manual:

man curl

This provides access to the complete list of available options and configurations.

Tags:
curl authenticationcurl command examplescurl download file Linuxcurl follow redirectscurl Linux tutorialcurl options guidecurl resume downloadcurl save filedownload files with curlLinux download files command line
Carly Medina
Carly Medina is the voice behind howsnip.com, where she shares practical insights, tips, and inspiration to help readers simplify life and achieve more every day.
View All Posts

Post navigation

Previous Post
Linux tar Command Tutorial Linux tar Command Tutorial – Create, Extract, List, and Manage Archives
Related posts
Linux tar Command Tutorial
Posted inLinux

Linux tar Command Tutorial – Create, Extract, List, and Manage Archives

Posted by Carly Medina
Ubuntu Server Setup Howsnip
Posted inLinux

Ubuntu Server Initial Setup Guide – Secure and Harden a New Ubuntu Server

Posted by Carly Medina
Nslookup Command Examples
Posted inLinux

Nslookup Command Tutorial – DNS Lookup Examples for A, MX, NS, TXT, CNAME, PTR, and AAAA Records

Posted by Carly Medina
Search
Categories
  • AI/ML 5
  • Cryptocurrency 1
  • Linux 58
  • Programming 11
  • Tech 32
  • Windows 11
Topattop_Banner
Recent Articles
  • How to Download Files Using cURL on Linux
  • Linux tar Command Tutorial – Create, Extract, List, and Manage Archives
  • Ubuntu Server Initial Setup Guide – Secure and Harden a New Ubuntu Server
  • 18 Essential PowerShell Commands Every Beginner Should Know
  • Nslookup Command Tutorial – DNS Lookup Examples for A, MX, NS, TXT, CNAME, PTR, and AAAA Records
  • How to Monitor Linux User Activity with psacct and acct
  • How to Use Linux sort and uniq Commands to Sort, Count, and Remove Duplicate Lines
  • Linux wget Command Tutorial – Download Files, Resume Transfers, Mirror Websites, and More
  • How to View Disk Partitions and Disk Information in Linux (7 Easy Methods)
  • 15 Practical Examples to Check Disk Space Usage in Linux
Useful Links
  • About Us
  • Advertise With Us
  • Contact Us
  • Privacy Policy
  • Sitemap
  • Terms and Conditions
  • Write For Us
Tech
  • Simple SIEM Home Lab with Elastic Cloud – Setup and Monitoring Guide
  • Apple iOS 27 Is Here – 9 Exciting New Features Every iPhone User Should Try
  • How to Detect CVE-2026-89049 Attacks Using AWS CloudTrail
  • 25 Commonly Asked AppSec & InfoSec MCQs with Answers and Explanations
  • 97 Essential JSON Test Cases for Authentication Endpoint Verification
  • 20+ SSL Certificate Decoder Websites to Check Certificate Details
  • Outbid.lol Alternatives – The Viral Pay-to-Rank Trend Taking Over the Internet
  • 16 Powerful Free SSL Scanning Tools for Website Security
  • How Latest Technology Is Shaping Everyday Life
  • Windows vs Linux: Choosing the Right Operating System for Your Needs
Linux
  • How to Download Files Using cURL on Linux
  • Linux tar Command Tutorial – Create, Extract, List, and Manage Archives
  • Ubuntu Server Initial Setup Guide – Secure and Harden a New Ubuntu Server
  • Nslookup Command Tutorial – DNS Lookup Examples for A, MX, NS, TXT, CNAME, PTR, and AAAA Records
  • How to Monitor Linux User Activity with psacct and acct
  • How to Use Linux sort and uniq Commands to Sort, Count, and Remove Duplicate Lines
  • Linux wget Command Tutorial – Download Files, Resume Transfers, Mirror Websites, and More
  • How to View Disk Partitions and Disk Information in Linux (7 Easy Methods)
  • 15 Practical Examples to Check Disk Space Usage in Linux
  • 100+ Essential Kali Linux Commands with Real Examples
Programming
  • Learn CRUD Operations in PHP Using PDO and MySQL in 15 Practical Steps
  • 25 Essential JavaScript Acronyms Every Developer Should Know
  • Top 100 JavaScript MCQs Every Full Stack Developer Should Know
  • 30-Day MERN Stack Challenge Roadmap to Become a Full-Stack Developer
  • Top 20 Advanced SQL Commands You Need To Know
  • 6 Essential SQL Operations Every Cybersecurity Professional Must Know
  • Build a Simple AJAX-Based Comment System in PHP and MySQL (With CAPTCHA Verification)
  • Top 10 Tricky SQL Interview Questions (With Examples and Explanations)
  • 100 HTML/CSS/JavaScript Interview Questions with Answers
  • 50+ Essential Web Development Abbreviations You Need to Know in 2025
Copyright 2026 - How Snip. All rights reserved.
Scroll to Top