Linux wget Command: Download Files from URLs

wget is a GNU tool for downloading files from URLs such as HTTP, HTTPS, and FTP. It is useful for saving files from a server or resuming interrupted downloads.

What is the wget command?

By default, it saves to the current directory using the remote file name. -O specifies the desired output file, and -c resumes an interrupted download. It also has a recursive download feature, but since it can request many pages, you should first check the scope and site policies.

Basic syntax

wget [options] URL

Installed implementations and options may vary depending on the distribution. Check the manual on your system with man wget.

Examples

Single file download

It saves to the current directory using the file name provided by the server.

wget https://example.com/

Specifying a file name

After confirming the possibility of overwriting an existing file, decide the save path.

wget -O example.html https://example.com/

Resume Interrupted Files

If the server supports range requests, it resumes at the end of the existing file.

wget -c https://example.com/archive.tar.gz

What should we check after downloading?

wget -O saves the received content to the specified filename. Depending on the server and network conditions, the progress or HTTP status messages may be displayed on standard error.

wget -O example.html https://example.com
ls -lh example.html

The second command shows the name and size of the file if it has been created. Size and content may vary each time you request, so don’t expect a fixed byte count.

A download success message alone does not guarantee the authenticity of the file. If it is an official distribution file, separately verify the checksum or signature provided by the provider. If you run it again with the same name, -O can overwrite the existing file, so check the save path first.

Main Options and Format

Options/Format Description
-O file Saves the download result to the specified file.
-P directory Specifies the directory to save to.
-c Resumes interrupted downloads when possible.
-q Reduces progress messages.
--spider Check the possibility of accessing a URL without saving the content.
-r Recursively fetch linked resources.

Precautions when using

-O can overwrite the specified file, so check existing data. When using -c, if the server file has changed, the resumed result can be corrupted, so checksum verification is important. Large-scale -r operations may put a burden on the server, so check permissions and scope.

Frequently Asked Questions

Does using wget -c always safely resume downloads?

No. It depends on whether the server supports range requests and whether the remote file has changed. Verify the checksum of the completed file.

Official Documentation

The exact behavior of the options and differences by implementation can be found in the official wget documentation.

More in This Category
Linux kill Command: Send a Signal to a Process ID

Linux kill Command: Send a Signal to a Process ID

Learn how to send a Signal to a Process ID with the Linux kill command, including practical examples, key options, and important precautions.

Linux groups Command: Show a User's Group Memberships

Linux groups Command: Show a User's Group Memberships

Learn how to show a User's Group Memberships with the Linux groups command, including practical examples, key options, and important precautions.

Linux Tutorial / File System Basics: Paths and Key Directories

Linux Tutorial / File System Basics: Paths and Key Directories

Understand the Linux directory tree, read absolute and relative paths, and learn what common directories such as /home, /etc, and /var are used for.

Linux resolvectl Command: Inspect systemd DNS Resolution

Linux resolvectl Command: Inspect systemd DNS Resolution

Learn how to inspect systemd DNS Resolution with the Linux resolvectl command, including practical examples, key options, and important precautions.

Linux systemctl Command: Manage systemd Services

Linux systemctl Command: Manage systemd Services

Learn how to manage systemd Services with the Linux systemctl command, including practical examples, key options, and important precautions.

Linux cd Command: Change the Current Directory

Linux cd Command: Change the Current Directory

Learn how to use the Linux cd command to move between directories using absolute, relative, home, and previous paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux scp Command: Copy Files over SSH

Linux scp Command: Copy Files over SSH

Learn how to copy Files over SSH with the Linux scp command, including practical examples, key options, and important precautions.

Linux id Command: Show User and Group IDs

Linux id Command: Show User and Group IDs

Learn how to show User and Group IDs with the Linux id command, including practical examples, key options, and important precautions.

Linux gunzip Command: Decompress gzip Files

Linux gunzip Command: Decompress gzip Files

Learn how to decompress gzip Files with the Linux gunzip command, including practical examples, key options, and important precautions.

Linux less Command: Browse and Search Long Text Files

Linux less Command: Browse and Search Long Text Files

Learn how to browse long files with Linux less, move forward and backward, search text, follow growing logs, preserve colors, and exit the pager.