Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use wget to automatically download a wallpaper. Here is the command:


However, if I try to open the resulting picture, it seems to say it has a bad magic number. By running file 1600.jpg, I get 1600.jpg: GIF image data, version 89a, 1 x 1. If I open it as a GIF it doesn't work either. It's only 37 bytes too.

It works perfectly fine if I view or download it through Firefox.

Any ideas?

share|improve this question
up vote 6 down vote accepted

I think it's some kind of protection against direct downloads, nothing wrong with wget (the server is sending you a transparent 1x1 GIF image).

You can circumvent this by using wget with the -U flag, adding the user agent string of your browser, eg.:

wget -U "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.17 (KHTML, like Gecko) Ubuntu/11.04 Chromium/11.0.654.0 Chrome/11.0.654.0 Safari/534.17"

BUT: You should first ask the owner of that website if it's ok to download the content this way. There has to be a reason why the usual wget approach is blocked (maybe it's intentional, maybe it's just misconfiguration).

share|improve this answer
I see. But why isn't Firefox affected? And how would I get around that? – alecRN Feb 5 '11 at 17:10
@alecRN: See update. – htorque Feb 5 '11 at 17:25
Thank you! It works perfectly now! – alecRN Feb 5 '11 at 17:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.