How to Download a Single File Using Wget in Ubuntu
This article provides a step-by-step guide on downloading a single file using the wget command in the Ubuntu terminal. It covers the basic syntax, how to specify custom filenames, and essential tips for verifying your download without relying on a graphical web browser.
Prerequisites
Ensure that wget is installed on your system. Most
Ubuntu installations include it by default. To verify, open your
terminal and run:
wget --versionIf the command is not found, install it using the Apt package manager:
sudo apt update
sudo apt install wgetBasic Download Command
To download a file, type wget followed by the direct URL
of the file. Press Enter to start the download.
wget https://example.com/path/to/file.zipThe file will be saved in your current directory with its original name. You will see a progress bar in the terminal indicating the download status.
Saving a File with a Different Name
If you want to save the file with a specific name instead of the
default, use the -O flag followed by the desired
filename.
wget -O my-archive.zip https://example.com/path/to/file.zipThis command downloads the content from the URL but saves it locally
as my-archive.zip.
Verifying the Download
Once the process completes, confirm the file exists in your directory
using the ls command.
ls -lhYou can also check the file type to ensure it downloaded correctly and is not an HTML error page.
file file.zipUsing wget allows for efficient downloading directly
from the command line, making it ideal for servers or automated scripts
in Ubuntu.