Low Orbit Flux Logo 2 F

Linux How To Download File From URL

If you are reading this you probably want to learn how to download files from a URL using Linux. We are going to go ahead and assume that you want to do this from the command line and not from a browser because otherwise you probably wouldn’t be searching for this. The good news is that this is very easy.

Quick Answer - Example, just do this:


wget https://wordpress.org/latest.zip

You can download a file from a URL from the Linux command line using one of these tools:

These aren’t the only tools that you can use but they are two of the most common.

You can download a file with wget like this:


wget http://example.com/data.tar.gz

You can also specify the filename that you want to save the file to on your system:


wget http://example.com/data.tar.gz -O mydatafile.tar.gz
wget http://example.com/data.tar.gz -O /home/user1/data.tar.gz

You can download using curl too but by default it just outputs to stdout ( right on your screen ). This is great for an HTML file but not for a gzipped archive.


curl https://wordpress.org/

You can tell curl to download to a file instead like this. Note that we are using a lowercase ‘o’.


curl https://wordpress.org/ -o tst

If you are downloading a binary file, you will need to specify either the “o” or “O” option because outputing binary data to the terminal would cause issues ( it fails with a warning message ).

This will download the file using the default file name:


curl https://wordpress.org/latest.zip -O

This will download the file using a filename that you specify:


curl https://wordpress.org/latest.zip -o test.zip
 

Install Curl and Wget on Ubuntu

You should probably have both of these commands installed already but if you don’t for whatever reason you can just install them like this.

Install curl:


sudo apt update
sudo apt install curl

Install wget:


sudo apt update
apt install wget