0
0
Linux CLIscripting~5 mins

wget for file downloads in Linux CLI - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes you need to get files from the internet directly to your computer using the command line. wget is a simple tool that helps you download files quickly and easily without opening a browser.
When you want to download a software installer from a website using the terminal.
When you need to save a backup of a webpage or file for offline use.
When you want to download multiple files automatically using a script.
When you have a slow or unstable internet connection and want to resume downloads.
When you want to download files on a remote server without a graphical interface.
Commands
This command downloads the file named sample.txt from the website example.com to your current folder.
Terminal
wget https://example.com/sample.txt
Expected OutputExpected
2024-06-01 12:00:00 URL:https://example.com/sample.txt [1234/1234] -> "sample.txt" [1]
This command downloads the file but saves it locally as newname.txt instead of the original name.
Terminal
wget -O newname.txt https://example.com/sample.txt
Expected OutputExpected
2024-06-01 12:01:00 URL:https://example.com/sample.txt [1234/1234] -> "newname.txt" [1]
-O - Save the downloaded file with a custom name
This command downloads a large file and allows resuming if the download is interrupted.
Terminal
wget -c https://example.com/largefile.zip
Expected OutputExpected
2024-06-01 12:02:00 URL:https://example.com/largefile.zip [104857600/104857600] -> "largefile.zip" [1] Resuming download
-c - Continue an incomplete download
This command downloads the file quietly without showing progress or messages.
Terminal
wget -q https://example.com/sample.txt
Expected OutputExpected
No output (command runs silently)
-q - Quiet mode, no output
Key Concept

If you remember nothing else from wget, remember: it downloads files from the internet directly to your computer using simple commands.

Common Mistakes
Typing the URL incorrectly or missing the https:// part
wget cannot find the file and returns an error because the address is wrong.
Always copy the full and correct URL including the protocol (http:// or https://).
Not using -c flag when resuming a large interrupted download
The download restarts from the beginning instead of continuing where it left off.
Use wget -c to continue incomplete downloads and save time.
Expecting wget to show progress when using -q flag
No output appears, so it seems like nothing is happening.
Use -q only when you want no messages; otherwise omit it to see progress.
Summary
Use wget followed by a URL to download files from the internet.
Use -O to save the file with a different name.
Use -c to resume interrupted downloads.
Use -q to download quietly without showing progress.