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. curl yoururl.com 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.

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 ex: Above example will save all the contents from  gf.dev 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. Ex:

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:- Ex:

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.

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. 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. Ex:

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. Good news, you can instruct cURL to ignore the cert error with –insecure flag.

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 and for different TLS versions

Download file from FTP Server

You can use curl to download the file as well by specifying your username and password. 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.

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.

10 cURL Command Usage with Real Time Example - 1310 cURL Command Usage with Real Time Example - 710 cURL Command Usage with Real Time Example - 2810 cURL Command Usage with Real Time Example - 510 cURL Command Usage with Real Time Example - 9310 cURL Command Usage with Real Time Example - 3410 cURL Command Usage with Real Time Example - 2010 cURL Command Usage with Real Time Example - 9110 cURL Command Usage with Real Time Example - 2710 cURL Command Usage with Real Time Example - 7010 cURL Command Usage with Real Time Example - 6810 cURL Command Usage with Real Time Example - 3810 cURL Command Usage with Real Time Example - 9410 cURL Command Usage with Real Time Example - 2410 cURL Command Usage with Real Time Example - 9610 cURL Command Usage with Real Time Example - 4310 cURL Command Usage with Real Time Example - 4010 cURL Command Usage with Real Time Example - 2310 cURL Command Usage with Real Time Example - 9410 cURL Command Usage with Real Time Example - 7010 cURL Command Usage with Real Time Example - 8910 cURL Command Usage with Real Time Example - 7210 cURL Command Usage with Real Time Example - 810 cURL Command Usage with Real Time Example - 41