View, download, and upload files to a remote system using the CURL command in Linux

Home > Search > Linux commands

Curl is a program which allows you to view the contents of a file on a remote PC, to GET a file from a remote PC, or to POST a file to a remote PC. For example, the curl command without any option followed by a URL will display the contents of the target file. For example, the following will GET the contents of the index.html file.

~]# curl http://www.example/index.html
    Hello World


Redirection can be used to transfer the contents of the target file to a file on the local PC. For example, to transfer the contents of the index.html file to local.file.

~]# curl http://www.example/index.html > local.file


Similarly, the -o option followed by the target file and then the URL will transfer the target file to the local PC.

curl -o index.html http://www.example/



The -X or --request option can be used to specify the type of request you want to use, such as GET, POST, PUT, or DELETE. In this example, a request is submitted to the web server with ID 12345 and a delete request. The web server or application logic needs to be setup to understand how to process this type of request.

~]# curl -X DELETE http://www.example/id=12345



If the resource requires authentication, the --basic and -u options can be used to authenticate.

~]# curl --basic -u 'username:password' http://www.example/secure.html


Public Certificate

The following command can be used to determine the public certificate that was requested from a particular URL.

curl -v -k 2>&1 | grep "Host"


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.