≡ Menu

How to download files on the command line in Linux?

The question is – how to download files using the command line or SSH sessions in Linux?

There are two main commands that can be used to download files on the command line. One is curl and the other is wget. I tend to use wget often as it automatically saves the file on the disk instead of curl which displays the file on the command line window.

The usage of both commands is the same:

wget http://www.google.com

curl http://www.google.com > index.html

Both will download index.html from google.com. However, for curl, you need to save the output to a file by using the > operator.

Both of these commands can also be used to download large files from the web.

For example, you might be interested in downloading the latest Alexa top million from Alexa.org.

You can do this using the following command:

wget http://s3.amazonaws.com/alexa-static/top-1m.csv.zip

The above wget command will download the file top-1m.csv.zip and save it to disk. You can then unzip it or use it in any way you desire.

How to install wget or curl?

It is quite easy to install wget or curl.

On Fedora/CentOS:

sudo yum install wget

sudo yum install curl

On Debian/Ubuntu:

sudo apt-get install wget

sudo apt-get install curl

Note that you need root access to install packages. So you should login as root or use sudo to install the wget and curl packages.

Comments on this entry are closed.