Linux/Unix: Web Tools β wget, curl, lynx Explained with Practical Examples
Introduction β Why Learn Web Tools in Linux?
Linux provides powerful CLI tools to access, download, and interact with web resources directly from the terminal. Whether you’re fetching files, making HTTP requests, or browsing the web in a terminal, tools like wget, curl, and lynx are essential for developers, sysadmins, and automation scripts.
In this guide, youβll learn:
- How to download files using
wget - How to make web requests and APIs with
curl - How to browse the web from the terminal using
lynx - Real-world examples and outputs for each tool
1. wget β Non-Interactive File Downloader
What is wget?
wget is a command-line utility to download files from the web using HTTP, HTTPS, or FTP protocols.
Syntax:
wget [options] URL
Common Options:
| Option | Description |
|---|---|
-c | Resume partially downloaded file |
-O | Save with a custom filename |
-r | Recursive download |
--limit-rate | Limit download speed |
Example 1: Download a file
wget https://example.com/file.zip
Example 2: Resume a broken download
wget -c https://example.com/large.iso
Example 3: Save with a custom name
wget -O latest.html https://example.com
Output:
Saving to: βlatest.htmlβ
HTTP request sent, awaiting response... 200 OK
2. curl β Transfer Data from or to a Server
What is curl?
curl is a command-line tool to send requests and receive responses from URLs. It supports HTTP, FTP, SFTP, and more.
Syntax:
curl [options] [URL]
Common Options:
| Option | Description |
|---|---|
-o | Save to file |
-I | Fetch headers only |
-d | Send data in POST requests |
-X | Specify HTTP method (GET, POST, etc) |
-H | Add custom header |
Example 1: Download a webpage
curl https://example.com
Example 2: Save output to file
curl -o page.html https://example.com
Example 3: Send POST data to an API
curl -X POST -d "name=Vaibhav&age=25" https://httpbin.org/post
Output (JSON):
{
"form": {
"age": "25",
"name": "Vaibhav"
}
}
3. lynx β Terminal-Based Web Browser
What is lynx?
lynx is a text-based web browser that lets you navigate websites right from the terminal.
Syntax:
lynx [options] [URL]
Install it using:
sudo apt install lynx
Example 1: Open a website in the terminal
lynx https://example.com
Output: A keyboard-navigable text UI of the webpage.
Navigation Keys:
- β / β: Move through links
- β: Follow a link
q: Quitg: Enter a new URL
Web Tools Comparison Table
| Tool | Main Use | Supports | GUI Needed | Best For |
|---|---|---|---|---|
wget | File downloads | HTTP/FTP | Automated bulk or scheduled pulls | |
curl | API calls & data transfers | HTTP/FTP/SMTP | Web APIs, headers, scripting | |
lynx | Text-based web browsing | HTTP/HTTPS | Browsing in terminal or SSH-only |
Summary β Recap & Next Steps
These web tools make Linux a powerful platform for interacting with the internetβwhether you’re downloading, debugging APIs, or browsing sites in restricted environments.
Key Takeaways:
- Use
wgetfor robust downloading and automation. - Use
curlfor web requests, APIs, and data posting. - Use
lynxto browse websites in a terminal-only environment.
FAQs
Whatβs the difference between wget and curl?
wget is best for downloading entire files or sites. curl is more flexible for sending/receiving custom HTTP requests.
Can wget handle recursive downloads?
Yes, use wget -r URL for entire websites (respect robots.txt).
How can I view only HTTP headers with curl?
Use:
curl -I https://example.com
Is lynx useful without a GUI?
Absolutely. It lets you browse web content in SSH or headless environments.
Can I download an entire site with wget?
Yes:
wget -r -np -k https://example.com
Share Now :
