Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.
Share on:

10 cURL Command Usage with Real-Time Example

Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.

cURL is a command-line tool to get or send data using URL syntax.

If you are working as a developer or in the support function, you must be aware of cURL command usage to troubleshoot web applications. cURL is a cross-platform utility means you can use on Windows, MAC, and UNIX.

The following are some of the most used syntaxes with an example to help you.

Verify if you can connect to the URL

If you are working on a UNIX system and trying to connect the external URL, the first thing you wish to do is to check if you can access the URL through curl.


It will not throw any output. However, if the server can’t connect, then you will get errors such as could not resolve the host.

[root@gf-lab tmp]# curl
curl: (6) Could not resolve host:; Unknown error
[root@gf-lab tmp]#

Save URL/URI output to file

If you have to save the URL or URI contents to a specific file, you can use the following syntax

curl > yoururl.html


[root@gf-lab tmp]# curl > /tmp/gfhtml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 18557    0 18557    0     0  72565      0 --:--:-- --:--:-- --:--:-- 72772
[root@gf-lab tmp]#

Above example will save all the contents from to /tmp/gf.html

Show request and response header

If you are having issues and would like to validate, you are getting the expected request and response header.

curl -v


[root@gf-lab tmp]# curl -v
* About to connect() to port 443 (#0)
*   Trying
* Connected to ( port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* 	subject:,OU=PositiveSSL Multi-Domain,OU=Domain Control Validated
* 	start date: Nov 07 00:00:00 2019 GMT
* 	expire date: May 15 23:59:59 2020 GMT
* 	common name:
* 	issuer: CN=COMODO ECC Domain Validation Secure Server CA 2,O=COMODO CA Limited,L=Salford,ST=Greater Manchester,C=GB
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host:
> Accept: */*
< HTTP/1.1 200 OK
< Date: Sat, 09 Nov 2019 19:41:37 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Set-Cookie: __cfduid=d2ce6cd359ebc0b6eb5ff3a454ed042021573328497; expires=Sun, 08-Nov-20 19:41:37 GMT; path=/;; HttpOnly; Secure
< Vary: Accept-Encoding
< Link: <>; rel=""
< Link: <>; rel=shortlink
< X-SRCache-Fetch-Status: HIT
< X-SRCache-Store-Status: BYPASS
< X-Frame-Options: SAMEORIGIN
< X-Powered-By: EasyEngine v4.0.12
< Via: 1.1 google
< CF-Cache-Status: DYNAMIC
< Strict-Transport-Security: max-age=15552000; preload
< X-Content-Type-Options: nosniff
< Alt-Svc: h3-23=":443"; ma=86400
< Expect-CT: max-age=604800, report-uri=""
< Server: cloudflare
< CF-RAY: 533243e4bcd4bbf4-LHR

Download at a limit rate

If you are working on optimization and would like to see how much time does it take to download at a particular speed, you can:-

curl –-limit-rate 2000B


curl –-limit-rate 2000B

Using a proxy to connect

Very handy if you are working on the DMZ server where you need to connect to the external world using a proxy.

curl --proxy yourproxy:port

Test URL with injecting header

You can use curl by inserting a header with your data to test or troubleshoot the particular issue. Let’s see the following example to request with Content-Type.

curl --header 'Content-Type: application/json'

By doing above, you are asking curl to pass Content-Type as application/json in the request header.

Display only response header

If you are doing some troubleshooting and quickly want to check the response header, you can use the following syntax.

curl --head


[root@gf-lab tmp]# curl --head
HTTP/1.1 200 OK
Date: Sat, 09 Nov 2019 19:51:23 GMT
Content-Type: text/html
Connection: keep-alive
Set-Cookie: __cfduid=d3cb2c7b8e566ad99c870b0af12b0f1eb1573329083; expires=Sun, 08-Nov-20 19:51:23 GMT; path=/;; HttpOnly
X-GUploader-UploadID: AEnB2Uo96JhvJmR2zYUL-Ndh2ta3UD_ykQAB5C7O8cjZQhCf-GxHQ0MsodSzRnl3guSN3ywAYNjtWcPXfwDXjLg3bQ-P5vQMOA
Expires: Sat, 09 Nov 2019 20:51:23 GMT
Cache-Control: public, max-age=3600
Last-Modified: Mon, 06 Aug 2018 10:45:47 GMT
x-goog-generation: 1533552347482034
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 24620
x-goog-hash: crc32c=DpDPAQ==
x-goog-hash: md5=cIP/3rusdUx12Zla1kf1yA==
x-goog-storage-class: MULTI_REGIONAL
Accept-Ranges: bytes
CF-Cache-Status: DYNAMIC
Expect-CT: max-age=604800, report-uri=""
Server: cloudflare
CF-RAY: 53325234dc2fbb9a-LHR

[root@gf-lab tmp]#

Connect HTTPS/SSL URL and ignore any SSL certificate error

When you try to access SSL/TLS cert secured URL and if that is having the wrong cert or CN doesn’t match, then you will get the following error.

curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.

Good news, you can instruct cURL to ignore the cert error with --insecure flag.

curl --insecure

Connect using a specific protocol (SSL/TLS)

Very handy to test if a particular URL can handshake over a specific SSL/TLS protocol.

To connect using SSL v3

curl --sslv3

and for different TLS versions

curl --tlsv1
curl --tlsv1.0
curl --tlsv1.1
curl --tlsv1.2
curl --tlsv1.3

Download file from FTP Server

You can use curl to download the file as well by specifying your username and password.

curl -u user:password -O ftp://ftpurl/style.css

You can always use “-v” with any syntax to print in verbose mode.

Using Host Header

The host header is useful to test the target URL over IP when the requested content is only available when the host header matches. Or, if you want to test the application using load balancer IP/URL.

curl --header 'Host:'

How about using cURL online?

Yes, that’s possible with the following tools. You can execute cURL remotely.

Online CURL – a lightweight tool to fetch the URL online and the possibility to add the following options.


cURL command line builder – this one is different. It helps you to build the curl command where you can enter information in nice UI, and at the bottom, you will get the cURL command.


cURL is a useful utility to troubleshoot a real-time connectivity issue, and I hope the above helps you. If you are looking to learn more, then I would recommend Linux Command Line Basics online course.

Thanks to our Sponsors
More great readings on Linux
Power Your Business
Some of the tools and services to help your business grow.
  • Invicti uses the Proof-Based Scanning™ to automatically verify the identified vulnerabilities and generate actionable results within just hours.
    Try Invicti
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.
    Try Brightdata
  • Semrush is an all-in-one digital marketing solution with more than 50 tools in SEO, social media, and content marketing.
    Try Semrush
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.
    Try Intruder