How to use curl and wget in Linux
· Category: Linux
Short answer
curl and wget are command-line HTTP clients. curl is versatile for APIs; wget excels at recursive downloads.
Steps
- Download with wget:
wget https://example.com/file.zip
- Download with curl:
curl -O https://example.com/file.zip
- POST JSON with curl:
curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' https://api.example.com
- Follow redirects:
curl -L https://example.com
Tips
curl -Ifetches headers only.wget -renables recursive downloading.- Use
-owith curl to specify an output filename.
Common issues
- SSL errors: use
-kto skip verification (insecure) or update CA certificates. - Large files: use
-C -with curl to resume interrupted downloads.