How to Download Files from Network in Linux

The wget command in Linux is a powerful utility for downloading files from the internet via HTTP, HTTPS, and FTP protocols. It is often used for automated downloads, mirroring websites, and handling large files.

Alby Andersen

The wget command in Linux is a powerful tool for downloading files from the web. It supports HTTP, HTTPS, and FTP protocols and offers features like recursive downloads, resuming interrupted downloads, and background downloads. Below are practical examples to master wget:


Download a Single File

wget https://example.com/file.zip  


Downloads file.zip from the specified URL.


Download and Save with a Different Name

wget -O custom_name.zip https://example.com/file.zip  
  • -O: Saves the file as custom_name.zip.

Download in the Background

wget -b https://example.com/large_file.iso  
  • -b: Runs the download in the background.

Resume an Interrupted Download

wget -c https://example.com/large_file.iso  
  • -c: Continues downloading a partially downloaded file.

Download Multiple Files

wget https://example.com/file1.zip https://example.com/file2.zip  


Downloads multiple files in sequence.


Download Files from a List

wget -i file_list.txt  
  • -i: Reads URLs from file_list.txt and downloads them.

Limit Download Speed

wget --limit-rate=200k https://example.com/large_file.iso  
  • --limit-rate=200k: Limits the download speed to 200 KB/s.

Download an Entire Website (Mirror)

wget --mirror --convert-links https://example.com  
  • --mirror: Recursively downloads the entire website.
  • --convert-links: Converts links for local viewing.

Download Files via FTP

wget ftp://example.com/file.zip  


Downloads file.zip from an FTP server.


Download with Authentication

wget --user=username --password=password https://example.com/file.zip  
  • --user and --password: Authenticate with the server.

Retry Failed Downloads

wget --tries=5 https://example.com/file.zip  
  • --tries=5: Retries the download up to 5 times.

Set a Custom User-Agent

wget --user-agent="Mozilla/5.0" https://example.com/file.zip  
  • --user-agent: Mimics a browser user-agent.

Download Files Matching a Pattern

wget -r -A "*.jpg" https://example.com/images/  
  • -r: Recursively downloads.
  • -A "*.jpg": Downloads only .jpg files.

Exclude Specific File Types

wget -r -R "*.mp4" https://example.com/media/  
  • -R "*.mp4": Excludes .mp4 files from the download.

Download with a Timeout

wget --timeout=10 https://example.com/file.zip  
  • --timeout=10: Sets a 10-second timeout for the connection.

Key Notes:

  • Resume Downloads: Always use -c for large files to avoid restarting from scratch.
  • Recursive Downloads: Use -r or --mirror for downloading entire directories or websites.
  • Permissions: Ensure you have permission to download files from the target server.
Share This Article