🌐 Commands: curl & wget (Web Downloaders)
Both curl and wget are used to retrieve data from web servers. While they overlap, they have different "philosophies": wget is a specialist at downloading files, while curl is a multi-tool for interacting with almost any protocol.
1. wget (The Specialist)
wget is designed for downloading files and entire directories. It is robust and can resume downloads if the connection drops.
- Best for: Downloading ISOs, large archives, or "mirroring" a whole website.
- Key Feature: It is non-interactive; it can run in the background while you do other things.
Practical Examples:
- Download a single file:
wget [https://example.com/file.zip](https://example.com/file.zip) - Download and rename:
wget -O my_paper.pdf [https://uni.edu/research_paper_123.pdf](https://uni.edu/research_paper_123.pdf) - Resume a broken download:
wget -c [https://example.com/large_file.iso](https://example.com/large_file.iso) - Mirror a full site (recursive):
wget -r -np [https://example.com/docs/](https://example.com/docs/)
2. curl (The Multi-Tool)
curl (Client URL) is used to transfer data to or from a server. It supports a massive range of protocols (HTTP, FTP, SCP, LDAP, etc.) and is a favorite for developers.
- Best for: Testing APIs, sending headers, and scripted web interactions.
- Key Feature: By default, it outputs the data to your terminal (stdout) rather than saving it to a file.
Practical Examples:
- Fetch a page and see the code:
curl [https://google.com](https://google.com) - Download and save to a file:
curl -o local_name.html [https://example.com](https://example.com) - Check HTTP headers (Great for debugging):
curl -I [https://yoursite.com](https://yoursite.com) - Send data to an API (like Supabase):
curl -X POST [https://api.supabase.com/v1/](https://api.supabase.com/v1/)... -d "name=Ahmed"
3. Comparison at a Glance
| Feature | wget |
curl |
|---|---|---|
| Primary Use | Downloading files. | Interacting with URLs/APIs. |
| Recursive (Mirroring) | Yes (-r). |
No. |
| Protocol Support | HTTP, HTTPS, FTP. | Almost everything (70+ protocols). |
| Standard Output | Saves to file by default. | Prints to terminal by default. |
| Resuming | Simple (-c). |
Possible, but more complex. |
4. Pro-Tips for Your Workflow
- API Testing: If you are debugging your documentation viewer's backend, use
curl -v(verbose). It will show you the entire handshake, headers, and any errors the server sends back. - Quick Public IP Check: As someone navigating Algerian networking, you can quickly find your public-facing IP using:
curl ifconfig.me - Batch Downloading: If you have a text file containing 100 links for your Quantum Computing research, you can download them all at once:
wget -i links.txt - Arch Linux Context: You'll see
curlused constantly in the install scripts for things like Oh My Zsh or Homebrew, whereaswgetis the hero when you need to pull down a specific.tar.gzfrom the AUR manually.
5. Summary Reference
| Goal | Command |
|---|---|
| Download a file (simple) | wget [URL] |
| Download and save as | curl -o [name] [URL] |
| Resume download | wget -c [URL] |
| Test an API endpoint | curl -X GET [URL] |
| Mirror a directory | wget -r [URL] |