0% found this document useful (0 votes)
49 views

5 Basic CURL Command Examples - RoseHosting

This document provides 5 examples of basic cURL commands: 1) Check a URL, 2) Save a URL's output to a file, 3) Download files, 4) Get HTTP header information, and 5) Access an FTP server. cURL is a command line tool that can be used to transfer data to and from servers using various protocols like HTTP, HTTPS, FTP, and more. The examples demonstrate how to view website content, save web pages locally, download files, view HTTP headers, and transfer files via FTP.

Uploaded by

semabay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

5 Basic CURL Command Examples - RoseHosting

This document provides 5 examples of basic cURL commands: 1) Check a URL, 2) Save a URL's output to a file, 3) Download files, 4) Get HTTP header information, and 5) Access an FTP server. cURL is a command line tool that can be used to transfer data to and from servers using various protocols like HTTP, HTTPS, FTP, and more. The examples demonstrate how to view website content, save web pages locally, download files, view HTTP headers, and transfer files via FTP.

Uploaded by

semabay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

5/29/2017 5basiccURLcommandexamplesRoseHosting.

comBlog

5basiccURLcommandexamples
OCTOBER21,2016 1 TIPSANDTRICKS

Facebook 0 Twitter 8 Google+ 2 Linkedin 2

cURLisveryusefulcommandlinetooltotransferdatafromortoaserver.cURLsupportsvariousprotocols

likeFILE,HTTP,HTTPS,IMAP,IMAPS,LDAP,DICT,LDAPS,TELNET,FTP,FTPS,GOPHER,RTMP,

RTSP,SCP,SFTP,POP3,POP3S,SMB,SMBS,SMTP,SMTPS,andTFTP.

cURLcanbeusedinmanydifferentandinterestingways.Withthistoolyoucandownload,uploadandmanage

files,checkyouremailaddress,orevenupdateyourstatusonsomeofthesocialmediawebsitesorcheckthe

weatheroutside.InthisarticlewillcoverfiveofthemostusefulandbasicusesofthecURLtoolonanyLinux

VPS.

1.CheckURL
OneofthemostcommonandsimplestusesofcURListypingthecommanditself,followedbytheURLyou

wanttocheck

https://www.rosehosting.com/blog/curlcommandexamples/ 1/4
5/29/2017 5basiccURLcommandexamplesRoseHosting.comBlog

curlhttps://domain.com

ThiscommandwilldisplaythecontentoftheURLonyourterminal

2.SavetheoutputoftheURLtoafile
TheoutputofthecURLcommandcanbeeasilysavedtoafilebyaddingtheooptiontothecommand,as

shownbelow

curlowebsitehttps://domain.com

%Total%Received%XferdAverageSpeedTimeTimeTimeCurrent
DloadUploadTotalSpentLeftSpeed
1004179304179300275k0::::::2.9M

Inthisexample,outputwillbesavetoafilenamedwebsiteinthecurrentworkingdirectory.

3.DownloadfileswithcURL
YoucandownlaodfileswithcURLbyaddingtheOoptiontothecommand.Itisusedforsavingfilesonthe

localserverwiththesamenamesasontheremoteserver

curlOhttps://domain.com/file.zip

Inthisexample,thefile.zipziparchivewillbedownloadedtothecurrentworkingdirectory.

YoucanalsodownloadthefilewithadifferentnamebyaddingtheooptiontocURL.

curloarchive.ziphttps://domain.com/file.zip

Thiswaythefile.ziparchivewillbedownloadedandsavedasarchive.zip.
https://www.rosehosting.com/blog/curlcommandexamples/ 2/4
5/29/2017 5basiccURLcommandexamplesRoseHosting.comBlog

cURLcanbealsousedtodownloadmultiplefilessimultaneously,asshownintheexamplebelow

curlOhttps://domain.com/file.zipOhttps://domain.com/file2.zip

cURLcanbealsousedtodownloadfilessecurelyviaSSHusingthefollowingcommand

curluusersftp://server.domain.com/path/to/file

Notethatyouhavetousethefullpathofthefileyouwanttodownload

4.GetHTTPheaderinformationfromawebsite
YoucaneasilygetHTTPheaderinformationfromanywebsiteyouwantbyaddingtheIoption(capitali)to

cURL.

curlIhttp://domain.com

HTTP/1.1200OK
Date:Sun,16Oct201623:37:15GMT
Server:Apache/2.4.23(Unix)
XPoweredBy:PHP/5.6.24
Connection:close
ContentType:text/html;charset=UTF8

5.AccessanFTPserver
ToaccessyourFTPserverwithcURLusethefollowingcommand

curlftp://ftp.domain.comuserusername:password

https://www.rosehosting.com/blog/curlcommandexamples/ 3/4
5/29/2017 5basiccURLcommandexamplesRoseHosting.comBlog

cURLwillconnecttotheFTPserverandlistallfilesanddirectoriesinusershomedirectory

YoucandownloadafileviaFTP

curlftp://ftp.domain.com/file.zipuserusername:password

anduploadafileottheFTPserver

curlTfile.zipftp://ftp.domain.com/userusername:password

YoucancheckcURLmanualpagetoseeallavailablecURLoptionsandfunctionalities

mancurl

https://www.rosehosting.com/blog/curlcommandexamples/ 4/4

You might also like