Nice hint and tips for using wget

on Friday, February 20th, 2009 at 12:28 am

I think most of us have used the wget command once or twice.
What i will do now is explain a few tips and tricks on using this useful command.
1. Download many files at the same time
2. Download and resume
3. Limit your download to a specific speed
4. Split your download for faster results
5. Log your download
6. Download in the background and keep using the terminal

Common use of wget:

wget http://example.com/bleh.tar

1. Download many files at the same time
There is more then one way to do this, my favourite one is to create a .txt file using the vi command and write in it the URLs of the files you want to download

vi downloads.txt

write in it

http://example.com/bleh.tar

http://example.com/tfeh.tar

http://example.com/blah.tar

http://example.com/stuff.tar

Then run wget using the -i argument

wget -i downloads.txt

2. Download and resume
You can force wget to resume any broken download like this

wget -i -c downloads.txt

3. Limit your download to a specific speed
You can use this when downloading a big file and you don’t want the connection to choke

wget -c –limit-rate=20k http://example.com/bigstuff.tar

4. Split your download for faster results
Just like free download manager or download accelerator on windows :D
To do this we will have to use awget instead of wget

aget -n=5 http://example.com/bleh.tar

Note that i could not find aget in the repos. However you can download a .deb package from http://www.enderunix.org/aget/

5. Log your download
Log all your downloads into a file

wget -c -o downloads.log -i downloads.txt

6. Download in the background and keep using the terminal

wget -cbi downloads.txt

Note that doing the above will automatically create a log file for the download process
To specify your own log file location do the following

wget -cb -o downloads.log -i download.txt

Hope this helps :)
// Jo

Changing the welcome message in SSH

on Thursday, December 18th, 2008 at 1:57 pm

If your a linux user or maybe a simple linux server administrator with some servers at hand, the chances are that you use SSH to login there and manage them.

When a user logs in to SSH usually he sees a welcome message.
If you have an ubuntu machine like me then you will see the following message

Linux jo-desktop 2.6.27-9-generic #1 SMP Thu Nov 20 21:57:00 UTC 2008 i686

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To access official Ubuntu documentation, please visit:

http://help.ubuntu.com/

In order to change this message just type in the terminal

sudo vi /etc/motd

Screenshot

Update:
Note: On restart your changes to /etc/motd will be reverted, the reason is that /etc/motd is a symbolic link to /var/run/motd which is rebuilt by /etc/init.d/bootmisc.sh from a template, /etc/motd.tail, at each reboot. (thank you Adam Trickett).

jo@jo-desktop:/etc$ ls -l motd
lrwxrwxrwx 1 root root 13 2008-11-27 14:18 motd -> /var/run/motd
jo@jo-desktop:/etc$

This means that to make your changes permanent you can either:
1. change

/etc/motd.tail

then reboot

2. point the /etc/motd symlink to a different file such as /etc/motd.static and make your changes there. (Also thank you Adam Trickett).

Joe

Preventing hotlinking to your website using .htaccess

on Tuesday, November 25th, 2008 at 3:32 pm

What is hotlinking?

In the web community, “hotlinking” is a curse phrase.
Also known as “bandwidth stealing” by the angry site owner, it refers to linking directly to non-html objects not on one own’s server, such as images, .js files etc. The victim’s server in this case is robbed of bandwidth (and in turn money) as the violator enjoys showing content without having to pay for its deliverance. The most common practice of hot linking pertains to another site’s images.

So how to prevent someone from hotlinking to your website?
How to give them maybe a “nasty” surprise when their hotlinks become so pervasive as to have a significant effect on your bandwidth usage ?

An easy solution is to write this piece of code into your .htaccess file.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/somelink.ext [R,L]

Of course dont forget to replace
1. “mydomain.com” by your domain name
2. gif|jpg by your desired of file extension you wish to block from referrers (ex: gif|jpg|css|js)
3. http://www.mydomain.com/somelink.ext by the page you wish to redirect to when someone is trying to access (2)

Hope it helps
// Jo

Problems with sound and video on ubuntu ?

on Saturday, May 31st, 2008 at 1:05 pm

Howdy,


I am writing this post because so many people are asking me about it.
I will not invent anything new here, i will just make a general tutorial that will fix 80% of your audio/video problems.

Please understand that i do not guarantee 100% success result, because it all depends on the hardware you have.

Before digging in complicated stuff, lets first try to install the Medibuntu packages.

Some of these packages include the libdvdcss package from VideoLAN and the external binary codecs package (commonly known as w32codecs) used by MPlayer and xine.

Step 1:
Add Medibuntu to your system’s list of APT repositories.
For ubuntu 7.10

sudo wget http://www.medibuntu.org/sources.list.d/gutsy.list -O /etc/apt/sources.list.d/medibuntu.list

For ubuntu 8.04

sudo wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list

Now add the GPG Key:

sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update



Step 2:
Install the libdvdcss2 package.
This package is used to play encrypted DVDs, more information about it here

sudo apt-get install libdvdcss2



Step 3:
Installing Non-Native Media Formats.
These media formats includes but are not limited to: wmv, mp3, .mov, .rm etc…

For i386 (use this if you are not sure)

sudo apt-get install w32codecs

For amd64

sudo apt-get install w64codecs



For ppc

sudo apt-get install ppc-codecs

This is it, restart your PC now and try to play some music. If you still cannot hear the beat continue reading this post.

mmm… I see you are still having problems ? Lets try to do more complicated stuff.
What we will do now is recompile the alsa drivers

UPDATE: Please be aware that compiling from source should be done as a last resort.
When you compile stuff from source apt don’t know about them, so it wont keep track of it.

Step 1:
Lets download them first.
We need to get: alsa-driver, alsa-lib and alsa-utils.
You can download the latest releases from here:

Step 2:
Untar these packages.
You can untar them using GNOME or by typing this line of code in terminal

tar yxf alsa-driver-xxx.tar.bz2 alsa-lib-xxx.tar.bz2 alsa-utils-xxx.tar.bz2

Note: dont forget to replace xxx by your version number.

Step 3:
To configure/install alsa utilities we need the following package.

sudo apt-get install libncurses5-dev



Step 4:
Installing alsa

In the alsa drivers folder type:

sudo ./configure –with-cards=intel8x0 –with-sequencer=yes ; make ; make install

In the alsa Lib folder type:

./configure
make
sudo make install

In the alsa utilites folder type:

./configure
make
sudo make install



Restart your PC and cross your fingers :)

Hope I helped you in a way.

// Jo