Curl is one of the popular command line tool that is used to receive or send data using a URL syntax. In simple terms , it is a software or command line utility tool for transferring data using various protocols.
The original author of the curl tool was a swedish developer by name Daniel Stenberg.
Most of the Support developers or web developers would be aware of this tool. It is a tool that may be used to troubleshoot web applications and is considered as a cross-platform tool that works on Mac , Linux and Windows.
In this blog post , we discuss 6 most commonly used Curl commands with examples.
Top 6 CURL Commands with examples
1. Test the connection to the Site
There are times when you want to check if you can access the URL or an external site. The first thing that you can do is use curl with the below syntax.
# curl Yoursite
Eg : # curl http://developerpublish.com
2. Save the Response to a File
If you want to save the response to a specific file you can use the syntax as shown below
# curl Yoursite > FileName.html
Eg : # curl http://developerpublish.com > response.html
In this example , the response of the URL or website will be saved in the file response.html
3. Proxy for connecting to the URL
There are times when you want to try connecting to the URL witha proxy. You can use the following syntax to perform this.
# curl –proxy yourproxy:port Yoursite
eg : # curl –proxy 192.168.1.2:8080 http://developerpublish.com
4. Ignore SSL Certificate error when connecting to HTTPS Site
There are times when you want to ignore the SSL error when connecting to the HTTPS site and you can use the –insecure property for it as shown below.
curl –insecure https://developerpublish.com
5. Connect to the URL using specific protocol like TLS/SSL
This is a handy command especially when you want to connect to a URL/URI with the specific protocol versions like SSL / SSLV3 / TLS etc.
To connect to a URL using the SSL V3
# curl –sslv3 https://<url>
Eg : # curl –sslv3 https://DeveloperPublish.com
To connect to a URL using the TLS V1
# curl –tlsv1 https://<url>
Eg : # curl –tlsv1 https://DeveloperPublish.com
6. Download a file from FTP Server
If you are a user trying to download a file frequently from the FTP , you can use the below curl command by specifying the username and password.
# curl -u username:password -O ftp://developerpublish.com/testfile.txt
How to use cURL online ?
Incase you wish to try out cURL online , there are various ways to do it. One such site is Online CURL which is a lightweight tool for testing the cURL commans online.