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

Tech Tutorials, IT Guides & Cybersecurity Tips

  • 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 Chetan Soni 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
Chetan Soni
Chetan Soni is the voice behind howsnip.com, where he 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
Next Post
50+ Essential Linux Commands with Examples Linux Commands Howsnip
Related posts
Install GitLab
Posted inLinux

How to Install GitLab on Ubuntu 26.04 Using Docker Compose

Posted by Chetan Soni
odoo 19
Posted inLinux

How to Deploy Odoo 19 on Ubuntu 24.04 Using Docker Compose and Caddy

Posted by Chetan Soni
Install Drupal Howsnip
Posted inLinux

How to Install Drupal on Ubuntu 26.04 with Apache, PHP, and MariaDB

Posted by Chetan Soni
Search
Categories
  • AI/ML 9
  • Cryptocurrency 2
  • Linux 118
  • Programming 11
  • Tech 38
  • Windows 15
Topattop_Banner
Recent Articles
  • 17 Best GitHub Repositories to Learn Python in 2026
  • How to Install GitLab on Ubuntu 26.04 Using Docker Compose
  • How to Deploy Odoo 19 on Ubuntu 24.04 Using Docker Compose and Caddy
  • How to Know If Your Windows License Is Permanent or Temporary
  • How to Install Drupal on Ubuntu 26.04 with Apache, PHP, and MariaDB
  • Microsoft Confirms LDAP Security Update Issue Affecting NetApp SMB Shares
  • Microsoft 365 Outage Explained: Why Outlook, Teams and Copilot Were Down for Over 24 Hours
  • How to Install PrestaShop on Ubuntu 26.04 Using Apache, MariaDB, and PHP
  • How to Install and Use Portainer on Ubuntu 26.04 for Docker Container Management
  • How to Install Traefik Reverse Proxy with Automatic SSL Using Docker Compose on Ubuntu
Useful Links
  • About Us
  • Advertise With Us
  • Contact Us
  • Privacy Policy
  • Sitemap
  • Terms and Conditions
  • Write For Us
Tech
  • 17 Best GitHub Repositories to Learn Python in 2026
  • How to Fix MySQL Server Has Gone Away Error When Importing a Large WordPress Database
  • 90+ Best Free Alternatives to Paid Software and Online Tools in 2026
  • [PHP2Shell] How to Check PHP Servers for CVE-2026-109618 and CVE-2026-109619
  • Major Cybersecurity Incidents: eMudhra, SBI Data Breach, PHP2Shell, Node.js and LiteLLM Security Risks
  • eMudhra Certificate Compromise Triggers Global Security Response After Eight CA Keys Exposed
  • 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
Linux
  • How to Install GitLab on Ubuntu 26.04 Using Docker Compose
  • How to Deploy Odoo 19 on Ubuntu 24.04 Using Docker Compose and Caddy
  • How to Install Drupal on Ubuntu 26.04 with Apache, PHP, and MariaDB
  • How to Install PrestaShop on Ubuntu 26.04 Using Apache, MariaDB, and PHP
  • How to Install and Use Portainer on Ubuntu 26.04 for Docker Container Management
  • How to Install Traefik Reverse Proxy with Automatic SSL Using Docker Compose on Ubuntu
  • How to Self-Host Uptime Kuma with Docker on Ubuntu for Free Server Monitoring
  • 11 Proven Ways to Secure a Linux Server Against Cyber Threats
  • How to Install Redis on Ubuntu 24.04 – Step-by-Step Guide
  • How to Install Apache Kafka 4.0 on Ubuntu with KRaft Mode
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