Παρασκευή 26 Οκτωβρίου 2007

Font Management in Linux

Fonts in Linux are crazy. Most Linux distributions ship with a big blob of serif, sans serif, and monospaced fonts, and there's barely a pixel's worth of difference between them.

Fonts on computers are crazy. Sometimes I pine for the olden days of swapping out the type balls on IBM Selectric typewriters to get different fonts. You always knew what you were getting with those.

Many fonts are copyrighted, so you cannot legally copy them and give them away to all of your friends. Some applications come with their own sets of fonts and rendering libraries. The GIMP does this because it thinks it can handle fonts more competently than your X server; it uses FreeType and Pango. OpenOffice.org also comes with its own set of fonts, for what reasons I know not.

The good news is your system is probably already set up to share all these fonts system-wide, and FreeType and Fontconfig are becoming standard. So the GIMP and OpenOffice.org can use your system fonts, and other applications can use the GIMP and OpenOffice.org fonts. If this is not so you can easily fix it. Just find the directories where the fonts are stored and add them to.

/etc/fonts/conf.avail/51-local.conf


Then, as root, run fc-cache to rebuild the fonts cache. Et voilá, and done! Some howtos say to edit /etc/fonts/fonts.conf but you shouldn't do this. local.conf is for your own customizations, and /fonts.conf will be overwritten when Fontconfig is updated.

There is one more peril: duplicate fonts in different font formats. if you have the same font in two different formats, you'll get inconsistent behavior. There can be only one.

Font Formats De-Mystified
The three main font formats are TrueType, OpenType, and PostScript. TrueType fonts have a .ttf extension on Linux/Unix, Windows, and Mac OS X, plus .ttc on the Mac. TrueType fonts scale up and down in size gracefully without jagged edges or inconsistencies in line thickness; you don't need a separate file for each size, but only for different styles like italic or bold.
PostScript fonts need two files each: .pfb is the printer font. This is specific to Linux and Unix; Windows PostScript fonts are .pfm and .pfb. Mac OS X handles PostScript fonts in a number of different ways that I don't even want to get entangled in, involving suitcases and forks and other oddments.
OpenType is a newer font format developed jointly by Microsoft and Adobe, their "can't we all just get along" format. Its file extension is .otf, and it works on both Windows and Mac.
Bitmap fonts are an old format. You need a separate font file for each size and style, so as you can imagine hardly anyone uses them anymore.
Most Linuxes these days come with both TrueType and PostScript Type 1 fonts. Finicky desktop publishers insist on using PostScript fonts with genuine PostScript printers, but these are becoming rare. Most printers support some form of PostScript emulation. Ghostscript is a PostScript interpreter that comes standard on most Linux distributions, so you should always be able to read and print PostScript documents.

Font Managers
Linux is lacking in good font managers. KDE's font installer is decent; it finds and displays the fonts on your system that Fontconfig knows about, and installs and removes fonts. It also displays the font type, and you can print a catalogue of all fonts or selected fonts. Use Ctrl+left-click to select non-contiguous fonts, and Shift+left-click to select a batch of contiguous fonts. Each font takes up two lines, so you can cram a lot onto a single page. On ordinary KDE you'll find the font installer in kcontrol. Kubuntu puts it in System Settings -> Appearance.
Gnome users can go into Nautilus, navigate to the folders that hold TrueType fonts, and click on individual fonts to generate a preview. But it won't work for other font formats. OpenOffice.org Writer and KWord both have nice font previewers, so at least you can quickly see what they look like.

Ubuntu Fonts: The Horror

Ubuntu installs over 200 fonts, the majority of them foreign-language fonts that only the most gifted linguist would ever be able to use. They're useless anyway since most of them don't render correctly. Those odd-looking ae_ fonts that have so many Ubuntu users scratching their heads? Those are all part of the ttf-arabeyes package. A quick way to find out which package a font belongs to is using the locate command to search on the font name:

$ locate -i ae_cortoba
/usr/share/fonts/truetype/ttf-arabeyes/ae_Cortoba.ttf


Go into Adept or Synaptic, search for installed fonts, and you'll see at a glance which ones are relevant to you. Do not remove:

Any xfonts or xfont utilities
  • x-tccidfont-conf
  • ttf-opensymbol
  • ttf-dejavu
  • anything that starts with lib
  • fontconfig
  • defoma
  • anything that starts with console
  • gsfonts

Ηow to Create PDF Documents in Ubuntu

Εάν χρησιμοποιήτε το OpenOffice είναι πολύ εύκολο να δημιουργήσετε έγγραφα PDF. Υπάρχει στο μενού File η επιλογή ‘Export as PDF’. Για τις υπόλοιπες εφαρμογές θα χρειαστεί η παρακάτω διαδικασία.

Πρέπει να εγκαταστήσετε το cups-pdf. Αυτή η εφαρμογή δημιουργεί έγγραφα PDF σε ένα ετερογενές δίκτυο δημιουργώντας ενα εκτυπωτή PDF στον κεντρικό διακομιστή. Είναι διαθέσιμο κάτω από την GPL και υπάρχουν πακέτα για αρκετές διανομές ή μπορείτε να τα δημιουργήσετε από το πηγαίο κώδικα.

Εγκατάσταση cups-pdf

sudo apt-get install cups-pdf

Χρειάζετε να δώσετε τα παρακάτω δικαιώματα

sudo chmod +s /usr/lib/cups/backend/cups-pdf

Ρύθμιση CUPS για τον εκτυπωτη PDF.

  • Επιλέξτε SYSTEM > ADMINISTRATION > PRINTERS > NEW PRINTER
  • Επιλέξτε LOCAL PRINTER
  • Χρησιμοποιήστε τον εκτυπωτή: PDF PRINTER
  • Επιλέξτε Print Driver:
  • Κατασκευαστής: Generic
  • Μοντέλο: Postscript Color Printer
  • Όνομα: postscript-color-printer-rev3b
  • Επιλέξτε APPLY

Όταν τυπώνετε από οποιαδήποτε εφαρμογή, επιλέξτε τον εκτυπωτή postscript-color-printer-rev3b για να δημιουργήσετε αρχεία PDF.

Τα αρχεία αποθηκεύονται στο φάκελο /home κάτω από το φάκελο /PDF.

Για να αλλάξετε το προκαθορισμένο φάκελο αποθήκευσης

Διορθώστε το αρχείο /etc/cups/cups-pdf.conf

gksudo gedit /etc/cups/cups-pdf.conf

βρείτε τη γραμμή

Out ${HOME}/PDF

και αλλάξτε το σε

Out ${HOME}/my_print_to_pdf_folder

όπου /my_print_to_pdf_folder είναι ο φάκελος της επιλογής σας
και κάντε επανεκκίνηση

sudo /etc/init.d/cupsys restart

How to set up Apache virtual hosting

Managing one site on a Web server can be tough enough, and the job is even harder if you have to host multiple client sites on a badly configured setup. If you're running Apache, you can make things easier by setting up virtual hosts, which let you control multiple domains on one IP address, allowing you to specify URLs like http://clientsdomain.com/file_name.html instead of http://yoursite.com/hosted/clients_directory/file_name.html, and letting you forgo setting up domain forwarding with a /srv/www/htdocs/hosted/clients_directory file.

If Apache is installed correctly, you can set up virtual hosting easily by editing Apache configuration files. The main .conf files in /etc/apache2 include httpd.conf, error.conf, server-tuning.conf, and a bunch more. These files are set for read-only access for normal users; you must gain root access with the sudo or su command to change them.

Edit /etc/apache2/httpd.conf and find this line:

