
The -upload-file (or -T) option allows you to upload a local file to a remote server. netrc config files, allowing you to define various curl options in a file and then to include the file in your command with curl -config (or curl -K), which is particularly useful for scripting. If, for some reason, you have to use an unencrypted protocol, make sure you use an authentication method that doesn’t transmit credentials in clear text (for instance, Digest, NTLM, or Negotiate authentication).Ĭurl also supports the use of. If you use a basic authentication method, you have to transfer a username and password, which means that you should use a secure protocol such as HTTPS (instead of HTTP) or FTPS (instead of FTP). All three of these options can be combined in short-notation, as shown in the following command: curl -kIL ĭownloading a file using username and password authentication with curl You can also use -insecure (or -k) to allow insecure connections to avoid any TLS certificate errors if the target URL is using a self-signed certificate. In that case, -location (or -L) allows the curl to follow the redirects.

Sometimes, a URL might redirect you to another location. This can be done using the -head (or -I) option.

Get remote file information.Īs an admin, you might want to be interested in HTTP headers only. Notice that the methods that are available depend on the protocol being used. To use these methods, along with the curl command, use the -request (or -X) option, followed by the method. It also supports other methods, such as HEAD, POST, PUT, and DELETE.

To specify the HTTP protocol version (e.g., http/2), use the -http2 option, as shown below: curl -http2 įor URLs starting with HTTPS, curl first tries to negotiate to establish a http/2 connection and automatically falls back to http/1.1 if the negotiation fails. The above command is essentially equivalent to curl -request GET, which sends a GET request to using the HTTPS protocol.

When you use curl against a URL without specifying any option, the request defaults to the GET method of the HTTP protocol. Now that you’ve become familiar with curl syntax, let’s discuss various use cases with the help of examples. The help section is divided into categories, so the curl -help category gets you an overview of all the categories. To get detailed help, you can use curl -help all.
