Linux command
curl 命令
网络
需要网络或远程资源。
常用示例
Download
curl -O [https://example.com/file.zip]
Save
curl -o [filename] [https://example.com/file]
POST
curl -X POST -d ["key=value"] [https://api.example.com]
Follow
curl -L [https://example.com]
Send
curl -H ["Content-Type: application/json"] -d ['{"key":"value"}'] [https://api.example.com]
Show
curl -I [https://example.com]
说明
curl is a command-line tool for transferring data with URLs. It supports HTTP, HTTPS, FTP, and many other protocols, making it essential for web development, API testing, and file transfers. The tool is ubiquitous in scripts, CI/CD pipelines, and system administration.
参数
- -O, --remote-name
- Save with remote filename
- -o, --output _file_
- Save to specified file
- -L, --location
- Follow redirects
- -X, --request _method_
- HTTP method (GET, POST, PUT, DELETE)
- -d, --data _data_
- Send POST data
- -H, --header _header_
- Add custom header
- -u, --user _user:pass_
- Authentication
- -I, --head
- Fetch headers only
- -v, --verbose
- Verbose output
- -s, --silent
- Silent mode
- -f, --fail
- Fail silently on HTTP errors
- -k, --insecure
- Allow insecure SSL connections
- -C, --continue-at _offset_
- Resume a previous download (use `-` for auto)
- --cookie _data|file_
- Send cookies (inline string or file path)
- --cookie-jar _file_
- Write received cookies to file
- --max-time _seconds_
- Maximum time allowed for the transfer
- --retry _N_
- Retry failed transfers up to N times
- -A, --user-agent _string_
- Send User-Agent header
- -e, --referer _url_
- Send Referer header
FAQ
What is the curl command used for?
curl is a command-line tool for transferring data with URLs. It supports HTTP, HTTPS, FTP, and many other protocols, making it essential for web development, API testing, and file transfers. The tool is ubiquitous in scripts, CI/CD pipelines, and system administration.
How do I run a basic curl example?
Run `curl -O [https://example.com/file.zip]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -O, --remote-name do in curl?
Save with remote filename