Chapter 36: Bash URL Transfer (curl)

Bash URL Transfer (curl)! 😄

curl (written in lowercase) is one of the most powerful and most used tools in the entire Bash/Linux world — especially for developers, DevOps people, API testers, and anyone who talks to the internet from the command line.

What does “curl” stand for? client URL

It’s a command-line tool that lets you transfer data to or from a server using URLs. It supports tons of protocols like HTTP, HTTPS, FTP, SFTP, SMTP (email), and many more — but 95% of people use it only for HTTP/HTTPS (web stuff and APIs).

Think of curl as your personal web browser without any graphical interface — it can fetch web pages, download files, send data to servers, test APIs, check headers, follow redirects, pretend to be Chrome/Firefox, and much more — all from your terminal in Hyderabad!

First: Check if You Have curl (Almost Everyone Does)

Type this right now:

Bash

You should see something like:

text

If not installed (rare), on Ubuntu/Debian:

Bash

On macOS (usually pre-installed), or Fedora:

Bash

Basic Syntax

Bash

No options → just fetches the page and prints it to screen (like a very basic browser).

1. Super Basic – Fetch a Web Page

Bash

→ Dumps the entire HTML of the homepage right in your terminal.

Want cleaner output? Pipe to less:

Bash

Or just the first few lines:

Bash

2. Save the Output to a File (Download!)

Two very common ways:

  • -o → specify your own filename
Bash
  • -O (capital O) → use the original filename from the URL
Bash

→ Saves as logo.png in current folder.

Resume interrupted download (super useful for big files):

Bash

-C – = continue from where left off.

3. Show Only Headers (Check Server Response)

Bash

→ -I = HEAD request (only headers, no body)

Output example:

text

Very useful to check status code, redirects, content-type, server type, etc.

4. Follow Redirects (-L)

Many sites redirect (http → https, or short links):

Bash

Combine with save:

Bash

5. Verbose Mode (-v) – See Everything!

Bash

→ Shows request headers, response headers, SSL handshake — great for debugging!

6. Change HTTP Method & Send Data (API Testing – Most Important!)

By default curl uses GET.

Change method with -X:

Bash

Send data (form or JSON – very common for APIs):

  • Simple form data (-d):
Bash
  • JSON (most modern APIs):
Bash

-H = add header (Content-Type, Authorization, etc.)

7. Authentication (Basic, Bearer Token, etc.)

Basic auth:

Bash

Bearer token (most APIs like GitHub, Twitter):

Bash

8. Download Files Silently & Progress (-s -S -#)

Bash

9. Pretend to be a Browser (User-Agent)

Some sites block command-line tools:

Bash

-A = User-Agent string.

10. Quick Reference Table (Most Used in 2026)

What you want to do Command Example Why useful in real life
Fetch page curl https://example.com Quick check content
Download file curl -O https://…/file.zip Save images, zips, PDFs
Resume download curl -C – -O https://… Big files interrupted
Only headers curl -I https://google.com Check status, redirects
Follow redirects curl -L -o page.html http://… Handle 301/302
POST JSON to API curl -X POST -H “Content-Type: application/json” -d ‘{“key”:”value”}’ https://api… Test/create data in APIs
Verbose debug curl -v https://… See full request/response
Silent download curl -s -O … Scripts/cron jobs
Auth with token curl -H “Authorization: Bearer token” … GitHub, OpenAI, most REST APIs

Practice Right Now (Try These!)

Bash

See how easy it is to talk to the internet?

Got it, boss? curl is your Swiss Army knife for the web — once you master it, you’ll use it every day for API testing, downloading, scripting, debugging.

Any part confusing? Want more on JSON APIs, file uploads (-F), cookies (-b -c), or proxies? Or next topic like “wget vs curl” or “curl in scripts”?

Just say — teacher is ready in Hyderabad! Keep curling the web! 🐧🌐😄

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *