search
HomeOperation and MaintenanceLinux Operation and MaintenanceWhat 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 Settings User agent sent to the server

 -anyauth Can use "any" authentication method

 -b/--cookie cookie string or file reading location

 -basic Use http basic authentication

 -b/--use-ascii Use ascii/text transmission

 -c/--cookie-jar Operation completed Then write the cookie to this file

 -c/--continue-at Continue at breakpoint

 -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 Write header information to the file

 --egd-file Set egd for random data (ssl) socket path

 --tcp-nodelay Use tcp_nodelay option

 -e/--referer source URL

 -e/--cert

  --cert-type Certificate file type (der/pem/eng) (ssl)

  --key

--key-type Private key file type (der/pem/eng) (ssl)

--pass Private key password (ssl)

 --engine Encryption engine use (ssl). "--engine list" for list

 --cacert ca certificate ( ssl)

  --capath ca directory (made using c_rehash) to verify peer against (ssl)

  --ciphers ssl password

--compressed Requires the returned state to be compressed (using deflate or gzip)

  --connect-timeout Sets the maximum request time

  --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 Simulates http form submission data

 -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 Custom header information is passed to the server

 --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

 -InterfaceSpecify network interface/address to use

 -krb4 Enable and specify Security level krb4

 -j/--junk-session-cookies Read the file and ignore the session cookie

 --interface Use the specified network interface/address

 --krb4 Use krb4 with the specified security level

 -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 Set the transfer speed

 -- local-port Force the use of local port number

 -m/--max-time Set the maximum transmission time

 --max-redirs Set the maximum Number of directories read

 --max-filesize Set the maximum total number of downloaded files

 -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

Use port address instead of using pasv

 -q/--quote Send before file transfer Command to server

 -r/--range Retrieve byte range from http/1.1 or ftp server

 --range-file Read (ssl) a random file

  -r/--remote-time When generating files locally, keep the remote file time

  --retry When there is a problem with the transmission, the number of retries

 --retry-delay When there is a problem with the transmission, set the retry interval

 --retry-max-time When there is a problem with the transmission, set the maximum retry time

 -s/--silent silent mode. Do not output anything

 -s/--show-error Show errors

 --socks4 Use socks4 to proxy the given host and port

 --socks5 Use socks5 to proxy the given host and port

 --stderr
-t/--telnet-option telnet option setting

 --trace Debug the specified file

 --trace-ascii like --trace but no hex output

 --trace-time When tracing/detailed output, add a timestamp

 -t/--upload-file Upload file

 --url spet url to work with

 -u/--user Set the server user and password

 -u/--proxy-user Set proxy username and password

 -v/--verbose

 -v/--version Display version information

 -w/--write-out [format]What output is completed

 -x/--proxy Use http proxy on the given port

 -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 Set the user agent sent to the server

 - anyauth Can use "any" authentication method

 -b/--cookie cookie string or file reading position

 - basic Use http basic authentication

 -b/--use-ascii Use ascii/text transmission

 - c/--cookie-jar Write the cookie to this file after the operation is completed

 -c/--continue-at Continue at the breakpoint

-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 Write header information to the file

 --egd- file Set egd socket path for random data (ssl)

 --tcp-nodelay Use tcp_nodelay option

 -e/--referer source URL

 -e/--cert Client certificate file and password (ssl)

 --cert-type Certificate file type (der/pem/eng) (ssl)

 --key Private key file name (ssl)

  --key-type Private key file type (der/pem/eng) (ssl)

  --pass Private key password (ssl )

 --engine Encryption engine use (ssl). "--engine list" for list

 --cacert ca certificate (ssl)

 --capath ca directory (made using c_rehash) to verify peer against (ssl)

 --ciphers ssl password

 --compressed Request to return Is the compression situation (using deflate or gzip)

 --connect-timeout Set the maximum request time

 --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 Simulate http form submission data

 -form-string Simulate http form submission data

 -g/--globoff Disable URL sequences and ranges using {} and []

 -g/--get Send data in the get method

 -h/--help Help

 -h/--header Custom header information is passed to the server

 --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

 -InterfaceSpecify network interface/address to use

 -krb4 Enable with specified security level krb4

 -j/--junk-session-cookies Read the file and ignore the session cookie

 --interface Use the specified network interface/address

 --krb4 Use krb4 with the specified security level

 -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 Set the transmission speed

 --local-port

 -m/--max-time Set the maximum transfer time

 --max-redirs Set the maximum number of directories to be read

 --max-filesize Set the maximum total number of downloaded files

-m/--manual Display all manual

 -n/--netrc From the netrc file Read username and password


 --netrc-optional Use .netrc or url to override -n

 --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

Use port address instead of using pasv

 -q/--quote Send command to server before file transfer

 -r/- -range Retrieve byte range from http/1.1 or ftp server

  --range-file Read (ssl) a random file

 -r/--remote-time When generating files locally, keep the remote file time

 --retry When there is a problem with the transmission, the number of retries

 --retry-delay When there is a problem with the transmission When there is a transmission problem, set the retry interval

 --retry-max-time When there is a problem with the transmission, set the maximum retry time

 -s/--silent silent mode. Do not output anything

 -s/--show-error Show errors

 --socks4 Use socks4 to proxy the given host and port

 --socks5 Use socks5 to proxy the given host and port

 --stderr

 -t/--telnet-option < ;opt=val> telnet option setting

  --trace Debug the specified file

  --trace-ascii like --trace but no hex output

 --trace-time When tracing/detailed output, add a timestamp

 -t/--upload-file Upload file

 --url spet url to work with

 -u/--user Set the server user and password

 -u/--proxy-user Set proxy username and password

 -v/--verbose

 -v/--version Display version information

 -w/-- write-out [format]What output is completed

 -x/--proxy Use http proxy on the given port

 -x/- -request Specify what command

 -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

 

404,not found

 . . . . . . . . . . . .

 [root@krlcgcms01 mytest]# curl -f

 curl: (22) the requested url returned error: 404

 [root@krlcgcms01 mytest]# curl

 

404,not found

 . . . . . . . . . . . .

 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!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
What is Maintenance Mode in Linux? ExplainedWhat is Maintenance Mode in Linux? ExplainedApr 22, 2025 am 12:06 AM

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

Linux: A Deep Dive into Its Fundamental PartsLinux: A Deep Dive into Its Fundamental PartsApr 21, 2025 am 12:03 AM

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

Linux Architecture: Unveiling the 5 Basic ComponentsLinux Architecture: Unveiling the 5 Basic ComponentsApr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux Operations: Utilizing the Maintenance ModeLinux Operations: Utilizing the Maintenance ModeApr 19, 2025 am 12:08 AM

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

Linux: How to Enter Recovery Mode (and Maintenance)Linux: How to Enter Recovery Mode (and Maintenance)Apr 18, 2025 am 12:05 AM

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

Linux's Essential Components: Explained for BeginnersLinux's Essential Components: Explained for BeginnersApr 17, 2025 am 12:08 AM

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

Linux: A Look at Its Fundamental StructureLinux: A Look at Its Fundamental StructureApr 16, 2025 am 12:01 AM

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

Linux Operations: System Administration and MaintenanceLinux Operations: System Administration and MaintenanceApr 15, 2025 am 12:10 AM

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.