Include /etc/apache2/vhosts.d/*.conf

Replace it with a line that specifies a .conf file we will create and call vhost.conf:

Include /etc/apache2/vhosts.d/vhost.conf

When you've made the change, save the file. Now, again as root, create the vhost.conf by renaming the vhost.template file in /vhosts.d/:

mv vhost.template vhost.conf

Now edit the file to set it to allow multiple name-based Web sites on a single IP address. First add in the virtual host directive with NamevirtualHost *. The asterisk is a wild card character that allows any address to be set. Under that directive you can add your first virtual host:

NamevirtualHost *


ServerAdmin youremail@yoursite.com
DocumentRoot /srv/www/htdocs/directory_of_your_choice/
ServerAlias yourdomain.com *.yourdomain.com

The first part is the opening tag for the defined virutal host block. ServerAdmin lets you display the administrator email address when an error such as a 404 occurs. DocumentRoot is the root directory for the defined site; for example, sites I have hosted in the past all had accounts set up within /srv/www/htdocs/hosted/sitename/. Next is the ServerAlias or ServerName, which controls what names people can use to see and access a site. You could set this to a directory within the main NameVirtualHost or the domain of the site so the server can display the content associated with the domain name. The reason for the two ServerAlias entries above is that servers are often called from more than one ServerName, so you set up a ServerAlias with more than one address listed. The wild card allows for any domain request with anything in front of .yourdomain.com.

What if you want to have multiple virtual hosts set up under two different NameVirtualHost blocks, with one being the server's main IP address and the other being for the localhost? The code would look like this:

NameVirtualHost *


ServerAdmin admin@mixfevers.com
DocumentRoot /srv/www/htdocs/
ServerAlias mixfevers.com *.mixfevers.com



ServerAdmin admin@snapnshare.com
DocumentRoot /srv/www/htdocs/snapnshare/
ServerAlias snapnshare.com *.snapnshare.com



ServerAdmin admin@boomerwebzine.com
DocumentRoot /srv/www/htdocs/~/boomer/
ServerAlias boomerwebzine.com *.boomerwebzine.com


NameVirtualHost 127.0.0.1


DocumentRoot /srv/www/htdocs/
ServerName localhost

Once you've saved the configuration file, you need to restart Apache as root in order for your change to take effect:

# /etc/init.d/apache2 restart

The setup above works well for a small company hosting multiple sites on one server, or for a hobbyist who designs sites and wants to host them. It allows you point your domains at a static or dynamic IP address, letting the server figure out what shows up for the domain.

Apache provides more information on setting up and maintaining different setups of virtual host in its documentation.

James Lees is a Web site developer who hopes to go to college for network engineering and Web development. He is a die-hard Linux user.

Get Wireless working in Ubuntu 7.04 Feisty Fawn

Non-working wireless internet is a common problem which can be easily resolved. All you need is
1 ) Ubuntu 7.04 Feisty Fawn installed ( how obvious )
2 ) Internet access - can be on another computer if not the one on which you have Ubuntu.

So lets get working!

First download the following packages
ndiswrapper-common
ndiswrapper-utils-1.9
ndisgtk

Now transfer these files to the system with Ubuntu installed - use a USB Flash Drive if you have to. Just get the files there.

Place them in the same folder and run the following commands in the terminal ( have the folder opened in it ). Change the * to the right text and run in the same order given below.

sudo dpkg -i ndiswrapper-common_*.deb
sudo dpkg -i ndiswrapper-utils-1.9_*.deb
sudo dpkg -i --force-depends ndisgtk_*.deb

When installing ndiswrapper-utils-1.9, it will ask for the Ubuntu 7.04 Feisty Fawn Install CD ( if you haven't played with the repositories ) If it doesn't ask for it, most probably you have been playing with the repositories and it will use the internet instead of the CD.
Once installed, you have to blacklist the open source bcm43xx that comes with Ubuntu. The file /etc/modprobe.d/blacklist contains the blacklisting information. Just open it in gedit with root rights.

gksudo gedit /etc/modprobe.d/blacklist

And add
to it...

blacklist bcm43xx

Now do a lspci in the terminal and find the name of your wireless card there. If you are using a USB wireless card, do a lsusb instead. Note it down because you will need it later. Like for me it says

03:00.0 Network controller: Broadcom Corporation Dell Wireless 1390 WLAN Mini-PCI Card (rev 01)

Now what you need is the windows driver for the card. Go to this page and find your card in the list(s) and get the required driver. Now you might need cabextract or unshield to get the real files from the setup. So install both of them

cabextract
unshield

Once you have the installed, open the folder where you have the setup in terminal and use the above given tools to extract it. In my case the command was...

cabextract -d drivers sp34152.exe
The "-d drivers" tells it to extract files into a new folder and call it drivers

And also do a ls *.inf in the folder where the files are extracted. It will list all files that end with a ".inf". Most probably there will be only one - note its name down. If there are more than one, go to this list again and see if it helps.

Go to System >> Administration >> Windows Wireless Drivers and press the Install New Driver button. Now browse to the folder where the files from the setup were extracted and point it to the inf file in it and you are done.

Now you just have to confirm if it installed correctly, start it and make it start at startup each time.

To confirm do a ...
ndiswrapper -l

If done right, it should say that the drivers are installed and stuff.
Now run it by...

sudo depmod -a
sudo modprobe ndiswrapper

And in the network settings, set it to "Roaming mode enabled"
Now we get it to start at startup, you have to add "ndiswrapper" to the /etc/modules file.
gksudo gedit /etc/modules

And add "ndiswrapper" to its bottom ( without quotes ), save it and restart. Enjoy wireless internet!

How-To Recover password under Ubuntu

If you forgot you password for your ubuntu system you can recover using the following steps
  • Turn your computer on.
  • Press ESC at the grub prompt.
  • Press e for edit.
  • Highlight the line that begins kernel ………, press e Go to the very end of the line, add
    rw init=/bin/bash
    press enter, then press b to boot your system.
Your system will boot up to a passwordless root shell.
Type in passwd username
Set your password
Type in
reboot

Πέμπτη 25 Οκτωβρίου 2007

Move your home directory to its own partition

There are some reasons why you may need to move your home directory to its own partition, it could be because you run out of space, or because you may want to share it with another distro in a dual Linux boot installation, well lets start.

Preparing the new partition
This may be different in your environment, in my case I will do in the same disk, just in another partition, but you can use a complete new and different disk for you /home directory.

Gparted
If you do not have gparted, install it with
sudo apt-get install gparted

the call it with:
gksudo gparted

then use gparted to create and format your new partition.
Once created and formated, it is time to move your /home

You may need to resize your / "root" partition to make enough room for your /home partition, or use another disk for it.

Moving your home directory

First logout from GNome or KDE, press Alt+F1 and login as root.
Follow this steps
mv /home /home.bak
mkdir /home
mount -t ext3 /dev/sda3 /home
cp -a /home.bak/* /home

Remember to change /dev/sda3 and ext3with your own data

We need one final step,
Open your /etc/fstab file, and add this line, in my case it is /dev/sda3 but could be different for you.
/dev/sda3 /home ext3 defaults,errors=remount-ro 0 1
It there were a line for /home in you /etc/fstab file replace it with the new data.
with this finished, just reboot your system and enter as usually.

Important note

Remember to back up before using gparted if you are resizing your disk to make room for the new partition

Convert .flv (Google Videos) to .mpg using ffmpeg

FFmpeg is a complete solution to record, convert and stream audio and video. It includes libavcodec, the leading audio/video codec library. FFmpeg is developed under Linux, but it can compiled under most operating systems, including Windows. In ubuntu This package contains the ffplay multimedia player, the ffserver streaming server and the ffmpeg audio and video encoder. They support most existing file formats (AVI, MPEG, OGG, Matroska, ASF, …) and encoding formats (MPEG, DivX, MPEG4, AC3, DV, …).

ffmpeg Features

  • ffmpeg is a command line tool to convert one video file format to another. It also supports grabbing and encoding in real time from a TV card.
  • ffserver is an HTTP (RTSP is being developped) multimedia streaming server for live broadcasts. Time shifting of live broadcast is also supported.
  • ffplay is a simple media player based on SDL and on the FFmpeg libraries.
  • libavcodec is a library containing all the FFmpeg audio/video encoders and decoders. Most codecs were developped from scratch to ensure best performances and high code reusability.
  • libavformat is a library containing parsers and generators for all common audio/video formats.

Install ffmpeg Ubuntu

sudo apt-get install ffmpeg

convert .flv to .mpg using ffmpeg

First you need to download your .flv file to a folder and you need to Open a terminal window and go in to the .flv file folder and type the following command

ffmpeg -i jokes.flv -ab 56 -ar 22050 -b 500 -s 320×240 jokes.mpg

jokes.flv is the file you want to convert, so the name must be the same as the source file.You can name jokes.mpg whatever you want as long as it has the .mpg extension.

-b bitrate: set the video bitrate in kbit/s (default = 200 kb/s)

-ab bitrate: set the audio bitrate in kbit/s (default = 64)

-ar sample rate: set the audio samplerate in Hz (default = 44100 Hz)

-s size: set frame size. The format is WxH (default 160×128 )

Load Applications Quicker in UBUNTU Using Preload

Preload is an adaptive read-ahead daemon. It monitors applications that users run, and by analyzing this data, predicts what applications users might run, and fetches those binaries and their dependencies into memory for faster startup times.

It runs as a daemon in the background so it is unobtrusive to your desktop. To install Preload open up Terminal and type in;

sudo apt-get install preload

For example, if you run Firefox, GAIM, and OpenOffice everyday Preload will determine these are common applications and will keep the libraries in your RAM before you even load them up - this leads to a faster startup time. Preload is also adaptive enough to determine if you change your working habits as well.

Preload does not need to be configured, it is adaptive and merely relies on a count of the number of times an application is launched to perform the preload.

Do not confuse Preload with Prefetch which is still under development and is expected to be part of Gutsy Gibbon in October 2007.

Nor is it to be confused with squid-prefetch which preloads web-pages.

The source article here

Using initrd

If you’ve ever looked into recompiling your Linux kernel, you’ve probably seen advice to include critical boot drivers (for your hard disk controller and root partition’s filesystem) in the kernel itself. Omitting the boot drivers is likely to result in an inability to boot the computer. The kernel loads and begins doing some checks, but then stops because it can’t read the root filesystem.

The kernels provided by most Linux distributions, however, lack the drivers for most disk hardware. These same distributions can install and boot on all of this hardware, though. How is that possible? The answer is that the kernels use an initial RAM disk (initrd for short) to hold the relevant drivers as modules. When the computer boots, the boot loader passes the initrd to the kernel, which loads it into RAM and treats it like a disk. The kernel can then load modules stored in the RAM disk, keeping the kernel size small while still providing a wide variety of drivers.

When you compile your own kernel, it’s usually easier to bypass the initrd and instead build the relevant drivers into your main kernel file. Sometimes, though, you might want to build your own initrd. Let’s see how.

Why Use initrd?

The average desktop or server system running a custom kernel doesn’t need initrd. However, it can be useful in several situations:

*Most distributions use initrd because the distributions’ designers can’t predict what hard disk controller you’ve got.

*Using initrd enables you to design a custom emergency system or specialized boot CD-R that will run on a variety of systems. This could be handy if you want to have an emergency system for use in a work environment with many different system configurations.

*If you maintain several Linux systems, you may want to custom-build a single kernel for all of them. Rather than tweak each system’s kernel for its specific hardware or build kernels with multiple sets of disk drivers, you can place the necessary drivers as modules in initrd.

*In certain embedded and specialized Linux systems, initrd may be used as the final root filesystem. This enables Linux to run on a read/write filesystem even when the only permanent storage is read-only in nature.

*Even if you don’t want to build a completely new initrd, you might want to modify the one provided by your distribution maintainer, say, to add a new or updated driver.

Getting to Know initrd

Before delving into initrd configuration, you should understand a bit about how it works.

When a Linux system boots, the computer reads a boot loader, which in the case of an x86 or x86-64 Linux system is likely to be the Linux Loader (LILO) or the Grand Unified Boot Loader (GRUB). LILO and GRUB are both very simple programs. They can read data from the hard disk using BIOS calls, so they don’t need disk drivers such as those used by the Linux kernel. Using BIOS calls, LILO or GRUB loads the Linux kernel into memory and executes it. When given appropriate options, LILO or GRUB also loads an initrd image, which is typically stored on disk in your /boot directory along with the kernel file. When the boot loader loads an initrd image, it passes its address in memory to the kernel when it starts the kernel.

Once the kernel is running, it mounts the initrd image and executes the /linuxrc or /init program on the RAM disk. (Most initrd documentation refers to /linuxrc, but some systems expect a file called /init.) This program acts something like the normal Linux startup program (/sbin/init), in that it controls what the kernel does with the initrd contents. Typically, /linuxrc or /init is a shell script that loads the drivers necessary for accessing your hard disk, swaps out the RAM disk filesystem for the root filesystem on the hard disk, releases the memory used by the RAM disk, and then continues the boot process using the hard disk’s root filesystem. In principle, this RAM disk boot script could do much more than this, but in practice additional steps are usually performed by /sbin/init on your hard disk and the programs it calls, such as SysV startup scripts. Using on-disk programs and utilities makes for easier system maintenance.

One problem with using initrd is that the RAM disk image must be maintained using utilities. You can’t just copy files in and out of a directory. In the past, initrd image files were typically filesystem images, holding ext2, romfs, or other filesystems. Today, they’re more often compressed cpio archives. As a result, the process of creating or modifying an initrd image involves extracting data from an existing image file, replacing and modifying files, and creating a new archive with your new or changed files. You can then modify your boot loader configuration to access the new files. Chances are you’ll need to reconfigure your kernel before you do any of these things, though.

Configuring Your Kernel

In most cases, the whole point of using initrd is to slim down your kernel. Therefore, you should peruse your kernel options, changing drivers you normally build into the kernel to build as modules. Typically, such options are restricted to filesystems and hard disk drivers.

Of course, you can do the same to other drivers, such as sound card drivers, network drivers, and frame buffer video drivers; however, such drivers are not typically required to boot the computer (with the exception of network drivers for network boot configurations), so you can perform such slimming even if you don’t use initrd.

One notable caveat exists: If you intend to create an initial RAM disk as a disk image file (rather than as a cpio archive file), you must build support for the filesystem you use into your kernel. You could build a RAM disk image using ext2, romfs, the Minix filesystem, or various others. Chances are ext2 would be the most convenient, but you can use your own judgment on this matter. Creating a cpio archive instead of using a conventional filesystem enables you to build all your standard filesystems as modules.

Two options that must be present in your kernel to use an initial RAM disk are the RAM Disk Support and Initial RAM Filesystem and RAM Disk (initramfs/initrd) Support options, both of which are in the “Block Devices” subsection of the Device Drivers kernel configuration area. Be sure these options are both built into the kernel itself!

Once you’re done configuring your kernel via make xconfig, make menuconfig, or similar tools, you can compile it in the normal way. Remember to install your kernel modules via make modules_install and copy your main kernel file to /boot.

Using initrd Preparation Tools

The easiest way to create an initrd is to use a preparation tool. Most distributions include a program called mkinitrd to do this job. To use it, pass it the name of the file in which you want to store your initrd image and the kernel version number you want to use:

# mkinitrd /boot/initrd-2.6.18.cpio.gz 2.6.18

This example creates an initrd image for the 2.6.18 kernel. Here, the .cpio.gz filename extension is used because this is what it really is, but most distributions give it no extension or an .img extension instead.

Although mkinitrd and similar tools (such as yaird, http://alioth.debian.org/projects/yaird/) are handy, they’re inflexible. If you want to create an unusual initrd, you’ll need to dig into the standard file and modify it.

Preparing an initrd Image from Scratch

One way to create a custom or unusual initrd is to start with a working image. You can begin with a standard initrd image or create one with mkinitrd. Locate the original file, copy it to a convenient directory, and create a subdirectory to hold the RAM disk’s extracted files. The original file is typically called /boot/initrd-* or /boot/initrd-*.img, where * is a version number and perhaps additional distribution-specific codes. Although many distributions do not include a .gz extension in their initrd filenames, these files are almost always compressed with gzip. Thus, you should rename the copy to include a .gz extension. Suppose it’s called initrd.img.gz. If the file is a cpio archive, you can uncompress it with cpio and gunzip, after changing into the working directory for your RAM disk files:

# gunzip -c ../initrd.img.gz | cpio -iv

The result should yield a copy of the files from the initrd image file you specified.

If you’re working from a disk image rather than a cpio archive, you can uncompress the copy and mount it using the loopback device, after changing into the directory that holds the initial RAM disk image file:

# gzunip ./initrd.img.gz

# mount -o loop initrd.img ./workdir

This pair of commands makes the working files available under the workdir subdirectory of the current directory. One caveat about this approach is that initial RAM disk images may contain little or no extra space for adding files. Thus, you may need to copy these files to another subdirectory, modify them there, and then create a cpio archive from your changed files. Alternatively, you could create a larger filesystem image file and copy the files there.

In either case, you can begin modifying the RAM disk’s files. Precisely how you proceed depends on what you want to accomplish, but some things you may want to do include:

*Replace kernel modules (files with the .ko extension) in the RAM disk’s lib directory with their equivalents from your newly compiled kernel, as stored in the /lib/modules/version directory tree, where version is your kernel version number.

*Add kernel modules for any drivers or filesystems you want to have available during the boot process, perhaps including proprietary or non-standard drivers.

*Modify the init or linuxrc file to perform additional tasks. You may need to add insmod lines to load new kernel modules, for instance. This startup script is normally a shell script, so you can edit it with a text editor.

*Depending on your distribution and from where you acquired your kernel source, you may need to rename the init file to linuxrc or vice-versa. To hedge your bets, create a symbolic link so that it may be called by either name.

*More ambitious changes may require you to add programs to bin, add device nodes to dev, or make more extensive changes to the startup script. If you’re creating an emergency boot system or other standalone boot CD-R, you may want to disable the last few lines of a standard initrd startup script, which pass control over to the on-disk boot partition. Instead, substitute a call to bash or some other shell.

One potentially frustrating aspect of preparing or modifying a startup script is that it can be tricky to get the order in which you load kernel modules right. You can use the modinfo command on the kernel module files to spot dependencies, which can help you figure out what needs to be loaded first (or at all).

When you’re finished making changes, you must create a new initial RAM disk file. If you’ve used a loopback device, unmount and recompress it to do the trick:

# umount ./workdir

# gzip -9 initrd.img

If you want to create a cpio archive as your initrd carrier, you can

do so with cpio and gzip:

# cd workdir

# find ./ | cpio -o -H newc | gzip -9 > ../initrd.cpio.gz

In either case, you should probably copy your new initrd image file to /boot, perhaps renaming it with an appropriate version number.

Reconfiguring Your Boot Loader

At this point, you should have a new kernel in /boot and a new initrd image in the same location. Your task now is to reconfigure your boot loader (LILO or GRUB) to use both.

If you use LILO, load the /etc/lilo.conf file into a text editor. This file contains global options followed by a series of stanzas, each of which describes one kernel or non-Linux OS. Linux stanzas begin with a line that starts with the string image= followed by the kernel’s filename. Subsequent lines in the stanza are usually indented and describe options.

Copy your current working stanza and modify the copy to point to the new kernel. Locate the line in the stanza that begins initrd= and point it to your new initrd image file. When you’re done, save your changes and type lilo at a root prompt to re-install LILO.

In the case of GRUB, edit the file called /boot/grub/grub.conf or /boot/grub/menu.lst. Locate your current boot stanza, copy it, and modify the copy to point to the new kernel and initrd image. The relevant lines begin with the strings kernel and initrd, respectively. Once you’ve made the changes, you don’t need to re-install GRUB; this boot loader reads the configuration file from disk whenever the system boots.

Rebooting to Use Your initrd Image

At this point, you should reboot your computer to test the new kernel and initrd configuration. If all goes well, your computer will start normally, providing access to all your devices. If there’s a problem, it should show up fairly early in the boot process.

The most common problem is that the kernel can’t mount a root filesystem (either the initial RAM disk or the hard disk’s root filesystem). If this happens, you’ll see a note to that effect. Read all the kernel messages on the screen; they may provide clues about what went wrong. The usual cause is a missing or out-of-place insmod call in the initrd startup script.

Once your system is working, you can tweak it. You can add drivers to your startup script to support multiple hardware configurations, or create separate startup scripts and RAM disk images to support these configurations. Attempting to load a driver for a nonexistent device is normally not a problem, so you may be able to get by with a single RAM disk image for multiple hardware configurations. Because the kernel releases the initrd memory when it switches to the hard disk root partition, there’s no memory penalty for providing a big RAM disk with lots of drivers.

How to test your firewall

The firewall is our gateway to the Internet. It is a piece of software or hardware that manages Internet connections to and from your computer. It monitors the applications that try to initiate connection with your computer from the Internet, and it controls which programs are allowed to use the Internet.

Nowadays, Internet users are exposed to several kinds of Internet threats, such as software vulnerabilities, automated worms, viruses and random Internet attackers. Properly configured personal firewalls are the first line of defense to answer these threats.

But how do you test your personal firewall? Security researchers have developed small, non-destructive, leak testers, that deliberately attempt to test different firewall capabilities. The idea behind them is simple: if the test can bypass your computer’s security, then so can a hacker.

There are many leak-testing programs available. Each one designed to test a particular flaw and each using a particular technique to bypass a firewall’s standard protection mechanisms. We’ve compiled a list of tools we believe will be of value to both home users and advance users.

  1. PCFlank Leaktest - PCFlank Leaktest is a small utility that tests any firewall’s ability to protect against unauthorized or illegal transmissions of data from a user’s computer that is connected to the Internet. It uses a special technique to impersonate another program, which your firewall has been set to trust. Get PCFlank Leaktest here.
  2. Breakout - Breakout sends to the IE’s or Firefox’s address bar the URL to launch, via the ‘SendMessage’ Windows API. No code is injected. Usually very hard to detect by firewalls. If the test is a success, this means that your firewall does not check for the ‘messages’ sent to your applications windows. Get BreakOut here for IE / Firefox.
  3. DNSTester - Starting from Windows 2000, a Windows service DNS client is running and handles all DNS requests. Thus, all DNS requests coming from various applications will be transmitted to the DNS client which will, itself, do the DNS request. This feature can be used to transmit data to a remote computer by crafting a special DNS request without the firewalls notice it. DNStester uses this kind of DNS recursive request to bypass your firewall. Get DNSTester here.
  4. MBTest - MBtest send packets directly to the network interface to try to bypass firewall. To do this, it sends differents kind of packet of different size/protocoles/type. If the test is a success, this means that your firewall is stuck in high level network and doesn’t check low level. Get MBTest here.
  5. Atelier Web Firewall Tester - AWFT probes the protection provided by your Personal Firewall software using six different tests. Each test uses a different technique for gaining access to the outside world. Techniques are differently rated, according to their sophistication, and your Personal Firewall is doing a great job if is able to score 10 points in total. Get Atelier Web Firewall Tester here.
  6. ZABypass - Originaly was developed to bypass old versions of ZoneAlarm, but it may work against many other firewalls today. It uses a special technique called Direct Data Exchange to transfer data between Internet Explorer and the Internet. Get ZABypass here.
  7. FireHole - FireHole attempts to launch the default web browser, inject its own DLL and try to establish a connection to the Internet. Get FireHole here.
  8. Thermite - Thermite injects it’s code into the target process directly, by creating an additional malicious thread within that process. If the test is a success, this means that your firewall is vulnerable to process injection. Get Thermite here.

Leak tests are designed to help identify security flaws and provide the invaluable function of informing the user whether or not their firewall is providing adequate protection. Unfortunately, malware programs are evolving rapidly. Many of such programs (will) have very advanced techniques to conceal their malicious activities so that they easily bypass firewalls and other protection mechanisms.

Edit: Matousec has a list of tested personal firewalls and their final score.

Mounting file-systems by label rather than device name

When you're dealing with multiple drives, both fixed and removable, it can get hard to remember which is which. Remembering to mount /dev/sda1 in one place and /dev/sdc5 in another. The solution to this problem is to use labels instead of partition names when referring to them, and here we'll show how that can be done.

There are two things you need to do to start using labels:

  • Add the label to your filesystem(s), or more properly partitions.
  • Use the names rather than anything else to refer to your partitions.

To add a label you must use the tune2fs command, specifying the partition to modify and the label to add.

Upon my home system I have only a single disk /dev/sda which has three partitions:

    Name        Flags           Size (MB)
-------------------------------------------
sda1 Linux ext3 20003.89
sda2 swap 3002.23
sda3 Linux LVM 297064.22

(Irony is .. my main disk drive died between the writing and publication of this article. Shortly I will be moving to a RAID-based system.)

To add the label "root" to my root partition, /dev/sda1, I'd run:

root@mine:~# tune2fs -Lroot /dev/sda1

Once I've got a label in place it becomes visible in my partition list when I run "cfdisk /dev/sda", so I know it has worked.

Once the label has been put into place there are now two places which I need to update the system in order to use it:

  • /etc/fstab
    • This file lists the partitions/file-systems which should be mounted at boot-time
  • /boot/grub/menu.lst
    • This file configures my boot-loader so that the system will boot.

In both cases the change is the same, instead of specifying /dev/sda1 I specify LABEL=root.

My /etc/fstab file now looks like this:

#
# /etc/fstab - static file system information.
#
LABEL=root / ext3 defaults,errors=remount-ro 0 1
/dev/sda2 none swap sw 0 0
...
...

The grub configuration file was updated to change:

# kopt=root=/dev/sda1 ro acpi=off noapic

into this:

# kopt=root=LABEL=root ro acpi=off noapic

Once this was done the kernel(s) can be updated by running update-grub. This updated my Xen kernels and my Debian kernels to include the new root - for example:

title           Xen 3.0.3-1-amd64 / Debian GNU/Linux, kernel 2.6.18-4-xen-amd64
root (hd0,0)
kernel /boot/xen-3.0.3-1-amd64.gz
module /boot/vmlinuz-2.6.18-4-xen-amd64 root=LABEL=root ro acpi=off noapic console=tty0
module /boot/initrd.img-2.6.18-4-xen-amd64
savedefault

The advantage of doing this is that I can now use identical configuration files upon each of my hosts, and rely upon the labels to make sure the correct partition is used as my root filesystem. This is very useful when you're configuring your systems via CFEngine, or similar.

How to backup mysql using php, and shell script, the easy way

As I was trying to find an easy way to backup a MySQL database with no ssh access to the server, there should be better ways, but i found this easy one. You will need a Shell script, a .php script. Ok, lets make this work
First create a shell script with this line
mysqldump --opt -u [user_name] -p [database_name] | gzip>[backup_file].dump.gz
and name it, lets say:
the_backup_script.sh
Now create the .php script that will call the shell script.
It will contain this:
<?php
echo exec('./the_back_script.sh');
?>
and name it, for instance
the_backup_php_script.php
Until this point this should work, just copy the two files using your ftp account in the root directory of your site.
Here comes the security issue, nobody wants that somebody discover this file and can get all you mysql database, so you have some options.
1. Create a complete server based security like shown here: http://www.pagetutor.com/keeper/http_authentication.html
2. Erase the files from your server once used, and upload them each time you may need to do a backup.

Howto Convert a .nrg (Nero) file to a .iso file in Debian

If you want to convert .nrg file to .iso file you can use nrg2iso tool to create this.
nrg2iso is a program that extracts ISO9660 data from Nero “.nrg” CD-ROM image files.


Install nrg2iso in Debian







#apt-get install nrg2iso



Using nrg2iso
Usage







nrg2iso [nrg-file] [iso-file]


Example
nrg2iso image.nrg image.iso


Now you can burn your iso with your preferred linux burning app.

Hacking Firefox: The secrets of about:config

Ever since its debut, Firefox has garnered a reputation for being an enormously customizable program, both through its add-on architecture and its internal settings. In fact, many of Firefox's settings aren't exposed through the Tools > Options menu; the only way to change them is to edit them manually. In this article, we'll explore some of the most useful Firefox settings that you can change on your own and that aren't normally available through the program's graphical interface.

The closest analogy to how Firefox manages its internal settings is the Windows Registry. Each setting, or preference, is given a name and stored as a string (text), integer (number) or Boolean (true/false) value. However, Firefox doesn't keep its settings in the registry, but in a file called prefs.js. You can edit prefs.js directly, but it's often easier to change the settings through the browser window.

Type about:config in the address bar and press Enter, and you'll see all the settings currently enumerated in prefs.js, listed in alphabetical order. To narrow down the hundreds of configuration preferences to just the few you need, type a search term into the Filter: bar. (Click the Show All button or just clear the Filter: bar to get the full list back again.)

The about:config page.

The about:config page. (Click for larger view.)

To edit a preference, double-click on the name and you'll be prompted for the new value. If you double-click on an entry that has a Boolean value, it'll just switch from true to false or vice versa; double-click again to revert to the original setting. Not all changes take effect immediately, so if you want to be absolutely certain a given change is in effect, be sure to close and reopen Firefox after making a change.

Editing a preference.

Editing a preference. (Click for larger view.)

Note that not every setting in about:config exists by default. Some of them have to be created manually. If you want to add a new preference, right-click somewhere on the page and select New, then select the type of item to create (String, Integer or Boolean) and supply the name and value.

Before you begin

Here are a few caveats to keep in mind as you explore and tweak:

Not everyone will get the same benefits by enabling these tweaks. This is especially true for changing the network settings. If you habitually visit sites that don't allow a large number of connections per client, for instance, you won't see much benefit from raising the number of connections per server.

Some hacks may have a limited shelf life. With each successive release of Firefox, the need for tweaking any of the performance-related config settings (like the network settings) may dwindle as Firefox becomes more self-tuning based on feedback from real-world usage scenarios. In short, what works now may not always work in the future -- and that might not be a bad thing.

Keep a log of everything you change, or make backups. If you tweak something now and notice bizarre activity in a week, you'll want to be able to track back to what was altered and undo it. Firefox does show which about:config changes have been set manually, but this isn't always the most accurate way to find out what you changed.

To make a backup of your preferences in Firefox, just make a copy of the file prefs.js, which is kept in your Firefox profile folder. If you mess something up, you can always copy this file back in. (Be sure to shut down Firefox before making a copy of prefs.js or moving a copy back into the profile folder!)

In Windows XP, the profile folder is
\Documents and Settings\\Application Data\Mozilla\Firefox\Profiles\.default\

In Windows Vista, this folder is
\Users\\AppData\Roaming\Mozilla\Firefox\Profiles\.default\

Note that Application Data and AppData are hidden folders by default, so they may not show up unless you force Explorer to show hidden objects. (Open the Control Panel, double-click Folder Options, select the View tab, select "Show hidden files and folders" and click OK.)

In Mac OS X, the profile folder is
/Library/Application Support/Firefox/Profiles/.default/

and in Linux it's
~/.mozilla/firefox/.default/

but on those platforms it's usually quicker simply to search for prefs.js.

Alternatively, you can use the handy Firefox Extension Backup Extension (FEBE). It backs up not only the prefs.js file but just about every other thing in Firefox -- extensions, themes, cookies, form history and so on.

Speed up page display

Some of the more recent Firefox customizations I've examined are ways to speed up the rendering of Web pages. The settings to do this are a little arcane and not terribly self-explanatory, but with a little tinkering, you can often get pages to pop up faster and waste less time redrawing themselves.

Start rendering pages faster
Creating an nglayout.initialpaint.delay integer preference lets you control how long Firefox waits before starting to render a page. If this value isn't set, Firefox defaults to 250 milliseconds, or 0.25 of a second. Some people report that setting it to 0 -- i.e., forcing Firefox to begin rendering immediately -- causes almost all pages to show up faster. Values as high as 50 are also pretty snappy.

Reduce the number of reflows
When Firefox is actively loading a page, it periodically reformats or "reflows" the page as it loads, based on what data has been received. Create a content.notify.interval integer preference to control the minimum number of microseconds (millionths of a second) that elapse between reflows. If it's not explicitly set, it defaults to 120000 (0.12 of a second).

Too many reflows may make the browser feel sluggish, so you can increase the interval between reflows by raising this to 500000 (500,000, or 1/2 second) or even to 1000000 (1 million, or 1 second). If you set this value, be sure to also create a Boolean value called content.notify.ontimer and set it to true.

A page

A page "reflowing" while loading in Firefox.

Control Firefox's 'unresponsive' time
When rendering a page, Firefox periodically runs a little faster internally to speed up the rendering process (a method Mozilla calls "tokenizing"), but at the expense of being unresponsive to user input for that length of time. If you want to set the maximum length of time any one of these unresponsive periods can be, create an integer preference called content.max.tokenizing.time.

Set this to a multiple of content.notify.interval's value, or even the same value (but higher is probably better). If you set this to something lower than content.notify.interval, the browser may respond more often to user input while pages are being rendered, but the page itself will render that much more slowly.

If you set a value for content.max.tokenizing.time, you also need to create two more Boolean values -- content.notify.ontimer and content.interrupt.parsing -- and set them both to true.

Control Firefox's 'highly responsive' time
If Firefox is rendering a page and the user performs some kind of command, like scrolling through a still-loading page, Firefox will remain more responsive to user input for a period of time. To control how long this interval is, create an integer preference called content.switch.threshold.

This is normally triple the value of content.notify.interval, but I typically set it to be the same as that value. Set it to something very low -- say, 10000 (10,000 microseconds) -- and the browser may not respond as snappily, but it may cause the rendering to complete more quickly.

If you haven't already created the Boolean values content.notify.ontimer and content.interrupt.parsing and set them both to true in conjunction with content.max.tokenizing.time, you'll need to do so to make content.switch.threshold work properly.

If you are more inclined to wait for a page to finish loading before attempting to do anything with it (like scroll through it), you can set content.max.tokenizing.time to a higher value and content.switch.threshold to a lower value to allow Firefox to finish rendering a page faster at the expense of processing user commands. On the other hand, if you're the kind of person who likes to scroll through a page and start reading it before it's done loading, you can set content.max.tokenizing.time to a lower value and content.switch.threshold to a higher one, to give you back that much more responsiveness at the cost of page-rendering speed.

Have tabbed browsing your way

Right from the start, one of Firefox's strengths has been tabbed browsing. But if the tabs don't behave quite the way you want them to by default, or you hate the way the default behaviors have changed since Firefox 1.x, the following changes will bring them in line.

Corral close buttons
The integer preference browser.tabs.closeButtons controls how the close buttons (the "X" icons) are rendered on tabs:

0: Display a close button only on the currently active tab. This is a nice way to keep from accidentally smacking into a close button for the wrong tab.

(You can press Ctrl-F4 to close only the current tab, but many mouse-centric people never bother to do this.)

1: Display close buttons on all tabs (default).

2: Don't display any close buttons; the only way to close a tab is by pressing Ctrl-F4.

3: Display one close button at the end of the tab bar (Firefox 1.x's default).

A close button on just one tab.

A close button on just one tab. (Click for larger view.)

Open search results in a new tab
This one is a favorite of mine. When browser.search.openintab (a Boolean preference) is set to true, any searches launched from the Search tool bar are opened in a new tab instead of overwriting the contents of the current one. I can't tell you the number of times I mistakenly wiped out my current page before I started using this.

Note that if you launch a new browser window with Ctrl-N and perform a search there, you'll see the search results and the default home page for the new browser instance loading in separate tabs.

Open bookmark groups in new tabs
If you open a group of bookmarks at once, Firefox's default behavior is to replace any existing tabs with the newly opened pages. Set browser.tabs.loadFolderAndReplace (Boolean) to false, and opening groups of bookmarks will append new tabs to the existing window instead of overwriting existing ones.

Squeeze more tabs into the tab bar
The integer preference browser.tabs.tabMinWidth controls how narrow, in pixels, tabs can be shrunk down before scroll arrows appear on the left and right edges of the tab bar.

The default is 100, but you can set this to something smaller so you can fit more tabs in the bar at once. Note, however, that you might find the shortened titles harder to read.

Before

After

The tab bar before and after reducing the minimum tab width. (Click for larger view.)

In the same vein, the integer preference browser.tabs.tabClipWidth sets the minimum width, in pixels, that a tab must be in order to show a close button. This is 140 by default, so if you set this to something lower, you'll see more tabs with close buttons when the tab bar is heavily populated.

Make the user interface behave

Another big reason people hack Firefox's settings is to modify the user interface -- either to make it a little easier to do something, or to revert to a behavior that was prevalent in Version 1.x but changed in 2.0.

Get case-sensitive, in-page searches
The integer preference accessibility.typeaheadfind.casesensitive controls how Firefox's "Find as You Type" feature behaves. The default is 0 for case-insensitive searches; set it to 1 for case-sensitive matching.

Control address bar searches
You may have noticed that if you type something into Firefox's address bar that's not an address (a "keyword"), Firefox typically passes it on to Google as an "I'm Feeling Lucky" search term. The exact search engine string to use is defined in the string preference keyword.URL; if you want to change it to something else, you can simply edit this string.

For instance, to make Microsoft's Live.com the default keyword search, set this string to
http://search.live.com/results.aspx?q=

For a Yahoo search, it would be
http://search.yahoo.com/search?p=

If you want to restore the default search, use
http://www.google.com/search?ie=UTF-8&oe=
UTF-8&sourceid=navclient&gfns=1&q=

Finally, if you want to turn this address-bar keyword functionality off altogether, set the Boolean preference keyword.enabled to false.

Note that with Google, the more generic the keyword, the less likely it is to be used as an "I'm Feeling Lucky" search -- although what constitutes "generic" isn't always clear. For instance, typing "clean" into the address bar returns a generic Google search page, but "sideways" takes me to the Internet Movie Database entry for the movie of that name (the "I'm Feeling Lucky" result). Your mileage will almost certainly vary.

Select just a word
The Boolean preference layout.word_select.eat_space_to_next_word governs one of Firefox's tiny, but for me incredibly annoying, little behaviors. When you double-click on a word in a Web page to select it, Firefox automatically includes the space after the word. Most of the time I don't want that; I just want the selection to stop at the end of the word. Setting this to false will defeat that behavior.

Select a word and its punctuation
Somewhat contrarily, if you double-click a word that's next to any kind of punctuation mark, Firefox defaults to selecting only the word itself, not its adjacent punctuation. Set the Boolean preference layout.word_select.stop_at_punctuation to false to select the word and its adjacent punctuation.

Get Alt-hotkey shortcuts back
One minor change in Firefox 2 was the way in which form elements on a Web page had hotkey bindings assigned to them. In Firefox 1.x, when a Web page assigned a hotkey to a form element, you pressed Alt-hotkey to access it. In Version 2.x, this was changed to Alt-Shift-hotkey. To revert to the original 1.x behavior, set the integer preference ui.key.contentAccess to 4. This is useful if you have, for instance, a Web-based interface you spend a lot of time in, and use Alt-key bindings to do things quickly in that particular page.

Note that one possible consequence of setting this back to the old behavior is that Alt-key bindings on a Web page can now override the default key sequences for the program itself (such as Alt-S for History), but you can always get around this by tapping Alt to activate the menu and then tapping the program hotkey in question.

Change scrollbar behavior
By default, clicking in the empty areas of the Firefox window's scrollbar will simply cause the view to move up or down one page. You can change this behavior by creating a Boolean preference called ui.scrollToClick and setting its value to true. Now clicking in a scrollbar will cause the view to jump directly to that point in the page (basically the same as dragging the scrollbar to that position).

Get click-and-hold context menus back (for Macs only)
If you want to restore the classic click-and-hold context-menu behavior on the Macintosh, edit or create the Boolean preference ui.click_hold_context_menus and set it to true.

Hack network connections

The very first batch of Firefox hacks I learned about was how to override its network defaults. Some of Firefox's out-of-the-box settings for how it deals with network connections are fairly conservative, probably because Firefox has no way of knowing what kind of network it's using (dial-up vs. broadband, etc.). If you have a network that readily supports multiple simultaneous connections, you can make a number of changes to Firefox to take advantage of that.

But proceed with caution. If Firefox's network settings are set too aggressively, they can lead you to being blacklisted for a short time by a given remote server. And you should certainly get permission from the IT department before attempting this kind of hack in a corporate environment. Regardless, moderation is the key. For the most part, I find that setting the network settings to absurdly high numbers does not accomplish much of anything; it helps to ramp them up a bit, but generally not much more than that.

Maximize connections to multiple servers
The integer preference network.http.max-connections controls how many simultaneous network connections Firefox will make at any one time to any number of Web servers. One typical way this pays off is if you have Firefox set to load multiple home pages in different tabs at once, or if you access pages that aggregate contents from several different servers (for instance, multiple advertising systems).

By default, this is set to 24, which should work well for most network connections, but you can raise it to 32 and see if that has any effect. (I've seen people raise this as high as 64, but anything above 32 doesn't seem to provide much discernible payoff.)

Maximize connections to the same server
The integer preference network.http.max-connections-per-server controls how many separate connections Firefox makes to the same server, which allows multiple elements in a page to be downloaded in parallel. Normally, this is set to 8, but some people choose to set it as high as 16.

Note, however, that some Web servers will block you if you try to establish more than 8 inbound connections, typically as a bandwidth-protection or antileeching measure -- this is the kind of behavior also exhibited by download managers that try to use as many "slots" as possible to speed things up, and many server admins hate that sort of thing. Also, if you're on a connection that's not fast to begin with (e.g., slow ISDN or dial-up), changing this setting will have no discernible effect, and may in fact slow things down.

Bump up persistent connections per server
Firefox keeps persistent connections to a server "alive" to improve performance: Instead of simply sending the results of one request and then closing, they're held open so that multiple requests can pass back and forth. This means a little less network traffic overall, since a connection to a given server has to be set up only once, instead of once for each separate piece of content; it also means successive connections to the same server go through faster.

The integer preference network.http.max-persistent-connections-per-server controls the number of persistent connections allowed per server. By default, this is set to 2, although some servers will honor a higher number of persistent connections (for instance, if there's a lot of content from their site that loads in parallel, like images or the contents of frames). You probably only want to go as high as 8 with this; more than that may cause a server to temporarily blacklist your IP address depending on how it's configured. (If you're going through a proxy defined by Firefox, use network.http.max-persistent-connections-per-proxy instead of this setting.)

Reduce the interval between persistent connections
If you've already used up all the persistent server connections described in the above setting and Firefox needs to make more connections, the integer setting network.http.request.max-start-delay governs how long to wait before attempting to open new connections. This helps if Firefox's persistent-connection limit has been used up by a number of long downloads, and the browser needs to queue a shorter download on top of that.

Most people set this to 0 (in seconds), with the default being 10. Note that this does not override connection limits imposed by remote hosts, so its usefulness is limited by the whim of the server you're connecting to.

Turn on pipelining
The Boolean preference network.http.pipelining enables an experimental acceleration technique called "pipelining," which speeds up the loading of most Web pages. A browser normally waits for some acknowledgment of a given request from a server before attempting to send another one to that server; pipelining sends multiple requests at once without waiting for responses one at a time.

If you turn this on (that is, set its value to true), also be sure to create or edit the integer preference network.http.pipelining.maxrequests, which controls the maximum number of requests that can be pipelined at once. 16 should do it; some people go as high as 128 but there's not much evidence it'll help. (If you use a proxy, set network.http.proxy.pipelining to true as well.)

Note that not every Web server honors pipelining requests correctly, which is why this feature is turned off by default and still considered experimental. Some sites may behave strangely if you submit pipelined requests.

Stop memory hogging

The default way the Windows version of Firefox consumes memory can be alarming if you don't know what's really going on. People routinely report a memory "footprint" of 75MB to 100MB or more with only a few windows or tabs open, and they assume a memory leak is to blame. While earlier versions of Firefox did have memory leak bugs, they're not the reason for this kind of memory consumption in Firefox 2.x.

Here's what's happening: Firefox caches recently used objects -- Web pages, images -- in memory so that they can be re-rendered on-screen quickly, which drives up memory usage. The following tweaks can make Firefox stake out memory less aggressively. (Note, however, that lightening the memory load might make your pages load a bit more slowly than you're used to.)

Reduce graphics caching
When the Boolean preference browser.cache.memory.enable is enabled (the default), Firefox keeps copies of all graphical elements from the current browsing session in memory for faster rendering. You can set this to false to free up more memory, but pages in your history will reload less quickly when you revisit them.

Another option: Set the value to true and create a new integer preference called browser.cache.memory.capacity. Then specify, in kilobytes, how much memory to set aside for graphics caching. That way you get some of the speed benefits that graphics caching provides without taking a huge memory hit. If you use -1 as the memory value, Firefox will size the memory cache based on how much physical RAM is present.

Reduce Web page caching
Firefox caches several recently visited Web pages in memory so they don't have to be regenerated when you press Back or Forward. The integer setting browser.sessionhistory.max_total_viewers determines how many individual Web pages to store in the back/forward cache; each page takes about 4MB (or 4,000KB) of RAM.

By default, however, this value is set to -1, which determines how many pages to cache from the amount of available physical memory; the maximum number of pages stored when you use -1 is 8. Set this value to 0 to disable page caching entirely. That will save some memory, but will also cause Back and Forward navigation to slow down a bit.

Note that this caching is not the same as browser.cache.memory.enable: That setting is for rendering elements on pages like graphics and buttons, and the contents of https-encoded pages, while this setting is for caching the text content of Web pages that have already been rendered or "tokenized."

Swap out to disk memory when minimized (Windows only)
A little-known feature in Firefox allows the Windows memory manager to swap out some of Firefox's physical memory space to disk when Firefox is minimized but not closed. This allows other programs to use the physical memory that Firefox was previously monopolizing.


With config.trim_on_minimize.

Without config.trim_on_minimize.

Firefox's minimized memory usage with (top) and without (bottom) config.trim_on_minimize. (Click for larger view.)

By default, this feature is turned off, for two reasons: 1) PC memory is generally more plentiful than it used to be, so it makes sense to use it if it's available, and 2) swapping Firefox's memory out to disk will slow the program down when it's restored.

That said, if you run Firefox side by side with other memory-hungry applications, it might help keep them from competing with each other. To enable this feature, create a new Boolean preference called config.trim_on_minimize and set its value to true.


Got your own about:config tweaks to share? Add them to the Comments area at the bottom of the page. If you've got the itch to learn more about about:config settings, MozillaZine's about:config entries wiki is a great source of information.


Serdar Yegulalp writes about Windows and related technologies for a number of different publications, including his own Windows Insight blog.

Backing up MySQL data


Backing up files and directories is relatively easy; databases, however, have some special quirks that you need to address. Our examples use MySQL, but the same principles apply to PostgreSQL and other relational databases.
This article is excerpted from O'Reilly's recently published book Linux System Administration.
If your MySQL server does not need to be available 24x7, a fast and easy offline raw backup method is:



  • Stop the MySQL server:










# /etc/init.d/mysqld stop




  • Copy MySQL's data files and directories. For example, if your MySQL data directory is /var/lib/mysql and you want to save it to /tmp/mysql-backup:









# cp -r /var/lib/mysql /tmp/mysql-backup




Instead of cp, you can use rsync, tar, gzip, or other commands.



  • Start the server again:








# /etc/init.d/mysqld start



Online backups are trickier. If you have mutually independent MyISAM tables (no foreign keys or transactions), you could lock each one in turn, copy its files, and unlock it. But you may have InnoDB tables, or someone could write a transaction involving multiple tables. Fortunately there are several reasonable noncommercial solutions, including mysqlhotcopy, mysqlsnapshot, replication, and mysqldump.


mysqlhotcopy is a Perl script that does online raw backups of ISAM or MyISAM tables. The manpage includes many options, but here's how to back up a single database named drupal:



# mysqlhotcopy -u user -p password drupal /tmp
Locked 57 tables in 0 seconds.
Flushed tables ('drupal'.'access', 'drupal'.'accesslog', 'drupal'.'aggregator_
category', 'drupal'.'aggregator_category_feed', 'drupal'.'aggregator_category_item',
'drupal'.'aggregator_feed', 'drupal'.'aggregator_item', 'drupal'.'authmap', 'drupal'.
'blocks', 'drupal'.'book', 'drupal'.'boxes', 'drupal'.'cache', 'drupal'.'client',
'drupal'.'client_system', 'drupal'.'comments', 'drupal'.'contact', 'drupal'.'file_
revisions', 'drupal'.'files', 'drupal'.'filter_formats', 'drupal'.'filters',
'drupal'.'flood', 'drupal'.'forum', 'drupal'.'history', 'drupal'.'locales_meta',
'drupal'.'locales_source', 'drupal'.'locales_target', 'drupal'.'menu', 'drupal'.
'node', 'drupal'.'node_access', 'drupal'.'node_comment_statistics', 'drupal'.'node_
counter', 'drupal'.'node_revisions', 'drupal'.'permission', 'drupal'.'poll',
'drupal'.'poll_choices', 'drupal'.'poll_votes', 'drupal'.'profile_fields', 'drupal'.
'profile_values', 'drupal'.'role', 'drupal'.'search_dataset', 'drupal'.'search_
index', 'drupal'.'search_total', 'drupal'.'sequences', 'drupal'.'sessions', 'drupal'.
'system', 'drupal'.'term_data', 'drupal'.'term_hierarchy', 'drupal'.'term_node',
'drupal'.'term_relation', 'drupal'.'term_synonym', 'drupal'.'url_alias', 'drupal'.
'users', 'drupal'.'users_roles', 'drupal'.'variable', 'drupal'.'vocabulary',
'drupal'.'vocabulary_node_types', 'drupal'.'watchdog') in 0 seconds.
Copying 171 files...
Copying indices for 0 files...
Unlocked tables.
mysqlhotcopy copied 57 tables (171 files) in 1 second (1 seconds overall).


mysqlsnapshot is even easier. It backs up all the ISAM or MyISAM tables on your server to one tar file per database:



# ./mysqlsnapshot -u user -p password -s /tmp --split -n
checking for binary logging... ok
backing up db drupal... done
backing up db mysql... done
backing up db test... done
snapshot completed in /tmp


If you've set up MySQL replication for 24x7 availability, you can back up from a slave server using one of the methods just decribed. You'll also need to save replication info (logs, configuration files, and so on).


For extra protection from hardware corruption (but not human error), set up replication and provide your slave (and/or master) with RAID 1 (mirrored) disks.


Many MySQL sites migrate data from MyISAM to InnoDB tables to get true database transactions and better write performance. The authors of the InnoDB module have a commercial product for online InnoDB backups named InnoDB Hot Backup.


The last method is usually the first mentioned in most documentation: mysqldump. Rather than a raw (verbatim) copy, mysqldump produces an ASCII dump of the specified databases and tables. It works with all MySQL table types, including InnoDB. It's relatively slow, and the text files it produces are large, although they compress fairly well. It's useful to create these dumps from time to time, because they contain a straightforward script for recreating your databases and tables from scratch. You can use editors, grep, and other text tools to search through or modify the dump files.


To lock all of your tables and dump them to a single file, enter:


# mysqldump -u user -ppassword -x --all-databases > /tmp/mysql.dump


You can pipe the output through gzip to save some time and space:


# mysqldump -u user -ppassword -x --all-databases | gzip > / tmp/mysql.dump.gz


A new open source tool (free download, pay for support) called Zmanda Recovery Manager for MySQLprovides a useful front end to many of these alternatives. Notable features:




  • Has a command-line interface.




  • Backs up local databases, or remote databases over SSL.




  • Emails the status of the backup procedure.




  • Handles all table types, including InnoDB.




  • Does not provide any new backup methods. Instead, it chooses among mysqldump, mysqlhotcopy, MySQL replication, or LVM snapshots.




  • Supports recovery to a particular transaction or point in time.




Zmanda provides .tar.gz and .rpm files for many Linux distributions. For an installation how-to for Debian, see HowtoForge.