Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Use the cURL Program

cURL is a small tool that fetches things from the internet using the command line. This guide shows the most useful commands for beginners.

Web Hosting1 min read6 steps

What is cURL?

The command line is a screen where you type commands. cURL lets you talk to a website from there. It can download a file, check if a site is up, or send data to a web address. It works like a browser that has no pictures.

Check that cURL is installed

Open a terminal. On Windows 10 and later, use Command Prompt. Type:

curl --version

This prints the cURL version. If it is missing on Ubuntu, install it with sudo apt install curl.

Basic commands

  1. Show a web page's code:
    curl https://example.com
    This command prints the page source on your screen.
  2. See only the headers:
    curl -I https://example.com
    Headers are short notes the server sends before the page. The first line shows the status, such as 200 OK.
  3. Save a file with its own name:
    curl -O https://example.com/file.zip
  4. Save a file with a name you choose:
    curl -o mycopy.zip https://example.com/file.zip
  5. Follow a redirect:
    curl -L http://example.com
    A redirect sends you from one address to another. The -L option tells cURL to follow it.
  6. Show details of the connection:
    curl -v https://example.com
    The -v stands for verbose. It prints every step and is great for fixing problems.

Send data

curl -X POST -d "name=Sam" https://example.com/form

This command sends the text name=Sam to a web address, like a filled-in form.

Handy status codes

CodeMeaning
200All good
301 or 302The page moved
403Not allowed
404Page not found
500Server error
Tip: Use quotes around web addresses that contain & or ?. Otherwise the terminal may misread them.

Quick recap

  • cURL fetches web content from the command line.
  • curl -I shows headers.
  • curl -O downloads a file.
  • curl -L follows redirects.
  • curl -v helps you find problems.