{"id":1592,"date":"2017-03-03T04:52:00","date_gmt":"2017-03-03T04:52:00","guid":{"rendered":"http:\/\/www.fastwebhost.in\/blog\/?p=1592"},"modified":"2019-01-22T11:50:54","modified_gmt":"2019-01-22T11:50:54","slug":"what-is-curl-and-how-to-use-curl-commands-in-linux","status":"publish","type":"post","link":"https:\/\/www.fastwebhost.in\/blog\/what-is-curl-and-how-to-use-curl-commands-in-linux\/","title":{"rendered":"10 Simple cURL Commands with Examples on Linux"},"content":{"rendered":"<h2>What is cURL?<\/h2>\n<p>cURL is an abbreviation for Client URL Request Library. Basically cURL is name of the project. \u200bcURL&nbsp;is used to transfer data from one place to another place. It is a command line tool for receiving and sending files using URL syntax. It consists of different cURL Commands and libraries which can work with different protocols.<\/p>\n<p>\u200bCURL and WGET&nbsp;have few similarities. WGET can be used to download single file\/folder where as CURL can download multiple files in a single shot.<\/p>\n<p>\u200bWGET can download an entire website with a single command. WGET only offers plain http post support where as CURL offers uploading and sending capabilities.<\/p>\n<h2>Advantages with CURL<\/h2>\n<ul>\n<li>We can see the downloaded file directly on console<\/li>\n<li>Ability to save downloads to a particular file name.<\/li>\n<li>With a single command we can download multiple files.<\/li>\n<li>There is an option to resume the download, from where it stops.<\/li>\n<li>Can set the rate limits for your downloads.<\/li>\n<li>it can work on all protocols.<\/li>\n<li>Shows the stats for the download like percentage, time.<\/li>\n<li>Works on wide variety of protocols and can be used on any of your programs.<\/li>\n<\/ul>\n<h2>Basic cURL Commands&nbsp;<\/h2>\n<p>Let&#8217;s see few basic cURL Commands<\/p>\n<h3>Downloading a web page using cURL?<\/h3>\n<p>For example you wish to see the content of a website, you can use below command<\/p>\n<p>curl http:\/\/fastwebhost.in<\/p>\n<p>Above command will only display the web page content , obviously, the page will be long so it keeps scrolling up.<\/p>\n<p>To see the page slowly we can add less, more using | to the above command like\u200b<\/p>\n<p>curl fastwebhost.in | more &amp; curl fastwebhost.in | less\u200b<\/p>\n<h3>\u200bSaving the output to a file<\/h3>\n<p>\u200bAbove cURL Commands will only display the content of the web page you requested, You can also save the output into a file directly,&nbsp;<\/p>\n<p>curl -o san.html fastwebhost.in\/san.html\u200b<\/p>\n<p>Using -o to curl command and giving a specific file name will save output to that file, Above instance san.html is the filename and content can be viewed with an editor.<\/p>\n<p>curl -O fastwebhost.in\/san.html\u200b<\/p>\n<p>&nbsp;Adding -O to CURL command it will use the tail part of the URL and downloads the content to that file.&nbsp;Above instance, file be saved as &#8220;san.html&#8221;<\/p>\n<h3>Downloading multiple files at a time<\/h3>\n<p>curl -O fastwebhost.in\/1.html -O fastwebhost.in\/2.html\u200b<\/p>\n<p>Above command will download both the URL&#8217;s at a time and benefit of using -O is that file can be saved directly to the file name, whereas in above case it saves with 1.html and 2.html<\/p>\n<h3>Continuing Download<\/h3>\n<p>curl -C fastwebhost.in<\/p>\n<p>This command would be very useful when you are trying t download a big file and when any downloading file gets interrupted.\u200b Adding -C will resume the download where it got stopped.<\/p>\n<h3>Data Transferring Limit<\/h3>\n<p>curl &#8211;limit-rate 100m -O fastwebhost.com\/san.html<\/p>\n<p>Use &#8211;limit-rate command to limit the data transfer to 100m. We can also give k, G.&nbsp;K = kilobytes G = Gigabytes<\/p>\n<h3>Showing Stats for the download<\/h3>\n<p>curl -# -O fastwebhost.com<\/p>\n<p>Adding <strong>-#<\/strong> above command will show the progress bar like total %,data transfer limits,downloaded speed,upload speed,time spent,time remaining.<\/p>\n<p>As discussed earlier curl will support various protocols.<\/p>\n<h3>Downloading and Uploading files to FTP using cURL Command<\/h3>\n<p>curl ftp:\/\/fastwebhost.com &#8211;user username:passowrd <\/p>\n<p>The above command will be listing files and directories under your root folder.<\/p>\n<p>curl ftp:\/\/fastwebhost.com\/san.tar.gz &#8211;user username:passowrd -o san.tar.gz<\/p>\n<p>Above command it will download the san.tar.gz file.<\/p>\n<p>curl -T san.tar.gz ftp:\/\/fastwebhost.com\/directory &#8211;user username:passowrd<\/p>\n<p>Adding&nbsp;-T above command can upload the files to mentioned&nbsp;specific directory by giving it as above.<\/p>\n<p>curl ftp:\/\/fastwebhost.com -X &#8216;DELE san.tar.gz&#8217; &#8211;user username:passowrd<\/p>\n<p>Adding -X above command &nbsp;can delete the mentioned file.<\/p>\n<h3>Ignoring SSL Certificate warnings<\/h3>\n<p>curl -k https:\/\/fastwebhost.com<\/p>\n<p>Sometimes when we access any website on browser it requires some user action like accepting &#8220;Advance section&#8221; &#8220;continue&#8221;, In that case we can use -k this will accept and continue.<\/p>\n<h3>Sending Emails using cURL Command<\/h3>\n<p>curl &#8211;mail-from san@fastwebhost.com &#8211;mail-rcpt shiv@fastwebhost.com smtp:\/\/ ip or mailserver.com<\/p>\n<p>Once you type the above command it will ask you to write the message after entering the message we need to give .(period) at last line which will be sending the email.<\/p>\n<h3>Downloading a file after a specific modification time<\/h3>\n<p>curl -z 8-feb-17 http:\/\/fastwebhost.com\/san.html<\/p>\n<p>Adding -z to curl command it will download a file only if the modification has done after the mentioned time in above command.<\/p>\n<h3>Conclusion<\/h3>\n<p>cURL Command can be used in different methods and can be used for various protocols like accessing FTP sites, sending emails,etc. Also, we keep updating this post with new commands. Keep watching.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is cURL? cURL is an abbreviation for Client URL Request Library. Basically cURL is name of the project. \u200bcURL&nbsp;is used to transfer data from one place to another place. It is a command line tool for receiving and sending files using URL syntax. It consists of different cURL Commands and libraries which can work [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":1984,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[22],"tags":[110],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/posts\/1592"}],"collection":[{"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/comments?post=1592"}],"version-history":[{"count":3,"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/posts\/1592\/revisions"}],"predecessor-version":[{"id":4710,"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/posts\/1592\/revisions\/4710"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/media\/1984"}],"wp:attachment":[{"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/media?parent=1592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/categories?post=1592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fastwebhost.in\/blog\/wp-json\/wp\/v2\/tags?post=1592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}