


What are the linux curl command parameters and how to use them
linux curl is a file transfer tool that uses url rules to work under the command line. It supports file upload and download, so it is a comprehensive transmission tool, but according to tradition, it is customary to call URL a download tool.
1. Curl command parameters
-a/--append When uploading files, append to the target file
-a/--user-agent
-anyauth Can use "any" authentication method
-b/--cookie
-basic Use http basic authentication
-b/--use-ascii Use ascii/text transmission
-c/--cookie-jar
-c/--continue-at
-d/--data http post mode Transmit data
--data-ascii Post data in ascii format
--data-binary Post data in binary format
--negotiate Use http authentication
--digest Use digital authentication
--disable-eprt Disable the use of eprt or lprt
--disable-epsv Disable the use of epsv
-d/--dump-header
--egd-file
--tcp-nodelay Use tcp_nodelay option
-e/--referer source URL
-e/--cert --cert-type --key --key-type --pass --engine --cacert --capath --ciphers --compressed Requires the returned state to be compressed (using deflate or gzip) --connect-timeout --create-dirs Create a directory for the local directory Hierarchy --crlf Uploading is to convert lf into crlf -f/--fail Do not display http errors when the connection fails --ftp-create-dirs If the remote directory does not exist, create the remote directory --ftp-method [multicwd/nocwd/singlecwd] Control the use of cwd --ftp-pasv Use pasv/epsv instead of port --ftp-skip-pasv-ip When using pasv, ignore the ip address --ftp-ssl Try to use ssl/tls for ftp data transmission - -ftp-ssl-reqd Requires ssl/tls for ftp data transmission -f/--form -form-string < ;name=string> Simulate http form submission data -g/--globoff Disable URL sequence and range using {} and [] -g/--get Use get method Send data -h/--help Help -h/--header --ignore-content- length The length of the ignored http header information -i/--include Include protocol header information when output -i/--head Only display document information From the file Read -j/--junk-session-cookiesIgnore session cookies -Interface -krb4 -j/--junk-session-cookies Read the file and ignore the session cookie --interface --krb4 -k/--insecure Allow ssl sites without certificates -k/--config Specify the configuration file Read -l/--list-only List the file names in the ftp directory --limit-rate -- local-port -m/--max-time --max-redirs --max-filesize -m/--manual Display all manual -n/--netrc Read username and password from netrc file --netrc-optional Use .netrc or url to override -n --ntlm Use http ntlm Authentication -n/--no-buffer Disable buffered output -o/--output Write output to this file -o/--remote -name Write output to this file, retaining the file name of the remote file -p/--proxytunnel Use http proxy --proxy-anyauth Select any proxy authentication method --proxy-basic Use basic authentication on the proxy --proxy-digest Use digital authentication on the proxy --proxy-ntlm Use on the proxy ntlm authentication -p/--ftp-port -q/--quote -r/--range --range-file Read (ssl) a random file -r/--remote-time When generating files locally, keep the remote file time --retry --retry-delay --retry-max-time -s/--silent silent mode. Do not output anything -s/--show-error Show errors --socks4 --socks5 --stderr --trace --trace-ascii --trace-time When tracing/detailed output, add a timestamp -t/--upload-file --url -u/--user -u/--proxy-user -v/--verbose -v/--version Display version information -w/--write-out [format]What output is completed -x/--proxy -x/--request < ;command>What command to specify -y/--speed-time The time required to give up the speed limit. The default is 30 -y/--speed-limit Stop transmission speed limit, speed time 'seconds -z/--time-cond Transmission time setting -0/--http1.0 Use http 1.0 -1/--tlsv1 Use tlsv1 (ssl) -2/--sslv2 Use sslv2 (ssl) -3/--sslv3 Used sslv3 (ssl) --3p-quote like -q for the source url for 3rd party transfer --3p-url Use url, Perform third-party transmission --3p-user Use user name and password to perform third-party transmission -4/--ipv4 Use ip4 -6/--ipv6 Use ip6 -#/--progress-bar Display the current transfer status with a progress bar -a/--append When uploading a file, append it to the target file -a/--user-agent - anyauth Can use "any" authentication method -b/--cookie - basic Use http basic authentication -b/--use-ascii Use ascii/text transmission - c/--cookie-jar -c/--continue-at -d/--data HTTP post method to transmit data --data-ascii Post data in ascii method --data-binary
--negotiate Use http authentication --digest Use digital authentication --disable-eprt Disable the use of eprt or lprt --disable-epsv Disable the use of epsv -d/--dump-header --egd- file --tcp-nodelay Use tcp_nodelay option -e/--referer source URL -e/--cert --cert-type --key --key-type --pass --engine --cacert --capath --ciphers --compressed Request to return Is the compression situation (using deflate or gzip) --connect-timeout --create-dirs Establish the directory hierarchy of the local directory will will need should be will be required. | , create a remote directory --ftp-method [multicwd/nocwd/singlecwd] Control the use of cwd --ftp-pasv Use pasv/epsv instead of port - -ftp-skip-pasv-ip When using pasv, ignore the ip address --ftp-ssl Try to use ssl/tls for ftp data transmission --ftp-ssl- reqd requires the use of ssl/tls for ftp data transmission -f/--form -form-string -g/--globoff Disable URL sequences and ranges using {} and [] -g/--get Send data in the get method -h/--help Help -h/--header --ignore-content-length Ignored http header The length of the information -i/--include Include protocol header information when output -i/--head Only display document information Read from the file-j /--junk-session-cookiesIgnore session cookies -Interface -krb4 -j/--junk-session-cookies Read the file and ignore the session cookie --interface --krb4 -k/--insecure Allow SSL sites without certificates -k/--config Read the specified configuration file -l/--list-only List the file names in the ftp directory --limit-rate --local-port -m/--max-time --max-redirs --max-filesize --ntlm Use http ntlm authentication -n/-- no-buffer Disable buffered output -o/--output Write the output to this file -o/--remote-name Write the output to this file and keep the remote file Filename -p/--proxytunnel Use http proxy --proxy-anyauth Choose any proxy authentication method --proxy-basic On the proxy Use basic authentication --proxy-digest Use digital authentication on the proxy --proxy-ntlm Use ntlm authentication on the proxy -p/- -ftp-port -q/--quote -r/- -range --range-file Read (ssl) a random file -r/--remote-time When generating files locally, keep the remote file time --retry --retry-delay --retry-max-time -s/--silent silent mode. Do not output anything -s/--show-error Show errors --socks4 --socks5 --stderr -t/--telnet-option < ;opt=val> telnet option setting --trace --trace-ascii --trace-time When tracing/detailed output, add a timestamp -t/--upload-file --url < url> spet url to work with -u/--user -u/--proxy-user < user[:password]>Set proxy username and password -v/--verbose -v/--version Display version information -w/-- write-out [format]What output is completed -x/--proxy -x/- -request -y/--speed-time The time required to give up the speed limit. The default is 30 -y/--speed-limit Stop transmission speed limit, speed time 'seconds -z/--time-cond Transmission time setting -0/--http1.0 Use http 1.0 -1/--tlsv1 Use tlsv1 (ssl) -2/--sslv2 Use sslv2 (ssl) -3/--sslv3 Used sslv3 (ssl) --3p-quote like -q for the source url for 3rd party transfer --3p-url Use url, Perform third-party transmission --3p-user Use user name and password to perform third-party transmission -4/--ipv4 Use ip4 -6/--ipv6 Use ip6 -#/--progress-bar Use the progress bar to display the current transmission status 2. Commonly used curl examples 1. Grab the page content into a file中 [root@krlcgcms01 mytest]# curl -o home.html [root@krlcgcms01 mytest]# curl -o home.html 2, use -o (in capital letters), the following url must be specific to a certain file, otherwise it will not be captured. We can also use regular expressions to grab things [root@krlcgcms01 mytest]# curl -o [root@krlcgcms01 mytest]# curl -o 3. Simulation Form information, simulate login, save cookie information [root@krlcgcms01 mytest]# curl -c ./cookie_c.txt -f log=aaaa -f pwd=****** [root@krlcgcms01 mytest]# curl -c ./cookie_c.txt -f log=aaaa -f pwd=****** 4. Simulate form information, simulate login, save header information [root@krlcgcms01 mytest]# curl -d ./cookie_d.txt -f log=aaaa -f pwd=****** [root@krlcgcms01 mytest]# curl - d ./cookie_d.txt -f log=aaaa -f pwd=****** The cookie generated by -c (lowercase) is different from the cookie in -d. 5. Use cookie files [root@krlcgcms01 mytest]# curl -b ./cookie_c.txt [root@krlcgcms01 mytest]# curl -b ./ cookie_c.txt 6. Resume the transfer, -c (capital) [root@krlcgcms01 mytest]# curl -c -o 7. Transfer data , it is best to use the login page to test, because after you pass the value, curl will capture the data, and you can see whether the value you passed is successful [root@krlcgcms01 mytest]# curl -d log=aaaa [root@krlcgcms01 mytest]# curl -d log=aaaa 8, display the crawl error, the following example clearly shows it. [root@krlcgcms01 mytest]# curl -f curl: (22) the requested url returned error: 404 [root@krlcgcms01 mytest]# curl . . . . . . . . . . . . [root@krlcgcms01 mytest]# curl -f curl: (22) the requested url returned error: 404 [root@krlcgcms01 mytest]# curl ssl password
-t/--telnet-option ssl password
--netrc-optional Use .netrc or url to override -n
. . . . . . . . . . . .
9. Forge the source address. Some websites will judge and request the source address.
[root@krlcgcms01 mytest]# curl -e
[root@krlcgcms01 mytest]# curl -e
10. When we often use curl to mess with other people’s things, People will block your IP. At this time, we can use proxy
[root@krlcgcms01 mytest]# curl -x 24.10.28.84:32779 -o home.html
[root@krlcgcms01 mytest]# curl -x 24.10.28.84:32779 -o home.html
11, for larger things, we can download them in sections
[root@krlcgcms01 mytest]# curl -r 0-100 -o img.part1 -
content/uploads/2010/09/compare_varnish.jpg
% total % received % xferd average speed time time time current
dload upload total spent left speed
100 101 100 101 0 0 105 0 --:--:-- --:--:-- --:--:-- 0
[root@krlcgcms01 mytest]# curl -r 100-200 -o img.part2 -
content/uploads/2010/09/compare_varnish.jpg
% total % received % xferd average speed time time time current
dload upload total spent left speed
100 101 100 101 0 0 57 0 0:00:01 0:00:01 --:--:-- 0
[root@krlcgcms01 mytest]# curl -r 200- -o img.part3 -
content/uploads/2010/09/compare_varnish.jpg
% total % received % xferd average speed time time time current
dload upload total spent left speed
100 104k 100 104k 0 0 52793 0 0:00:02 0:00:02 --:--:-- 88961
[root@krlcgcms01 mytest]# ls |grep part | xargs du -sh
4.0k one.part1
112k three.part3
4.0k two.part2
[root@krlcgcms01 mytest]# curl -r 0-100 -o img.part1 -
content/uploads/2010/09/compare_varnish.jpg
% total % received % xferd average speed time time time current
dload upload total spent left speed
100 101 100 101 0 0 105 0 --:--:-- --:--:-- --:--:-- 0
[root@krlcgcms01 mytest]# curl -r 100-200 -o img.part2 -
content/uploads/2010/09/compare_varnish.jpg
% total % received % xferd average speed time time time current
dload upload total spent left speed
100 101 100 101 0 0 57 0 0:00:01 0:00:01 --:--:-- 0
[root@krlcgcms01 mytest]# curl -r 200- -o img.part3 -
content/uploads/2010/09/compare_varnish.jpg
% total % received % xferd average speed time time time current
dload upload total spent left speed
100 104k 100 104k 0 0 52793 0 0:00:02 0:00:02 --:--:-- 88961
[root@krlcgcms01 mytest]# ls |grep part | xargs du -sh
4.0k one.part1
112k three.part3
4.0k two.part2
用的时候,把他们cat一下就ok了,cat img.part* >img.jpg
12,不会显示下载进度信息
[root@krlcgcms01 mytest]# curl -s -o aaa.jpg
13,显示下载进度条
[root@krlcgcms01 mytest]# curl -# -o
################################# 100.0%###### 14,通过ftp下载文件###### [zhangy@blackghost ~]$ curl -u 用户名:密码 -o###### % total % received % xferd average speed time time time current###### dload upload total spent left speed###### 101 1934 101 1934 0 0 3184 0 --:--:-- --:--:-- --:--:-- 7136###### [zhangy@blackghost ~]$ curl -u 用户名:密码 -o###
% total % received % xferd average speed time time current
dload upload total spent left speed
101 1934 101 1934 0 0 3184 0 --:--:-- -:--:-- --:--:-- 7136
Or use the following method
[zhangy@blackghost ~]$ curl -o ftp://username: Password@ip:port/demo/curtain/bbstudy_files/style.css
[zhangy@blackghost ~]$ curl -o ftp://username:password@ip:port/demo/curtain/bbstudy_files/ style.css
15, upload via ftp
[zhangy@blackghost ~]$ curl -t test.sql ftp://username:password@ip:port/demo/curtain/ bbstudy_files/
[zhangy@blackghost ~]$ curl -t test.sql ftp://username:password@ip:port/demo/curtain/bbstudy_files/
The above is the detailed content of What are the linux curl command parameters and how to use them. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

