The Ultimate Wget Download Guide With 15 Awesome Examples

by SathiyaMoorthy on September 28, 2009

15 Practical Examples to Download Images and Videos from Internetwget utility is the best option to download files from internet. wget can pretty much handle all complex download situations including large file downloads, recursive downloads, non-interactive downloads, multiple file downloads etc.,

In this article let us review how to use wget for various download scenarios using 15 awesome wget examples.

1. Download Single File with wget

The following example downloads a single file from internet and stores in the current directory.

$ wget

While downloading it will show a progress bar with the following information:

  • %age of download completion (for e.g. 31% as shown below)
  • Total amount of bytes downloaded so far (for e.g. 1,213,592 bytes as shown below)
  • Current download speed (for e.g. 68.2K/s as shown below)
  • Remaining time to download (for e.g. eta 34 seconds as shown below)

Download in progress:

$ wget
Saving to: `strx25-'

31% [=================> 1,213,592   68.2K/s  eta 34s

Download completed:

$ wget
Saving to: `strx25-'

100%[======================>] 3,852,374   76.8K/s   in 55s    

2009-09-25 11:15:30 (68.7 KB/s) - `strx25-' saved [3852374/3852374]

2. Download and Store With a Different File name Using wget -O

By default wget will pick the filename from the last word after last forward slash, which may not be appropriate always.

Wrong: Following example will download and store the file with name: download_script.php?src_id=7701

$ wget

Even though the downloaded file is in zip format, it will get stored in the file as shown below.

$ ls

Correct: To correct this issue, we can specify the output file name using the -O option as:

$ wget -O

3. Specify Download Speed / Download Rate Using wget –limit-rate

While executing the wget, by default it will try to occupy full possible bandwidth. This might not be acceptable when you are downloading huge files on production servers. So, to avoid that we can limit the download speed using the –limit-rate as shown below.

In the following example, the download speed is limited to 200k

$ wget --limit-rate=200k

4. Continue the Incomplete Download Using wget -c

Restart a download which got stopped in the middle using wget -c option as shown below.

$ wget -c

This is very helpful when you have initiated a very big file download which got interrupted in the middle. Instead of starting the whole download again, you can start the download from where it got interrupted using option -c

Note: If a download is stopped in middle, when you restart the download again without the option -c, wget will append .1 to the filename automatically as a file with the previous name already exist. If a file with .1 already exist, it will download the file with .2 at the end.

5. Download in the Background Using wget -b

For a huge download, put the download in background using wget option -b as shown below.

$ wget -b
Continuing in background, pid 1984.
Output will be written to `wget-log'.

It will initiate the download and gives back the shell prompt to you. You can always check the status of the download using tail -f as shown below.

