Introduction to the curl Command: Syntax, Options, and Examples
This article provides a comprehensive overview of the curl command-line tool, detailing its purpose, basic syntax, frequently used options, and practical examples for file downloading, uploading, and HTTP request testing, helping readers effectively leverage curl for network and data transfer tasks.
curl command is a file transfer tool that works from the command line using URL syntax. It supports uploading and downloading over many protocols (HTTP, HTTPS, FTP, etc.) and offers features such as POST, cookies, authentication, partial downloads, user‑agent strings, rate limiting, progress display, and more.
Syntax : curl [options] [URL] . Common options include:
-a, --append : Append to target file when uploading.
-A, --user-agent <string> : Set the User‑Agent header.
-b, --cookie <name=string/file> : Provide cookie data or file.
--basic : Use HTTP Basic authentication.
-c, --cookie-jar <file> : Write cookies to a file after the operation.
-C, --continue-at <offset> : Resume a transfer at the given offset.
-d, --data <data> : Send data via HTTP POST.
-D, --dump-header <file> : Write response headers to a file.
-o, --output <file> : Write output to the specified file.
-O, --remote-name : Save with the remote file name.
-R, --remote-time : Preserve remote file timestamp.
-u, --user <user[:password]> : Specify server user and password.
-U, --proxy-user <user[:password]> : Specify proxy authentication.
Examples :
Download a single file: curl http://man.linuxde.net/text.iso
Download multiple files: curl -o http://man.linuxde.net/text1.iso -o http://man.linuxde.net/text.iso
Download with progress bar and output file: curl http://man.linuxde.net/text.iso -o filename.iso --progress-bar
Limit download speed: curl http://man.linuxde.net/text.iso --limit-rate 50k
Set maximum file size: curl http://man.linuxde.net/text.iso --max-filesize 1000k
Download from FTP with credentials: curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/xss.php
Resume a broken download: curl http://man.linuxde.net/text.iso -C <offset> or curl -C - http://man.linuxde.net/text.iso
Upload a file: curl --form "[email protected]" http://hostname/resource
Additional HTTP request examples include viewing page source ( curl www.so.com ), performing GET and POST requests, displaying headers ( curl -i http://www.so.com ), showing the transfer process ( curl -v www.so.com ), using cookies, adding custom headers, and basic authentication ( curl -u name:password http://www.so.com ).
For more detailed usage, refer to the official curl manual at http://man.linuxde.net/curl .
360 Quality & Efficiency
360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.