Sunday, May 30, 2010

How to download Youtube videos

Have you ever wanted to download a Youtube video? This is very easy with Firefox as there is an add-on called 1-Click YouTube Video Download. Once you have installed this add-on there will be a link below every Youtube video where you can download them in the following formats: MP4 HD (High Definition), MP4 High-Quality and FLV.

Which format should I download?

This depends on what you want to do with it. The MP4 file format is usually the recommended format as it allows easy conversions to other formats. The FLV format is the container file format used to deliver video over the Internet using the Adobe Flash Player. Finally the 3GPP file format is mostly used on used on 3G mobile phones.

Saturday, May 29, 2010

How to change the user agent in Firefox

Did you ever reach a website which said something like "Your browser is too old". Sometimes it is not easily possible to upgrade your browser like if you have an Asus Eee PC. Here's how you can change your user agent so that those annoying websites will work again.

With Firefox this is a peace of cake. First install the User Agent Switcher add-on for Firefox. Once you have clicked on "Download Now" and have restarted your Firefox you will have a new menu under Tools (Default User Agent) which lets you change your user agent to anything you want.

Once you have changed your user agent you can verify it on this site.

How to get the window ID (Xwindows)

Here is how you can the the x windows id:

$ xwininfo

Now click on the window you would like to get the id, eg. Firefox. You will get some results like this:

$ xwininfo

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x28000c8 "Getting window id for certain process id (for sharing theapplication) - Unix Linux Forum - - Mozilla Firefox"

  Absolute upper-left X:  107
  Absolute upper-left Y:  102
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 847
  Height: 627
  Depth: 24
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +107+102  -326+102  -326-295  +107-295
  -geometry 847x627+104+78

Here, the window id of Firefox is 0x28000c8.

Now you'll ask yourself why on earth would I need the window id. This is useful for example if you want to record a video with recordMyDesktop which takes the window id as an argument like this:

$ recordmydesktop -windowid 0x28000c8

Friday, May 28, 2010

Feisty Performance - "Fly Like A Butterfly"

