How to Download a File to Disk on Ubuntu
Table of Contents
This article describes how to download a file and save it to disk on your Ubuntu machine using a command line terminal.
wget command saves to file on disk by default, whereas
curl displays the file on screen by default. However, both programs can both display on screen and save to disk.
Step 1. Open a Terminal Session
If you're using an Ubuntu laptop or desktop, you can press
Ctrl + Alt + T on your keyboard to open a new terminal window. If you're using a remote Ubuntu server, you can connect using SSH to open a new terminal session.
Ubuntu usually comes with both
curl pre-installed, so you can try Step 3 first and come back to this step only if you see an error message like
Command 'curl' not found.
If your Ubuntu machine does not already have
wget, you can install it using the following command:
Similarly, if your Ubuntu machine does not already have
curl, you can install it using the following command:
To save the file located at URL
https://example.com/index.html, we can run:
wget saves the file in the current directory using the same filename specified in the URL (in our example,
If we want to save it as a different filename, we can use the
-O option (an uppercase letter "O" for "Output"). For example, if we want to save the file at URL
example1.html in our current directory, we can run:
Alternatively, we can use the
curl program to download a file to disk. By default, if we run
curl https://example.com/index.html, it prints the contents to standard output (stdout). Because standard output in a terminal session is just the terminal window, we'll see the contents show up in the terminal window.
To save the contents to a file on disk using
curl, we need to use the
-o option (a lowercase letter "o" for "output"). For example, to save the contents of
https://example.com/index.html to a file called
example2.html in the current directory, we can run: