0% found this document useful (0 votes)
5 views

Curl Commands

Uploaded by

hrithikrajnk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Curl Commands

Uploaded by

hrithikrajnk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

### Basic Commands

1. Fetch a URL and Display the Response Body:

```bash

curl http://example.com

```

2. Fetch a URL and Display the Response Headers Only:

```bash

curl -I http://example.com

```

3. Fetch a URL and Save the Response to a File:

```bash

curl -o filename.html http://example.com

```

4. Fetch a URL and Save the Response to a File with Automatic Filename:

```bash

curl -O http://example.com/file.zip

```

5. Follow Redirects:

```bash

curl -L http://example.com

```
### Authentication

6. Basic Authentication:

```bash

curl -u username:password http://example.com

```

7. Bearer Token Authentication:

```bash

curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" http://example.com

```

### Custom Headers

8. Send a Custom Header:

```bash

curl -H "X-Custom-Header: value" http://example.com

```

### Data Submission

9. Send Data with POST Method:

```bash

curl -d "param1=value1&param2=value2" -X POST http://example.com

```

10. Send JSON Data with POST Method:


```bash

curl -H "Content-Type: application/json" -d '{"key1":"value1","key2":"value2"}' http://example.com

```

### File Upload

11. Upload a File:

```bash

curl -F "file=@/path/to/your/file" http://example.com/upload

```

### SSL/TLS

12. Ignore SSL Certificate Warnings:

```bash

curl -k https://example.com

```

13. Use a Specific SSL Certificate:

```bash

curl --cert /path/to/cert.pem https://example.com

```

### Proxy

14. Use a Proxy:

```bash
curl -x http://proxyserver:port http://example.com

```

15. Use a Proxy with Authentication:

```bash

curl -x http://proxyserver:port -U user:password http://example.com

```

### FTP/SFTP

16. Download a File from FTP Server:

```bash

curl -u user:password ftp://ftp.example.com/file.zip -o file.zip

```

17. Upload a File to FTP Server:

```bash

curl -u user:password -T file.zip ftp://ftp.example.com/

```

### Debugging and Verbosity

18. Show Detailed Request and Response:

```bash

curl -v http://example.com

```
19. Show Only the Response Headers:

```bash

curl -I http://example.com

```

20. Show Only the Request Headers:

```bash

curl -v -o /dev/null http://example.com

```

### Rate Limiting

21. Limit the Transfer Rate:

```bash

curl --limit-rate 100K http://example.com

```

### Timeouts

22. Set Connection Timeout:

```bash

curl --connect-timeout 10 http://example.com

```

23. Set Maximum Time for the Entire Operation:

```bash

curl --max-time 30 http://example.com


```

### Miscellaneous

24. Include Response Headers in the Output:

```bash

curl -i http://example.com

```

25. Resume a Download:

```bash

curl -C - -O http://example.com/file.zip

```

26. Download Multiple Files:

```bash

curl -O http://example.com/file1.zip -O http://example.com/file2.zip

```

27. Pass a List of URLs to Download from a File:

```bash

curl -K urls.txt

```

28. Send a DELETE Request:

```bash

curl -X DELETE http://example.com/resource/1


```

29. Send a PUT Request:

```bash

curl -X PUT -d "param1=value1&param2=value2" http://example.com/resource/1

```

You might also like