Skip to content
Search

CURL

lastmod 2025-07-02created 2014-02-1778 edits

cURL is a computer software project providing a library and command-line tool for transferring data using various protocols. The cURL project produces two products, libcurl and cURL. It was first released in 1997.

Provides a command-line program and a C API library that support data transfer using various protocols.

Categories

Examples

Too many, so split into a separate page.

Alternatives

Checking your global IP

Visit a site that shows your global IP:

  • curl ifconfig.me
  • curl ident.me
  • curl ifconfig.me
  • curl icanhazip.com
  • curl ipecho.net/plain
  • curl ipv4.icanhazip.com

Options

-f, --fail
If the HTTP status code is not 200, propagates an error to the exit code. Needed when writing command-line scripts.
--connect-timeout
Maximum time in seconds that you allow the connection to the server to take.
-m, --max-time
Maximum time in seconds that you allow the whole operation to take.
-s, --silent
Silent or quiet mode.
So if you don't want any output use: curl -s 'http://example.com' > /dev/null
-L, --location
When a 301 Moved Permanently error occurs, follows the Location information in the header and moves to the new address.
-o [FILE]
Specifies the name of the file to download to.
curl -o index.htmlhttp://www.netscape.com/
-O
Downloads using the file name from the web page.
curl -Ohttp://www.netscape.com/index.html
-u/--user [username][:passwd]
ID and PASSWORD for authentication.
-e [Referrer URL]
Sets the referrer (referer). (referrer)
--max-filesize [size]
Limits the size of the file to download.
-T/--upload-file [FILE]
Transfer file to remote site.
-s/--silent
Silent mode. Don't output anything.
-S/--show-error
Show error. With -s, make curl show errors when they occur.
-m/--max-time [seconds]
Maximum time allowed for the transfer.
--connect-timeout [seconds]
Maximum time allowed for connection.
--ftp-create-dirs
Create the remote dirs if not present (F).
--verbose, --trace,, --trace-ascii
Protocol debugging. Gives detailed information about the HTTP data exchange. If verbose is not enough, use trace-ascii.
-k, --insecure
Forces a connection even to insecure servers. Verifies the server connection by checking that the server's certificate contains the right name, and verifies it successfully using the certificate store.

Error codes

CURLE_OK (0)
All fine. Proceed as usual.
CURLE_OPERATION_TIMEDOUT (28)
Operation timeout. The specified time-out period was reached according to the conditions.
CURLM_ADDED_ALREADY (7)
An easy handle already added to a multi handle was attempted to get added a second time. (Added in 7.32.1)
CURLE_GOT_NOTHING (52)
Nothing was returned from the server, and under the circumstances, getting nothing is considered an error.

Adding to the certificate authority list

Run curl with the -v option to see where it loads the CA list from.

$ curl -v  https://google.com
* About to connect() to google.com port 443 (#0)
*   Trying 74.125.128.139... connected
* Connected to google.com (74.125.128.139) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
  • Ubuntu loads the CA list from /etc/ssl/certs/ca-certificates.crt or the /etc/ssl/certs directory
  • RHEL/CentOS loads the CA list from /etc/pki/tls/certs/ca-bundle.crt, as shown below
  • Mac OSX loads the CA list from /etc/ssl/cert.pem

See OpenSSL for how to extract certificates.

Running a downloaded script directly in the Bash shell or PowerShell without saving it to a file

See the sample from k3s:

curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644

In short:

curl -sfL https://raw.githubusercontent.com/your/bash/script.sh | bash

For reference, if you want a similar command in PowerShell:

powershell -Command "iwr https://fly.io/install.ps1 -useb | iex"

Alternatives when curl is not available

See also

  • URI
  • URL
  • URN
  • wget
  • Fiddler
  • WireShark
  • ciao - Simple HTTP server monitoring tool
  • aria2 - aria2 is a lightweight multi-protocol & multi-source command-line download utility.
  • crul - A tool that queries any web page or API for free
  • resty - Command line
  • HTTPie (httpie) - Command line
  • Vim REST Console - vim plugin
  • Posting - HTTP API client for the terminal
  • Pipet - CLI tool for scraping/extracting data online
  • ArchiveBox - ArchiveBox self-hosts an internet archive
  • Hurl - Text-based tool for HTTP requests and testing on the command line
  • Vet – A tool for running remote shell scripts more safely

Favorite site

References


  1. Document page: Curl.haxx.se.zip ↩

author Zer0 sitemap