curl and wget
The web from the terminal.
You don't need a browser to talk to websites. From the terminal, curl and W get can fetch any web page, or download any file. They're essential on servers, where there's no browser at all.

- No browser needed
- Fetch pages, download files
- Essential on servers
Curl prints a page
Curl fetches a web address, and prints what comes back. For a web page, that's the HTML code. It's long, so here we pipe it into grep, to pick out just the title. Example domain.
curl -s https://example.com | grep -o "<title>.*</title>" <title>Example Domain</title>
W get saves a file
W get is made for downloading. It saves what it fetches straight into a file. Dash Q keeps it quiet, and dash capital O picks the file name. LS dash L shows the downloaded page. Curl can save files too, with dash O.
wget -q https://example.com -O page.html ls -l page.html -rw-r--r-- 1 sam sam 577 Jan 5 09:00 page.html
Curl for APIs
Curl is also how developers test web APIs. Dash capital I shows just the response headers, including the status code, like two hundred for OK. Dash capital X picks the method, like post. And dash H adds headers. If you work with web apps, you'll use curl every day.
| key | value |
|---|---|
| curl URL | print the response |
| curl -I URL | headers only |
| curl -o file URL | save to a file |
| wget URL | download a file |
Summary
Curl prints what a web address returns, and W get downloads files. Both work great on servers. Next, SSH, logging in to other computers.
Key takeaways- curl -s URL
- wget -O file URL
- curl -I for headers