$ tail -f wget-log
Saving to: `strx25-'

     0K .......... .......... .......... .......... ..........  1% 65.5K 57s
    50K .......... .......... .......... .......... ..........  2% 85.9K 49s
   100K .......... .......... .......... .......... ..........  3% 83.3K 47s
   150K .......... .......... .......... .......... ..........  5% 86.6K 45s
   200K .......... .......... .......... .......... ..........  6% 33.9K 56s
   250K .......... .......... .......... .......... ..........  7%  182M 46s
   300K .......... .......... .......... .......... ..........  9% 57.9K 47s

Also, make sure to review our previous multitail article on how to use tail command effectively to view multiple files.

6. Mask User Agent and Display wget like Browser Using wget –user-agent

Some websites can disallow you to download its page by identifying that the user agent is not a browser. So you can mask the user agent by using –user-agent options and show wget like a browser as shown below.

$ wget --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/2008092416 Firefox/3.0.3" URL-TO-DOWNLOAD

7. Test Download URL Using wget –spider

When you are going to do scheduled download, you should check whether download will happen fine or not at scheduled time. To do so, copy the line exactly from the schedule, and then add –spider option to check.

$ wget --spider DOWNLOAD-URL

If the URL given is correct, it will say

$ wget --spider download-url
Spider mode enabled. Check if remote file exists.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.

This ensures that the downloading will get success at the scheduled time. But when you had give a wrong URL, you will get the following error.

$ wget --spider download-url
Spider mode enabled. Check if remote file exists.
HTTP request sent, awaiting response... 404 Not Found
Remote file does not exist -- broken link!!!

You can use the spider option under following scenarios:

  • Check before scheduling a download.
  • Monitoring whether a website is available or not at certain intervals.
  • Check a list of pages from your bookmark, and find out which pages are still exists.

8. Increase Total Number of Retry Attempts Using wget –tries

If the internet connection has problem, and if the download file is large there is a chance of failures in the download. By default wget retries 20 times to make the download successful.

If needed, you can increase retry attempts using –tries option as shown below.

$ wget --tries=75 DOWNLOAD-URL

9. Download Multiple Files / URLs Using Wget -i

First, store all the download files or URLs in a text file as:

$ cat > download-file-list.txt

Next, give the download-file-list.txt as argument to wget using -i option as shown below.

$ wget -i download-file-list.txt

10. Download a Full Website Using wget –mirror

Following is the command line which you want to execute when you want to download a full website and made available for local viewing.

$ wget --mirror -p --convert-links -P ./LOCAL-DIR WEBSITE-URL
  • –mirror : turn on options suitable for mirroring.
  • -p : download all files that are necessary to properly display a given HTML page.
  • –convert-links : after the download, convert the links in document for local viewing.
  • -P ./LOCAL-DIR : save all the files and directories to the specified directory.

11. Reject Certain File Types while Downloading Using wget –reject

You have found a website which is useful, but don’t want to download the images you can specify the following.

$ wget --reject=gif WEBSITE-TO-BE-DOWNLOADED

12. Log messages to a log file instead of stderr Using wget -o

When you wanted the log to be redirected to a log file instead of the terminal.

$ wget -o download.log DOWNLOAD-URL

13. Quit Downloading When it Exceeds Certain Size Using wget -Q

When you want to stop download when it crosses 5 MB you can use the following wget command line.

$ wget -Q5m -i FILE-WHICH-HAS-URLS

Note: This quota will not get effect when you do a download a single URL. That is irrespective of the quota size everything will get downloaded when you specify a single file. This quota is applicable only for recursive downloads.

14. Download Only Certain File Types Using wget -r -A

You can use this under following situations:

  • Download all images from a website
  • Download all videos from a website
  • Download all PDF files from a website
$ wget -r -A.pdf http://url-to-webpage-with-pdfs/

15. FTP Download With wget

You can use wget to perform FTP download as shown below.

Anonymous FTP download using Wget

$ wget ftp-url

FTP download using wget with username and password authentication.

$ wget --ftp-user=USERNAME --ftp-password=PASSWORD DOWNLOAD-URL

If you liked this article, please bookmark it with delicious or Stumble.

Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 82 comments… read them below or add one }

1 bubblefish September 28, 2009 at 12:54 am

Really nice guide, it’ll sure come handy.
Have fun!

2 kyanh September 28, 2009 at 2:17 am

Thanks for great tips :)

You can use wget to follow HTTP locations as shown here.

3 MihirJ September 28, 2009 at 6:52 am

Awesome … very helpful.

4 runlevel0 September 28, 2009 at 6:58 am

Perfect timing, lol
I was just trying to remember how to use this application to download some documentation.

Thanks !

5 Orlin Vasilev September 28, 2009 at 7:30 am

Quite good :)

6 Jaeho Jang September 28, 2009 at 10:12 pm

very good, thanks.

7 beparas September 28, 2009 at 10:56 pm

Thanks for great information,
But I have one question,
Are we net to set any configure file before using wget ?

8 Ramesh Natarajan September 29, 2009 at 6:24 pm

@bubblefish, kyanh, MihirJ, Orlin, Jaeho,

Thanks a lot for your comments. I’m glad you found this article helpful.


We can read your mind and post articles accordingly. :) Just kidding.


There is no configuration file for wget. Once you’ve installed wget, just start using it using one of the examples mentioned in this article.

9 shashank September 29, 2009 at 11:16 pm

how to download whole directory, sub directory with wget.

10 kyanh September 30, 2009 at 12:51 am

@shashank: try -r and –level options

11 3gitar September 30, 2009 at 1:21 am

thanks for sharing..

12 King Beetle October 9, 2009 at 1:15 pm

I have used wget regularly for a long time, but never realized (or considered) that wget had command line options. Thanks for the great tutorial!

13 kuko November 12, 2009 at 9:55 am

for ((i=10; i<= 99; i++ ))
wget http://url/some_picture_$i.jpg

if som1 needs wild cards just an idea how to do it if one is limited and cant use curls [from-to] range

14 vivek December 1, 2009 at 7:34 am

Good sathiya.. even i referred this article for the -P option for downloading only one particular URL path to a directory..

good work.. keep it up.

15 vivek December 26, 2009 at 11:37 am

for recursive download of index.html to only one directory level , with all required files, you can use this
wget -nc -nd -nH -l2 –convert-links -r /index.html

16 TS Fender January 8, 2010 at 12:04 pm

Great examples! Thanks!!
Q. Can wget download part of a site for offline viewing?
I like to download html documentation for offline use but the links are always wrong for local viewing. i end up creating regular expressions and using the substitute command in vim to update the html files to work locally.
I have tried wget’s –mirror option but it downloads the entire website, rather than just the few pages I want.
Is wget the simple way to get this task done, and if so, how?
Thanks in advance!

17 Edsox5 January 22, 2010 at 1:02 pm

Just a note, I needed to put the web address in double quotes for this to work on my linux box.

18 Yan February 1, 2010 at 7:48 pm

O Man… you saved my time :)

Thanks you so much …

19 Darr247 February 21, 2010 at 12:49 am

Thanks, Ramesh… the only thing lacking is a link to wget’s download site. :-)

20 raiderhost April 10, 2010 at 11:58 am

i’m sure make a great thankz for this tutor :)

hehe windows addict but wont to learning widget at linux to make mirror website :D

xiix thankz broo

21 Chitr June 22, 2010 at 9:58 am

Is there any way to invoke wget programmatically in C/C++ without using system(). Which library contains this. If I get any idea, then I could possibly dyamically load the library for the same.

If someone can give hints on the same, it will be of great help.

Thanks in advance,

22 faezeh alizadeh August 1, 2010 at 9:06 am

its usefull

23 Dinos September 5, 2010 at 3:12 am

How do I download a file with a “%20″ space in the URL?
For example 1.5.1 32bit.exe or ?

If wget can not do this and there is another command line tool which can do this please let me know.

Regards & TIA

24 preveena September 23, 2010 at 11:25 pm

How to download an excel file using wget in unix?Kinldy help.

25 habeeb perwad September 27, 2010 at 6:40 pm

Very Useful Tips!
Keep it up.

26 PhillyG September 29, 2010 at 11:15 pm

You solved my problem! I am going to bookmark this page. Thanks.

27 jehzlau December 18, 2010 at 6:28 pm

how can i get all files with the same file extension in a specific folder using wget?

for example I want to get all .ZIP files on

please help me.

28 bubun December 25, 2010 at 10:51 pm

to jehzlau
use wget -P -A zip

29 vipul vaid December 26, 2010 at 7:37 pm

fabulous tutorial for a beginner

30 vivek December 26, 2010 at 11:59 pm

That -c option to wget is the best!!, it helps to continue the download from where it left off before power failure.

Awesome article again ;)

31 vivek December 27, 2010 at 12:06 am


is a great option if you are using the wget -i , you can keep appending the contents of the file with newer URLs yet it wont download/overwrite the files that are already downloaded ;)

32 daiwan908 January 5, 2011 at 4:40 am

Thank you for your tips!

33 LenMSP January 10, 2011 at 8:27 pm

Thanks for the great tips! Very useful. Looking to direct my downloaded files to a specific directory – perhaps by file extension. TIA.

34 chas March 12, 2011 at 10:01 pm

9. Download Multiple Files / URLs Using Wget -i

tell me what you do to rename these files?

35 magicwand March 29, 2011 at 10:58 am

This is very handy information. Awesome job! Thanks for sharing!

36 Evan Bartholomeusz April 20, 2011 at 9:35 pm

I use a fairly simple WGET command to verify if the IP Address and port are open or closed for a particular server (wget -a /tmp/ports.log -t1 -T1

The issue I have is that there are a number of servers that I need to check, and each server links to other IP addresses/ports.

Currently I have several of these one liner type scripts deployed on each of the specific servers which require being run manually as and when required.

Ideally, I am looking to customize this by hopefully creating one script that can recursively read in perhaps a flat file of IP addresses/ports against a WGET command and report on only those that are not connected (ie: “failed: Connection timed out.”). Results to be written out to an output file.

Is it possible to create this single script in such a way that it can be run from a single location (like windows) rather than deploying the script and running it in each of the servers?



37 Franklin September 5, 2011 at 9:13 pm

If you have a download link (e.g.download_script.php?src_id=7701) but do know the extension of the file being provided (it could be zip, rar, dmg, gz, etc..), how do you know what to call the file in your -O argument?

Is there any way to get wget to resolve the file extensions automatically?

38 Ravikant September 21, 2011 at 10:24 pm

Where the is saved when downloaded using command “wget” ?????

39 ned October 27, 2011 at 3:45 am

2. Download and Store With a Different File name Using wget -O
How can I store with a different file name dynamiquely
I wanna add the date to the name of file
wget -O File_%DATE%.txt ftp://username:pass@Host/folder/File.txt
that doesn’t work :(
P.S: I use wget on windows.
Thanks for your help

40 ned November 15, 2011 at 4:33 am

I found a solution of my prob, it’s only missed a “”:
wget -O “File_%DATE%”.txt ftp://username:pass@Host/folder/File.txt

41 Arun November 23, 2011 at 11:21 pm

I am using the wget command to download a file. But, the speed is too slow its happening B/S. Can we increase it to KB/S?. Is there any network settings I need to do in order to increase the speed?

42 ned November 24, 2011 at 10:09 am

To Arun: you can limite the speed (–limit-rate=value k) but you can’t increase it.
It depend with the connexion that you use.

43 Tapas Mishra December 20, 2011 at 8:22 pm

Nice article but there is one more interesting link include the things given here also

44 Jay P January 3, 2012 at 2:32 pm

A cool trick. If you come across a site with download links using a PHP redirect that won’t work with WGET (you get an html file named *.php* instead of what you want) What you can do is use WGET to mirror the page with the links.

wget –mirror -p -A.php -P ./LOCAL-DIR WEBSITE-URL

It will start downloading all of the PHP on the page including the files behind the PHP redirects. Now what you can do is stop with CTRL+C once it starts downloading one of those files behind the PHP redirect. Above the Progress bar you’ll see a URL next to a Date stamp and above “Resolving [some address here]… [some IP]“, That’s the real location of that file. Using that you can now figure out the actual location of the file you want.

You could also just let WGET keep running until it’s downloaded all the files and just find the one you want from the dump, but depending on how many Download links there are, you could end up with a lot of really large files. If you want to do this I reccomend making sure the Download Loctaion has plenty of Free Space.

45 ned February 23, 2012 at 3:12 am

I don’t understand so much how
wget -r –dont-remove-listing ftp://username:pass@Host/folder works !!
I know that creat a list to check the ftp files BUT if there’s a new file on the ftp folder, i can’t download it with this methode.
-nc helps to download only the new files but it take much time if there is a lot of folders.
as there any other way please ?

46 Sirisha Sunkara March 8, 2012 at 7:41 pm

Is there a way to mirror a static copy of a PHP page that requires login and password authentication?

I tried this (using a cookies file), but had no luck:

Something else that I need to know pertaining to the syntax here…?

Thanks a lot!

47 CSC March 28, 2012 at 7:19 am

What about downloading a file and saving it to a certain directory?

48 Yusuf Irzan April 29, 2012 at 8:54 pm

Thanks, I’ve been looking download with list file, and finally found it here

49 yamen May 1, 2012 at 10:32 pm

Very nice..! How do I specify which directory I am downloading files to?

50 ned May 2, 2012 at 2:58 am

you just need to be in the directory.
cd c:\test
wget …
the files will be saved in the folder test


51 Tom May 9, 2012 at 9:25 am

wget -r -PE:\test

will download all zip files located in a certain subdirectory at the ftp server of into the test folder on your E-drive.


52 Anonymous June 21, 2012 at 11:55 pm

how can i download any thing in A specific path ??

wget http://abcd/../../a.php   >> /var/www/html/
53 ned June 22, 2012 at 7:33 am

this question is already get ansered

you just need to be in the directory.
exemple with wget in windows:
cd /var/www/html/
wget …


54 Mike June 25, 2012 at 8:34 pm

Great information!

Anyone able to use Wget to get past Digest Authentication and download the web page?

55 Jalal Hajigholamali July 6, 2012 at 8:53 am


Thanks a lot, very useful article

56 block72 July 12, 2012 at 1:04 pm

great article – use wget with caution. wget is a direct link to the other server [ file, web, etc... ] Especially if you use the -r option!! If you’re not watching the logs you could download 500g of data before you know it. Excellent intro to the topic. To add to this article I’d also suggest to look at the documentation.

57 sumit dinodiya July 18, 2012 at 2:44 am

Hello sir, i am new to linux but when i read ur posts its really interesting to learn and use commands of linux.
Its Nice to have u…………………..
thanks a lot

58 tothimre July 29, 2012 at 9:21 pm

In example 2 can use –content-disposition option to save file in correct name.
$ wget –content-disposition

59 domain admin August 20, 2012 at 9:14 pm

just what i was looking for.. i had the older wget syntax.

thank you

60 Deepak September 1, 2012 at 6:07 pm

Thanks for the excellent information!
Is there a way to pass an argument to the download link? I am looking to download build from Jenkins/Hudson server but the build number keeps auto-incrementing to a new number. Hence I have to update the URL with the new build number.
I am looking for a way to automate this process and not enter the build number (may be through a script?). Any help would be appreciated..

61 ned September 3, 2012 at 5:16 am

you have two choices:
1. replace the number incremented by *
2. do a script who increment the last number just before the wget line, and insert it in a variable..

62 Deepak September 4, 2012 at 10:54 am

Thanks ned!
Yeah I’m looking at option #2 and will report once I get it working..

63 ned September 5, 2012 at 3:17 am

@Deepak, here is a solution,
:: you put the variable to be increment in the file C:\test\increment_variable.txt

:: this line set the number in the file to a variable v
FOR /F %%a IN (C:\test\increment_variable.txt) DO SET v=%%a
:: increment the variable
SET /A increment_v=%v%+1
:: do your wget commande
wget … %increment_v%
:: replace the varible incremented in the file
echo %increment_v% > C:\test\increment_variable.txt

Let me know if that works ^^

64 AROD September 21, 2012 at 2:10 pm

Thanks for the quick tutorial.

65 vilas September 22, 2012 at 12:38 am

how to download check file “check_memcached.tar.gz” from this link. When I use wget it’s download only “attachment.php?link_id=2182″ this file and size is “0″. Please help me.

66 ned September 23, 2012 at 3:05 pm

you need to put the extention of the file .tar.gz u want to download

67 David October 17, 2012 at 8:41 am

–limit-rate is an unrecognized option

68 jone November 5, 2012 at 3:23 am

How to download all videos from a specif website?


69 rizwan January 30, 2013 at 8:33 am

that was really nice

70 Rao February 6, 2013 at 9:07 pm

Nice examples.
Some urls require authentication user, password. One may use :
wget –user –password URL
However, when the above above command is downloading the file, password can be viewed by other users on different sessions by simply typing ‘ps -eaf|grep wget’. To avoid this, use the below option which will ask password later and will password will not appear in the process list:
wget –user –ask-password URL
NOTE: not sure if this option for wget is available in all flavours of unix

71 murugesh April 16, 2013 at 5:26 am

very nicely explanied, thank a lot

72 WJC May 13, 2013 at 10:07 pm

Fantastic tool as well as this teaching article. Thank you most much for sharing knowledge !!!

Just tried “Download Multiple Files / URLs Using Wget -i” for 6 embeded mp3 files and it works like a charm !!!

73 Alim May 31, 2013 at 4:30 am

I would like to Download all the .pdf and reject .zip files of a Website including there Original ‘Directory and Sub-Directory’ i am trying the following command

wget -r -l0 url

But, its downloading all the files of a url including ‘index.php, and .zip’ files…i want to reject ‘.php, and .zip’ files

74 amir July 8, 2013 at 6:00 am

this article really help me.
thanks alot.

75 daniel July 22, 2013 at 1:14 pm

These guides were extremely helpful. Especially the demonstration of the user agent switch. Helped me a lot. thanks

76 roshan August 27, 2013 at 7:45 am

Very userful info
But i have a few problems
1) How to download https files
2) How to download the files(when username and password is mentioned in the URL

77 Walter September 11, 2013 at 10:26 pm

I have an interesting issue, I am trying to tackle. Consider this link

I need to the output of the data ie. values of open,high,low,close, vol, chg, et. et.

I tried several options however I am not able to get the data in a file, this is oe of the several commands i used.

wget –user-agent=”Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/2008092416 Firefox/3.0.3″ -O c:/temp/sample.csv “”

Any inputs will be appreciated.


78 abhishek October 9, 2013 at 3:26 am

I downloaded following file

file is 920 Mb approximately, I do not use any download manager it was a direct http download, after having approximately 600 Mb of download some how the download has broken, I have a file now which is 600 Mb but this should have been 900 Mb is there any way to resume this one using wget

79 ned October 9, 2013 at 5:00 am

take a look to num 4,
4. Continue the Incomplete Download Using wget -c


80 venkatesh November 11, 2013 at 10:41 pm

can someone tell me how to view the contents of downloaded file in unix…

81 neal January 22, 2014 at 5:40 pm

hello, how do we retry wget after when we see 500 Internal Server Error? Regards

82 A March 27, 2014 at 9:09 am

Does this work for wget for windows too? I am using the command to downlaod all PDF files and it tries to download the entire website. help!

Leave a Comment

Previous post:

Next post: