

{"id":110420,"date":"2022-09-09T10:00:58","date_gmt":"2022-09-09T04:30:58","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=110420"},"modified":"2022-09-09T10:12:47","modified_gmt":"2022-09-09T04:42:47","slug":"curl-command-in-linux","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/","title":{"rendered":"Curl Command in Linux"},"content":{"rendered":"<p>In this article, you will learn all there is to the curl command in Linux-based operating systems. We will be going through, what the curl command is, how to install it, syntax, options, and understanding its progress meter.<\/p>\n<p>In the end, we will also look at some practical examples of the curl command in the Linux terminal. So sit down, grab a snack, pay attention, and read right till the end of this long yet effective article.<\/p>\n<h3>What is Linux curl command?<\/h3>\n<p>Curl is a command-line-based tool in Linux-based operating systems used for transferring data to or from servers designed to work without user interaction. With the help of the curl command, you can either upload or download data using any supported protocols.<\/p>\n<p>The protocols supported by the curl command are HTTP, HTTPS, FTP, SFTP, TFTP, TELNET, LDAP, FILE, FTP, IMAP, POP3, and SCP. The curl command is powered by libcurl. One of the standalone features of curl is that it is designed to work without user interaction.<\/p>\n<p>The curl command comes with a range of options that allows you to resume transfers, limit the bandwidth, proxy support, user authentication, and more. Curl can also transfer multiple files in just one command and we will see all these options and beautiful examples in the subsequent sections.<\/p>\n<h3>Installing curl<\/h3>\n<p>Curl does not come preinstalled in most distributions of Linux, to download it follow the command shown below with respect to your following Linux distribution:<\/p>\n<h4>Installing curl in Debian based Linux distros<\/h4>\n<p>If you want to install curl on Debian based Linux operating systems like Ubuntu, Kali, ParrotOS, MX Linux, Mint, Deepin, etc, use the command shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo apt install curl<\/pre>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/installing-curl-in-ubuntu.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110562\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/installing-curl-in-ubuntu.webp\" alt=\"installing curl in ubuntu\" width=\"780\" height=\"378\" \/><\/a><\/h4>\n<h4>Installing curl in Fedora-based Linux distros<\/h4>\n<p>If you want to install curl on Fedora-based Linux operating systems like Fedora spins, CentOS, Berry Linux, Qubes OS, RHEL, etc, use the command shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo yum install curl<\/pre>\n<h3>Syntax of the curl command<\/h3>\n<p>The syntax of the curl command is pretty easy:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl &lt;options&gt; &lt;URL&gt;<\/pre>\n<p>Let us take a closer look at the fields present in the syntax of the curl command:<\/p>\n<h4>1. &lt;options&gt;<\/h4>\n<p>This field takes in a range of options that specifies how the curl command should function and sprint the output. These options allow you to do tasks like resuming transfers, limiting the bandwidth, proxy support, user authentication, and more.<\/p>\n<h4>2. &lt;URL&gt;<\/h4>\n<p>This field takes in the URL of the website you either want to download or upload files to. You can even specify multiple URLS in this field.<\/p>\n<h3>Options used with the curl command<\/h3>\n<p>As we have seen, there is a field in the syntax of the curl command that takes in a wide range of options. In typical Linux fashion, the curl command has a gargantuan list of options, let us take a look at them:<\/p>\n<h4>1. -a<\/h4>\n<p>This option appends to the target file instead of overwriting when use in an FTP upload. If the file you specified does not exist, it will create one for you.<\/p>\n<h4>2. -A<\/h4>\n<p>This option specifies the User-agent string to send to the HTTP server.<\/p>\n<h4>3. &#8211;anyauth<\/h4>\n<p>This option Tells curl to figure out the authentication method by itself, and use the most secure method the remote site claims it supports.<\/p>\n<h4>4. -b<\/h4>\n<p>This option passes the data to the HTTP server as a cookie<\/p>\n<h4>5. -B<\/h4>\n<p>This option enables ASCII transfer<\/p>\n<h4>6. &#8211;basic<\/h4>\n<p>This option tells curl to use HTTP Basic authentication. This is the default and this option is usually pointless. The only scenario you use this option is to override a previously set option that sets a different authentication method.<\/p>\n<h4>7. &#8211;ciphers<\/h4>\n<p>This option specifies which ciphers to use in the connection.<\/p>\n<h4>8. &#8211;compressed<\/h4>\n<p>This option requests a compressed response using one of the algorithms supported by the curl command<\/p>\n<h4>9. &#8211;connect-timeout<\/h4>\n<p>This option limits the connection phase<\/p>\n<h4>10. -c<\/h4>\n<p>This option specifies what file you want curl to write all cookies after a completed operation.<\/p>\n<h4>11. -C<\/h4>\n<p>This option continues or resumes a previous file transfer at the specified offset<\/p>\n<h4>12. &#8211;create-dirs<\/h4>\n<p>This option creates the necessary local directory hierarchy as needed.<\/p>\n<h4>13. &#8211;crif<\/h4>\n<p>This option converts LF to CRLF in upload.<\/p>\n<h4>14. -d<\/h4>\n<p>This option Sends the specified data in a POST request to the HTTP server.<\/p>\n<h4>15. &#8211;data-ascii<\/h4>\n<p>This option is the alias for the option \u201c-d\u201d.<\/p>\n<h4>16. &#8211;data-binary<\/h4>\n<p>This option posts data exactly as specified with no extra processing whatsoever.<\/p>\n<h4>17. &#8211;delegation<\/h4>\n<p>This option sets the level you specified to tell the server what it is allowed to delegate with the user credentials. The following are the levels you can specify:<\/p>\n<ul>\n<li>None &#8211; Don&#8217;t allow any delegation.<\/li>\n<li>Policy &#8211; Delegates if and only if the option \u201cOK-AS-DELEGATE\u201d flag is set in the Kerberos service ticket.<\/li>\n<li>Always &#8211; Unconditionally allow the server to delegate.<\/li>\n<\/ul>\n<h4>18. &#8211;digest<\/h4>\n<p>This option enables HTTP Digest authentication.<\/p>\n<h4>19. -D<\/h4>\n<p>This option writes the protocol headers to the specified file.<\/p>\n<h4>20. -e<\/h4>\n<p>This option sends the &#8220;Referrer Page&#8221; information to the HTTP server.<\/p>\n<h4>21. &#8211;engine<\/h4>\n<p>This option selects the OpenSSL crypto engine to use for cipher operations.<\/p>\n<h4>22. &#8211;environment<\/h4>\n<p>This option Sets a range of environment variables.<\/p>\n<h4>23. -E<\/h4>\n<p>This option specifies the client certificate files when getting a file with HTTPS, FTPS, or another SSL-based protocol.<\/p>\n<h4>24. -f<\/h4>\n<p>This option is similar to quiet mode, it prints no output at all on server error.<\/p>\n<h4>25. &#8211;ftp-account<\/h4>\n<p>This option asks for &#8220;account data&#8221; after a username and password were provided, this data is sent off using the ACCT command.<\/p>\n<h4>26. -F<\/h4>\n<p>This option lets curl emulate a filled-in form where a user has pressed the submit button.<\/p>\n<h4>27. -g<\/h4>\n<p>This option switches off the &#8220;URL globbing parser&#8221;.<\/p>\n<h4>28. -G<\/h4>\n<p>This option makes all data specified with -d\/&#8211;data or &#8211;data-binary to be used in an HTTP GET request instead of the POST request that otherwise would be used.<\/p>\n<h4>29. &#8211;ignore-content-length<\/h4>\n<p>This option ignores the Content-Length header. It is very useful, particularly for servers running Apache 1.<\/p>\n<h4>30. -i<\/h4>\n<p>This option includes the HTTP header in the output.<\/p>\n<h4>31. -I<\/h4>\n<p>This option fetches only the HTTP header.<\/p>\n<h4>32. -k<\/h4>\n<p>This option explicitly allows the curl command to perform &#8220;insecure&#8221; SSL connections and transfers.<\/p>\n<h4>33. &#8211;krb<\/h4>\n<p>This option enables Kerberos authentication and use.<\/p>\n<h4>34. -K<\/h4>\n<p>This option specifies which config file to read the curl arguments.<\/p>\n<h4>35. &#8211;limit-rate<\/h4>\n<p>This option specifies the maximum transfer rate you want curl to use.<\/p>\n<h4>36. &#8211;local-port<\/h4>\n<p>This option sets a preferred number or range of local port numbers to use for the connection<\/p>\n<h4>37. &#8211;libcurl<\/h4>\n<p>When you append this option to any ordinary curl command line, you receive as output C source code that uses libcurl, written to the file that does the equivalent of what your command-line operation does<\/p>\n<h4>38. &#8211;max-filesize<\/h4>\n<p>This option specifies the maximum size (in bytes) of a file to download.<\/p>\n<h4>39. -m<\/h4>\n<p>This option specifies the maximum time in seconds you allow the whole operation to take.<\/p>\n<h4>40. &#8211;mail-auth<\/h4>\n<p>This option Specify a single address that will be used to specify the authentication address or identity of a submitted message that is being relayed to another server.<\/p>\n<h4>41. &#8211;mail-from<\/h4>\n<p>This option specifies a single address that the given mail should get sent to.<\/p>\n<h4>42. &#8211;metalink<\/h4>\n<p>This option tells curl to parse and process a given URI as a Metalink file and make use of the mirrors listed within for failover if there are errors.<\/p>\n<h4>43. -n<\/h4>\n<p>This option makes the curl command scan the .netrc file in the user&#8217;s home directory for login name and password.<\/p>\n<h4>44. &#8211;negotiate<\/h4>\n<p>This option enables GSS-Negotiate authentication.<\/p>\n<h4>45. &#8211;no-keepalive<\/h4>\n<p>This option disables the use of keepalive messages on the TCP connection, as by default curl enables them.<\/p>\n<h4>46. -N<\/h4>\n<p>This option disables the buffering of the output stream.<\/p>\n<h4>47. -o<\/h4>\n<p>This option writes the output to the file you specified instead of stdout.<\/p>\n<h4>48. -O<\/h4>\n<p>This option writes the output to a local file named like the remote file we get.<\/p>\n<h4>49. -Q<\/h4>\n<p>This option sends an arbitrary command to the remote FTP or SFTP server.<\/p>\n<h4>50. &#8211;raw<\/h4>\n<p>This option disables all internal HTTP decoding of content or transfer encodings and instead makes them passed on unaltered, raw.<\/p>\n<p>PHEW!! Those are a lot of options! Even though we hit half a century, we barely scratched the surface of the gargantuan list of options available with the curl command. Nonetheless, we do not use most of these options on a regular basis, enact we will look at the most used option in action in subsequent sections.<\/p>\n<h3>Environmental variables used by the curl command<\/h3>\n<p>You can specify environment variables either in lowercase or uppercase, let us look at the environment variables used by the curl command:<\/p>\n<h4>1. http_PROXY [protocol:\/\/]&lt;host&gt;[:port]<\/h4>\n<p>This environment variable sets the proxy server to use for HTTP.<\/p>\n<h4>2. HTTPS_PROXY [protocol:\/\/]&lt;host&gt;[:port]<\/h4>\n<p>This environment variable sets the proxy server to use for HTTPS.<\/p>\n<h4>3. [url-protocol]_PROXY [protocol:\/\/]&lt;host&gt;[:port]<\/h4>\n<p>This environment variable sets the proxy server to use for the specified [url-protocol],<\/p>\n<h4>4. ALL_PROXY [protocol:\/\/]&lt;host&gt;[:port]<\/h4>\n<p>This environment variable sets the proxy server to use if no protocol-specific proxy is set.<\/p>\n<h4>5. NO_PROXY<\/h4>\n<p>This environment variable specifies the list of hostnames that shouldn&#8217;t go through any proxy.<\/p>\n<h3>Progress meter vs progress bar<\/h3>\n<p>When you are using curl (while uploading or downloading files), the curl command by default displays a progress meter that indicates the amount of transferred data, transfer speeds and estimated time left, and more. As shown below:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/showing-progress-meter.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110564\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/showing-progress-meter.webp\" alt=\"showing progress meter\" width=\"780\" height=\"150\" \/><\/a><\/p>\n<p>However, If you want a progress bar instead of a meter, use the option \u201c-#\u201d as shown below:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/showing-progress-bar.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110565\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/showing-progress-bar.webp\" alt=\"showing progress bar\" width=\"780\" height=\"92\" \/><\/a><\/p>\n<p>Now that we have liad down the fundamentals, let us look at some practical examples of the curlc command in the terminal.<\/p>\n<h3>Saving output to a file<\/h3>\n<p>To save the output of the curl command to a file, use the option \u201c-o\u201d or \u201c-O\u201d as shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -o &lt;filename&gt; &lt;URL&gt;<\/pre>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/saving-output-to-a-file.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110566\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/saving-output-to-a-file.webp\" alt=\"saving output to a file\" width=\"780\" height=\"88\" \/><\/a><\/h3>\n<h3>Downloading multiple files<\/h3>\n<p>If you want to download multiple files in just one command, use multiple options \u201c-o\u201ds followed by the URLS you want to download as shown:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -o &lt;filename&gt; &lt;URL1&gt; &lt;URL2&gt;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/downloading-multiple-files.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110567\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/downloading-multiple-files.webp\" alt=\"downloading multiple files\" width=\"780\" height=\"160\" \/><\/a><\/p>\n<p>In the above examples, we downloaded the iso files of Arch Linux and Debian is just one command.<\/p>\n<h3>Resuming a download<\/h3>\n<p>Say for some reason, your download failed, instead of downloading again from scratch, you can resume that particular download by using the option \u201c-C -\u201d as shown:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -C -o &lt;filename&gt; &lt;URL&gt;<\/pre>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/resuming-a-download.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110568\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/resuming-a-download.webp\" alt=\"resuming a download\" width=\"780\" height=\"177\" \/><\/a><\/h3>\n<h3>Retrieving the HTML headers of a URL<\/h3>\n<p>Before we retrieve them let us take a glance at what HTML headers are. HTML headers are colon-separated key-value pairs that contain various information like user agent, content type, encoding and so much more.<\/p>\n<p>These headers are passed between the server and clients with responses or requests. To retrieve the HTML headers of a webpage, use the option \u201c-I\u201d as shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -I &lt;URL&gt;<\/pre>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/retrieving-the-html-headers-of-url.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110569\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/retrieving-the-html-headers-of-url.webp\" alt=\"retrieving the html headers of url\" width=\"780\" height=\"193\" \/><\/a><\/h3>\n<h3>Testing if a website supports HTTP\/2<\/h3>\n<p>If you want to check if a particular website supports the HTTP\/2 protocol or not retrieve the HTML header by using the option \u201c-I\u201d followed by the option \u201c&#8211;http2\u201d and piping this output to a grep command to see if it matched the string \u201cHTTP\u201d as shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -I --http2 -s &lt;URL&gt;<\/pre>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/testing-if-a-website-supports-http2.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110570\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/testing-if-a-website-supports-http2.webp\" alt=\"testing if a website supports http2\" width=\"780\" height=\"68\" \/><\/a><\/h3>\n<h3>Following redirects<\/h3>\n<p>By default, curl does not follow the HTTP location headers. However, if you are interested in following these redirects, you can use the option \u201c-L\u201d. For example, if you simply run the command \u201ccurl google.com\u201d, you will be redirected to the WWW version of it as shown:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/using-normal-curl-command-with-no-options-will-not-follow-any-redirects.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110572\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/using-normal-curl-command-with-no-options-will-not-follow-any-redirects.webp\" alt=\"using normal curl command with no options will not follow any redirects\" width=\"780\" height=\"161\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>But, If you are interested in retrieving the non-WWW version, use the option \u201c-L\u201d, as this option tells curl to follow any redirect until it reaches the final destination. Use the syntax shown:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -L &lt;filename&gt; &lt;URL&gt;<\/pre>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/following-redirects.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110571\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/following-redirects.webp\" alt=\"following redirects\" width=\"780\" height=\"339\" \/><\/a><\/h3>\n<h3>Changing the User-Agent<\/h3>\n<p>When downloading a file, the remote server may sometimes be set to block curl User-Agent or to return different contents. In such scenarios, to emulate a different browser, use the option \u201c-A\u201d as shown below:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/changing-the-user-agent.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110573\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/changing-the-user-agent.webp\" alt=\"changing the user agent\" width=\"780\" height=\"231\" \/><\/a><\/p>\n<h3>Specifying a maximum transfer rate<\/h3>\n<p>We saw that the option \u201c&#8211;limit-rate\u201d allows you to limit the data transfer rate. You can specify the value in bytes, kilobytes (k), megabytes (m), and gigabytes (g).<\/p>\n<p>For example, if you want to set the download speed to 1mb, use the command shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl --limit-rate &lt;n&gt; -o &lt;filename&gt; &lt;URL&gt;<\/pre>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/specifying-a-maximum-transfer-rate.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110574\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/specifying-a-maximum-transfer-rate.webp\" alt=\"specifying a maximum transfer rate\" width=\"780\" height=\"87\" \/><\/a><\/h3>\n<h3>Transferring files through FTP<\/h3>\n<p>If you want to access a protected FTP server with the curl command, ue the option \u201c-u\u201d and specify the username and password as shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -u &lt;username&gt; &lt;password&gt; ftp:\/\/ftp.example.com\/<\/pre>\n<p>Upon successful login, the command lists all the files and directories in the user\u2019s home directory. You can also download a single ftp file from the FTP server using the following syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -u &lt;username&gt;:&lt;password&gt; ftp:\/\/ftp.example.com\/file.tar.gz<\/pre>\n<p>Similarly to upload a file to the FTP server use the option \u201c-T\u201d followed by the name of the file you want to upload:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -T newfile.tar.gz -u &lt;username&gt;:&lt;password&gt; ftp:\/\/ftp.example.com\/<\/pre>\n<h3>Sending cookies<\/h3>\n<p>Sometimes, you may need to make an HTTP request with a specific set of cookies to access a remote resource. By default, when you request a resource with the curl command, no cookies are sent or stored. Nonetheless, if you want to send cookies to a server, use the option \u201c-b\u201d followed by the name of the cookies as shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -L -b &lt;cookie name&gt; -o &lt;filename&gt; &lt;URL&gt;<\/pre>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/sending-cookies.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110575\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/sending-cookies.webp\" alt=\"sending cookies\" width=\"780\" height=\"131\" \/><\/a><\/h3>\n<h3>Using proxies<\/h3>\n<p>We have already seen that the curl command supports different types of proxies like HTTP, HTTP, SOCKS and so many more. If you want to transfer data through a proxy server, the option \u201c-x\u201d or \u201c&#8211;proxy\u201d followed by the URL of the proxy as shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl -x &lt;URL&gt;<\/pre>\n<p>The command shown above downloads specified resource using a proxy on 192.168.44.1 port 8888<\/p>\n<h3>DICT protocol<\/h3>\n<p>Libcurl defined the DICT protocol that can be used to easily get the definition or meaning of any word directly from the command line: use the following syntax to use the DICT protocol:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl [protocol:[dictionary_URL]:[word]<\/pre>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/using-dict-protocol.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110576\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/using-dict-protocol.webp\" alt=\"using dict protocol\" width=\"780\" height=\"361\" \/><\/a><\/h3>\n<h3>Checking the version of curl<\/h3>\n<p>If you want to check the version of the curl command you are using in your computer use the option \u201c&#8211;version\u201d to print information about the version and exit. Use the command \u201ccurl &#8211;version\u201d<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/checking-the-version-of-curl.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110577\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/checking-the-version-of-curl.webp\" alt=\"checking the version of curl\" width=\"780\" height=\"144\" \/><\/a><\/p>\n<h3>Downloading multiple files from a file<\/h3>\n<p>We have already seen that we can download multiple files using the curl command by using multiple option \u201c-o\u201ds and specifying the URLS one after the other. But, instead of doing such a tedious job, you can simply write all the links in one text file and later use the \u201cxargs\u201d command to download from the file as shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">xargs -n -1 curl -O &lt; &lt;filename&gt;<\/pre>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/downloading-multiple-files-from-a-file.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110578\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/downloading-multiple-files-from-a-file.webp\" alt=\"downloading multiple files from a file\" width=\"780\" height=\"258\" \/><\/a><\/h3>\n<h3>Modifying name resolution<\/h3>\n<p>Say you are a web developer and want to test a local version of \u201cyourdomain com\u201d before pushing it live. To do so, use the option \u201c&#8211;resolve\u201d followed by the URL of your website as shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">curl --resolve www.yourdomain.com:80:localhost http:\/\/www.yourdomain.com\/<\/pre>\n<h3>Protocols supported by curl<\/h3>\n<p>We have seen that curl supports so many various kinds of protocols, it is only fair to have a look at the complete list:<\/p>\n<h4>1. DICT<\/h4>\n<p>This protocol is a dictionary network protocol for querying dictionary servers about the meanings of words.<\/p>\n<h4>2. FILE<\/h4>\n<p>This protocol is a URL scheme for obtaining a file from the local file system using curl.<\/p>\n<h4>3. FTP<\/h4>\n<p>This protocol stands for File Transfer Protocol, used for file transfers between clients and servers.<\/p>\n<h4>4. GOPHER<\/h4>\n<p>An old protocol for searching, retrieving, and distributing internet documents, a precursor of HTTP.<\/p>\n<h4>5. HTTPS<\/h4>\n<p>This protocol stands for Hypertext Transfer Protocol, used for web and internet data transfer.<\/p>\n<h4>6. IMAPS<\/h4>\n<p>This protocol stands for Internet Message Access Protocol, used for email access and management.<\/p>\n<h4>7. LDAP<\/h4>\n<p>This protocol stands for Lightweight Directory Access Protocol, used for distributed directory information access and management.<\/p>\n<h4>8. MQTT<\/h4>\n<p>This protocol stands for Message Queuing Telemetry Transport &#8211; a protocol for data exchange between small devices, usually IoT systems.<\/p>\n<h4>9. POP3<\/h4>\n<p>This protocol stands for Post Office Protocol version 3 &#8211; a protocol for email retrieval from a server.<\/p>\n<h4>10. RTMP<\/h4>\n<p>This protocol stands for Real-Time Messaging Protocol &#8211; a streaming protocol for audio, video, and other data.<\/p>\n<h4>11. RTSP<\/h4>\n<p>This protocol stands for Real-Time Streaming Protocol, used for streaming media servers management.<\/p>\n<h4>12. SCP<\/h4>\n<p>This protocol stands for Secure Copy &#8211; a protocol for copying files to and from an SSH server.<\/p>\n<h4>13. SFTP<\/h4>\n<p>This protocol stands for SSH File Transfer Protocol &#8211; a version of the File Transfer Protocol using the SSH connection.<\/p>\n<h4>14. SMB<\/h4>\n<p>This protocol stands for Server Message Block &#8211; a protocol for managing shared access to files and computer peripherals.<\/p>\n<h4>15. SMTP<\/h4>\n<p>This protocol stands for Simple Mail Transfer Protocol &#8211; an email protocol for easy transmission of email.<\/p>\n<h4>16. TELNET<\/h4>\n<p>This protocol is an application layer protocol for bidirectional interactive text-oriented communication.<\/p>\n<h4>17. TFTP<\/h4>\n<p>This protocol stands for Trivial File Transfer Protocol, used for uploading or downloading files to or from a remote host.<\/p>\n<h3>Summary<\/h3>\n<p>As you have seen the curl command is a really simple yet extremely useful tool that helps in uploading and downloading files from the web. You have now learned what curl is, how to install it, syntax, options, and so many examples of how to use the curl command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, you will learn all there is to the curl command in Linux-based operating systems. We will be going through, what the curl command is, how to install it, syntax, options, and&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":110556,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[27075,27073,27074],"class_list":["post-110420","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-install-curl-in-linux","tag-linux-curl-command","tag-syntax-of-linux-curl-command"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Curl Command in Linux - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn about curl command in linux. See how to install it, its syntax, options, and understanding its progress meter with practicals.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Curl Command in Linux - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn about curl command in linux. See how to install it, its syntax, options, and understanding its progress meter with practicals.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-09T04:30:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-09T04:42:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/curl-command-in-linux.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Curl Command in Linux - DataFlair","description":"Learn about curl command in linux. See how to install it, its syntax, options, and understanding its progress meter with practicals.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"Curl Command in Linux - DataFlair","og_description":"Learn about curl command in linux. See how to install it, its syntax, options, and understanding its progress meter with practicals.","og_url":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2022-09-09T04:30:58+00:00","article_modified_time":"2022-09-09T04:42:47+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/curl-command-in-linux.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9"},"headline":"Curl Command in Linux","datePublished":"2022-09-09T04:30:58+00:00","dateModified":"2022-09-09T04:42:47+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/"},"wordCount":2734,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/curl-command-in-linux.webp","keywords":["install curl in linux","Linux curl command","syntax of linux curl command"],"articleSection":["Linux Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/","url":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/","name":"Curl Command in Linux - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/curl-command-in-linux.webp","datePublished":"2022-09-09T04:30:58+00:00","dateModified":"2022-09-09T04:42:47+00:00","description":"Learn about curl command in linux. See how to install it, its syntax, options, and understanding its progress meter with practicals.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/curl-command-in-linux.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/curl-command-in-linux.webp","width":1200,"height":628,"caption":"curl command in linux"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/curl-command-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Linux Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/linux\/"},{"@type":"ListItem","position":3,"name":"Curl Command in Linux"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team is a group of passionate educators and industry experts dedicated to providing high-quality online learning resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With years of experience in the field, the team aims to simplify complex topics and help learners advance their careers. At DataFlair, we believe in empowering students and professionals with the knowledge and skills needed to thrive in today\u2019s fast-paced tech industry. Follow us for Free courses, expert insights, tutorials, and practical tips to boost your learning journey.","url":"https:\/\/data-flair.training\/blogs\/author\/datafbdad\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/110420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=110420"}],"version-history":[{"count":7,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/110420\/revisions"}],"predecessor-version":[{"id":110579,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/110420\/revisions\/110579"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/110556"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=110420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=110420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=110420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}