This blogpost is a mirror of an old URL ( which does not exist anymore. As there are still plenty of sites linking to it I'm publishing it here so it stays online.

Disable IPv6
At least I dont need ipv6 yet so this is what I do to disable it. In the future there might be some use of ipv6 but until then I’ll keep disabling it.
sudo kate /etc/modprobe.d/aliases
And change the line:
alias net-pf-10 ipv6
alias net-pf-10 off #ipv6
Now comment out all the lines that has to do with Ipv6 in your hosts file.
sudo kate /etc/hosts
This will disable IPv6 on all network interfaces. You need to reboot.

Run boot processes in parallel
This will make upstart to run the boot processes in parallel and speed up the boot process.
sudo kate /etc/init.d/rc
Find and change the line:
Make sure to check your spelling, one little mistype here and you won’t be able to boot!!!
This one seems to do best if you are using SATA or SCSI but even on my old computer with the old ATA it does make the KDM login screen show up a little bit faster.
There could actually be that this tweak slows down your boot if you are using old hardware…

Aliasing hostname to localhost
Right or wrong, you decide. But I picked this up in the Ubuntu forums some time ago and it does improve the startup of some apps.
sudo kate /etc/hosts
and add you hostname to the first line after localhost like this: localhost yourhost yourhost

Disable pango
I know that this is already taken care of in firefox but it still makes a good performance boost to thunderbird and some other apps.
sudo kate /etc/environment
and add:

Disable gettys
Thank’s to some anonymous user for the tip.
sudo kate /etc/event.d/tty3
and comment out the lines starting with start and respawn with a number sign (#).
This does not improve my performance at all but it saves a little resources so why not

It does what you think. It preloads most common used libs and application = faster startup times on your applications (this does not increase your boot speed as some might think).
sudo apt-get install preload
What about prelink?
Prelink is no longer necessary in feisty. Feisty uses a new linking mechanism called DT_GNU_HASH which speeds up the linking process without the need for continuously running prelink.

The default value for vm.swappiness is 60 in Ubuntu Feisty whic is a good default value but if you want to tweak the performance a little bit more you can change this value to a lower value to reduce the load of the swap. If you run the follwing command:
sysctl -q vm.swappiness
You will se that the value is set to 60. And by running:
sudo sysctl vm.swappiness=10
You will change the value from 60 to 10 which will make your system write to swap a lot less and I would recommend this to everyone that has 512 MB of memory or more. If you find that you have very little use of swap set the value to 0. This will not disable the swap but it will make your system write to the swap as little as possible and keep as much as possible in memory. This makes a huge improvement when switching between applications since they are now likely to be in physical ram instead of on the swap partition.
To set your value permanent you need to change the sysctl.conf file:
sudo kate /etc/sysctl.conf
Add the line
To the end of the file. This way it will be set upon boot.
I’ve found that the value of 5 works very good for my use and I have 1 GB of memory.

Grub option profile
There is a option to grub called profile which will profile your startup. What it does is that it kind of indexing all the files read during boot/startup and later on it will find and read those files quicker.
Hit the escape button when booting to get to the grub menu.
Select your default boot kernel and hit the e button.
Go down to the second line and hit the e button again.
Add profile to the end of the line and press enter.
Hit the b button to boot with your new option.
The first time it will take a little bit longer to boot because it has to build the index (or whatever they want to call it) but every boot after this will be a lot smoother.
You need to do this every time you update your kernel or have made other huge changes to your system that might affect the files needed during boot.

Install sysv-rc-conf and disable the services you don’t need at startup.
As an example. On my computer I don’t have bluetooth or PCMCIA so I don’t need to start it at boot time.
So simply disable what ever you don’t have or use.
sudo apt-get install sysv-rc-conf
and then run:
sudo sysv-rc-conf

This is just a general tip. I will not tell you what to remove. You know best what you need…
If you strip down the xorg.conf you can decrease the amount of resources that xorg will use.
sudo kate /etc/X11/xorg.conf
Remove any unnessesary fontpaths, modules and the wacom devices (unless you need them).
By removing the wacom devices you will also get rid of those anoying errors that usually prints out in the console whenever you run an application.

Kernel hacking
Even thought the new kernel in feisty is very good and already tuned a bit there still are some things you can do to the kernel that will make your system snappier and boot up even faster.
Use this thread from the ubuntu forums as a guide on how to compile your own kernel.
master kernel thread
What I do is that I make sure to add the file systems and drivers I use to the kernel instead of loading them as modules. Take out whatever I don’t have or use and then compile my new and hopefully improved kernel
If you don’t want to compile your own kernel there is now a low-latency kernel in the universe repos that you could try.

Disk and file system setup
This is probably the most important thing to think about when you are about to install your computer. The choice and use of the disks and file system is a huge issue when dealing with performance. Depending on your usage of your system you might need to configure your file system different.
For my usage I like to use the following setup (which I think is a good desktop setup).
Mountpoint File system Size
/boot ext2 100 MB
/ LVM, VG=system, XFS 6 GB
/swap LVM, VG=system, swap The size of RAM in your computer. Making it smaller and you will not be able to hibernate.
/home LVM, VG=system, XFS 1 GB, or the rest of the space in that VG
/data LVM, VG=data, XFS The rest of the free space
I’m using the following options in fstab for all my xfs partitions:
Using LVM can really speed up the disk performance. And you get a lot of other good stuff with it as well. Read more about LVM here.
I choose to have /root and /home on one VolumeGroup and /data on another simply because I can then split them up on different physical disks and have them spanning over multiple physical disks witch really speeds up the reads and writes.
What about hdparm?
I have not found any use for hdparm on SATA disks (seems to lack support for SATA). But on older disks there are some things you could tune with hdparm.
Anyhow, since I don’t use it I won’t give you any example on how to use it. Simply search for hdparm on the net and you will find plenty
Defragmentation of XFS filesystem
Until just about a month ago I did not believe that the worlds best file system could get fragmented so I never even bothered to check it out. But then I accidentally came across an article discussing fragmentation on different file systems and I realized that it actually could.
So here is how to defrag your XFS filesystem
make sure that you have xfsdump installed and the run:
sudo xfs_db -r /dev/[your xfs partition]
at the prompt xfs_db> type in frag to view the fragmentation factor and then type in quit to exit the xfs_db util.
If your fragmentation factor is above 10% then I would recommend defragmentation.
Now, to actually defrag the filesystem you need to do this
sudo xfs_fsr -v /dev/[your xfs partition]
And then it is time for a well needed break from your computer for a while.
The results. The one thing that I immediately noticed is that after defragmentation is that the operations browse and delete are much faster on my XFS partitons.
At the moment this is pretty much it but I will update this guide as soon as I discover more performance tunings…

Tuning applications

At the moment there is not so much to add here but this what I like to do.
Use swiftfox instead. It’s optimized for your CPU.
If it’s not already set, disable ipv6. In the url enter about:config and find the ipv6 entry and disable it. And while you are at it change the ui.allow_platform_file_picker to false to change the file dialogs to look a little bit better (if you are a KDE user like me).
Addons I use:
Opens video stream directly in an external video player
A nice gui to tweak the performance of the browser
adblock plus
to disable ad’s it helps a lot
Mouse gestures
Cause it makes the surfing a lot easier…
Gives it a little bit more of a KDE look and feel…
If you don’t need that extras that java JRE provides then simply disable it openoffice. That’s what I do.

Q & A

I followed this guide and managed to screw up, now I can’t boot…
Hey, what can I say. Life’s a bitch…
Well ok then. Here’s something that might help.
Boot up your computer with the Feisty desktop cd
mount your root file system and change/restore your files again.
If you are using LVM then apt-get install lvm and then run vgchange -ay to activate your LVM volumes before you can mount them.

Wednesday, May 26, 2010

Speedup old Linux PCs by disabling auto run of "updatedb"

Here is a way you can speedup old Linux PCs by disabling the auto run of updatedb. updatedb creates a database of all local files (an index) so they can be found faster. Most users won't need this so it can be safely disabled.There can be several files responsible for the daily update of this database:


By default the run-parts program (which is used to run all the files there) only accepts files which contain letters, numbers and hyphens. Renaming the file to something with a dot in it for example will cron stop from executing this file.

To rename these files you have to type the following a console:

mv /etc/cron.daily/find /etc/cron.daily/find.old
mv /etc/cron.daily/slocate /etc/cron.daily/slocate.old 
mv /etc/cron.daily/mlocate /etc/cron.daily/mlocate.old

This will rename the three files so that cron will not execute them anymore.

Monday, May 24, 2010

Set up Kubuntu 8.04 (hardy) automatic updates

Here's how you can set up your Kubuntu 8.04 (hardy) for automatic updates. This is useful if you have set up a Linux system for someone who is not very familiar with the system but you still want them to have the most recent security updates.

First you have to start the Adept Installer by clicking on the "K" in the lower left corner and then "Add/Remove Programs". You'll the see the Adept Installer coming up:

Click the button "Edit Software Sources" in the bottom left corner. In the next window click on the tab "Updates":

Now you can select "Install security update without confirmation. From now on your Kubuntu will check daily for updates and install them automatically.

Saturday, May 22, 2010

How to download Apple trailers with wget

Did you ever try to download a trailer from It doesn't work. Apple is trying to limit downloads to the iTunes application. Here's how you can change your user agent so the download works with wget.

Choose a trailer to download. For example the movie The Scientist produces the link

To get the correct URL you have to add the letter 'h' before the resolution. In our example the correct URL will look like this:

Now you can use wget with the parameter -U QuickTime/7.6.4:

wget -U QuickTime/7.6.4

Have fun watching the trailers.

The difference between a client and server SSL certificate

So what is the difference between client and server Secure Sockets Layer (SSL) certificates? Although client certificates and SSL server certificates both use certificates, they are not directly related to each other. SSL server certificates provide encryption and security functionality. Client certificates provide user authentication functionality. The client certificate identifies the user, the server certificate identifies the server.

Here is the technical difference between the two. The difference lies in the Certificate Extensions. The X.509 standard defines what information can go into a certificate, and describes how to write it down (the data format). X.509 Version 3 is the most recent (1996) and supports the notion of extensions.

This tech note by Mozilla describes the Certificate Extensions in detail. But here are the extensions which are necessary for a client certificate:

basicConstraints = CA:FALSE
nsCertType = client
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth

If you want to know how to create such a client certificate, see my last blog entry.

How to create a self-signed SSL client certificate

Here's how to create a self-signed SSL client certificate with openssl on the command line.
First we have to create the private key:
openssl genrsa -out client.key 2048
Now we can create certificate request. Enter all the distinguished name information required to create a certificate request using the following command:

openssl req -key client.key -new -out client.req

OpenSSL commands expect to receive a file named: client.cnf. This file stores information that help generate extension fields to the certificate. You must create the client.cnf file with the following information:

[ ssl_client ]
basicConstraints = CA:FALSE
nsCertType = client
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth

Create a certificate request into a self signed certificate using extensions for the client certifiacte:
openssl x509 -req -days 365 -in client.req -signkey client.key -out client.crt -extfile client.cnf -extensions ssl_client
Verify the certificate:
openssl x509 -text -noout -in client.crt
As you can see the SSL extensions are now part of the certificate:
X509v3 extensions:
X509v3 Basic Constraints:
Netscape Cert Type:
SSL Client
X509v3 Key Usage:
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Client Authentication

Now you can test your SSL connection with the following command:
openssl s_client -connect localhost:443 -key client.key -cert client.crt