When it comes to downloading files from the internet, we usually imagine pressing the download button. However, you can also download files directly from your terminal. Wget and Curl are two of the popular tools that let you do that.
In this tutorial we will look at these two and see how the two differ.
Installation of wget and curl commands
If you don’t have wget or curl on your system you can download by following the steps given below.
Steps to install curl on different distros
To install Curl on your system use the following command :
#Debian and Ubuntu Systems sudo apt install curl #Red hat, CentOS, Fedora sudo rpm install curl sudo yum install curl sudo dnf install curl #Arch Linux sudo pacman -S curl
Steps to install wget on different distros
To install Wget on your system use the command :
#Debian and Ubuntu Systems sudo apt install wget #Red hat, CentOS, Fedora sudo rpm install wget sudo yum install wget sudo dnf install wget #Arch Linux-based distros: sudo pacman -S wget
Difference between curl and wget
Let’s see how the outputs of two commands differ when we use them.
Accessing a website with curl
To see what the output of curl command looks like, try running curl on a few websites.
We can see that curl displays data from the website on the terminal itself. We can also save the output to a file.
To save the output to a file use the following command :
curl linuxfordevices.com > [filename]
The output is different from the one above. To view the file where the output is saved use cat command.
Alternatively you can also use the following command to store the output in a file.
curl -o [filename] [url]
Accessing a website with wget
To see what the output of wget command looks like, try running wget on a few websites.
We can see that Wget stores the output in a file by default. It also shows a progress bar in the output.
Wget command will simply download a file based on the file name that’s provided by the server. Alternatively, you can set a filename by using the -0 flag.
wget [URL] -0 [filename]
You can use the cat command to display the file.
Similarities between wget and curl
- Both Wget and Curl can download files off the internet.
- Both Curl and Wget support HTTP and its secure version, HTTPS.
- Both are command-line tools.
- Both support HTTP cookies.
- Both are capable of making HTTP post requests.
- Both are completely open-source and free software.
You might be wondering then what’s the difference between the two. Let’s look at the difference next.
Differences between wget and curl
|Wget is a simple tool designed to perform quick downloads||Curl on the other hand is a much more powerful tool. It can achieve a lot more as compared to Wget.|
|Wget is command line only||Curl is powered by libcurl|
|Wget supports only HTTP, HTTPS, and FTP protocols||Curl supports a lot more protocols, these are DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, Telnet and TFTP|
|Wget offers the ability to download recursively||It’s difficult to achieve recursive access to a web resource with curl|
|wget is more focused on Linux-based distros||Curl is available on multiple platforms with many web utilities leveraging curl to interact with the web|
This tutorial was about the difference between wget and curl. If you want a tool to just download files over the internet, you should use Wget. If you want some features apart from just downloading then you should go for curl.