CentOS installation steps: Download the ISO image and burn bootable media; boot and select the installation source; select the language and keyboard layout; configure the network; partition the hard disk; set the system clock; create the root user; select the software package; start the installation; restart and boot from the hard disk after the installation is completed.

CentOS has been discontinued, alternatives include: 1. Rocky Linux (best compatibility); 2. AlmaLinux (compatible with CentOS); 3. Ubuntu Server (configuration required); 4. Red Hat Enterprise Linux (commercial version, paid license); 5. Oracle Linux (compatible with CentOS and RHEL). When migrating, considerations are: compatibility, availability, support, cost, and community support.

How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

After CentOS is stopped, users can take the following measures to deal with it: Select a compatible distribution: such as AlmaLinux, Rocky Linux, and CentOS Stream. Migrate to commercial distributions: such as Red Hat Enterprise Linux, Oracle Linux. Upgrade to CentOS 9 Stream: Rolling distribution, providing the latest technology. Select other Linux distributions: such as Ubuntu, Debian. Evaluate other options such as containers, virtual machines, or cloud platforms.

Troubleshooting steps for failed Docker image build: Check Dockerfile syntax and dependency version. Check if the build context contains the required source code and dependencies. View the build log for error details. Use the --target option to build a hierarchical phase to identify failure points. Make sure to use the latest version of Docker engine. Build the image with --t [image-name]:debug mode to debug the problem. Check disk space and make sure it is sufficient. Disable SELinux to prevent interference with the build process. Ask community platforms for help, provide Dockerfiles and build log descriptions for more specific suggestions.

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)
