curl command cheat sheet

In this tutorial, I have compiled a comprehensive curl command cheat sheet. Curl is a powerful command-line tool for making HTTP requests and working with various protocols. The cheat sheet is designed to serve as a quick reference guide, providing concise and organized information on the essential curl commands. Whether you're a beginner or an experienced user, this resource aims to simplify the usage of curl commands, helping you navigate and leverage its capabilities efficiently. Feel free to explore the cheat sheet and enhance your proficiency in utilizing curl for various web-related tasks.

curl command cheat sheet

Option

-o <file>       # --output: write to file
-u user:pass  # --user: Authentication
-v                  # --verbose
-s                  # --silent
-I                  # --head: headers only
-i                  # --include: Include the HTTP-header in the output
Request

-X POST          # --request
-L                     # follow link if page redirects
-F                     # --form: HTTP POST data for multipart/form-data
Headers
-A <str>            # --user-agent
-b name=val      # --cookie
-b FILE             # --cookie
-H "X-Foo: y"    # --header
--compressed     # use deflate/gzip
Data
-d 'data'      # --data: HTTP post data, URL encoded (eg, status="Hello")
-d @file     # --data via file
-G              # --get: send -d data via get
SSL
-E, --cert <cert>     # --cert: Client cert file
    --cert-type          # der/pem/eng
-k, --insecure          # for self-signed certs

Curl command examples

curl Get/Head

#Curl head request
curl -I https://www.google.com
#Curl head request with verbose
curl -v -I https://www.google.com
#Curl get response with headers
curl -k -v https://www.google.com
CURL command POST
#Curl post request
curl -d "name=username&password=1111111111" <URL>
#Curl post send json
curl <URL> -H "content-type: application/json" -d "{ \"woof\": \"bark\"}"


CURL command ADVANCED 

#Get my public ip
curl -L -s http://whatismijnip.nl
curl -L -s http://ipecho.net/plain
#Curl upload
curl -v -F key1=value1 -F upload=@localfilename <URL>
#Curl with http2
curl -k -v --http2 https://www.google.com/
#Curl ftp upload
curl -T file.zip -u test:test ftp://10.10.1.23/
#Curl ftp download
curl -u test:test ftp://10.10.1.23/file.zip -o file.zip

Conclusion

The provided resources, including the "curl command cheat sheet" and the examples demonstrating "Curl command POST" and "Curl command ADVANCED," offer valuable insights into harnessing the capabilities of the curl command-line tool. The cheat sheet serves as a handy reference guide, condensing essential information for quick and efficient usage. The diverse examples showcase the versatility of curl, from basic GET requests to advanced scenarios like POST requests and customization options. Whether you're a beginner seeking fundamental understanding or an advanced user exploring intricate functionalities, these resources collectively empower you to navigate and leverage curl effectively in various web-related tasks.

Comments

Popular posts from this blog

zimbra some services are not running [Solve problem]

Bash script list all IP addresses connected to Server

How to install php7 on centos 6