Restore Settings on a Broken Firefox
When people have a problem with Firefox I’ve seen many people will resort to deleting their old profile (or folder) and creating a new one. This works, but doing this though will get rid of any passwords, history, bookmarks… you may have. I recently deleted the Microsoft fonts on my installation and Firefox began to display alot of site with monospace – thought I was still in vim :). Having used Firefox quite a bit, getting a new profile was a good idea anyhow as cruft and buggy configs can slow down the browsing experience.
Details
First you’ll need to get to your Firefox configs:
cd ~/.mozilla/firefox/
Backup your old profile and profile list:
mv xxxxxxxx.default{,.bck}
mv profiles.ini{,.bck}
Create a new profile:
firefox -CreateProfile <profilename>
This command will tell you the name of the new folder. Copy important information to the new profile:
cd *.default.bck cp places.sqlite key3.db formhistory.sqlite signons3.txt persdict.dat content-prefs.sqlite ../*.<profilename>
This will transfer your bookmarks, browsing history, form entries, passwords, personal dictonary changes, and page zooms. There might be a couple other things you’d like to add (possibly your firefox preferences), take a look at Transferring data to a new profile.
Keyboard Template
I needed a keyboard template and I couldn’t find any so I made one (uh kinda). The outline was made by aphasia100stock:
Notes
- Converted from .ai format to .svg
- Removed inner borders
- Added Letters, Numbers, Symbols
- Added guidelines to be able to reference keys.
Thanks aphasia100stock for the outline.
Enjoy!
Getting Help from Console
If you’re in console (aka virtual console) doing an install or repairs on a system, it’s good to know how to get help if problems occur.
“Ground Control…”
To get help in console you can use a chat client. Read this page on how to set up irssi – a terminal/console IRC program. The guide will walk you through setting up irssi and connecting to freenode where many Linux distribution chat channels are located.
“Waiting for details, Houston…”
When you tell the people in the chat-room what your problem is, sometimes they will need to know additional information. This could be the output of a command or the contents of a configuration file. To do a command without leaving irssi do Ctrl+Alt+F2 (F3, F4… can also be used) to enter another console, then enter the command.
Be better not to have to write everything down on a notepad and then type it into irssi, this is where it becomes useful to use a collaborative debugging tool like pastebin. Pastebin is a website that temporarily holds configurations, bug outputs… that you can refer other people to get help. There are several tools that can be used from the command line that can send files to a pastebin service, for example pastebinit. Add pastebinit from your distro, then upload a file. For example, your xorg.conf file:
For uploading the output of a command, first you have to put it into a file:
&> will redirect all output to a text file (both standard output and error output) and now it can be uploaded.
“I have visual…”
Occasionally you might need to actually show a picture of what your question is about (e.g. if you have a question about a console-based installer). For this you can use fbshot. fbshot is a framebuffer screenshot program. To take a screenshot of the first console (Ctrl+Alt+F1):
Then you can use links and a image-hosting website to upload the image.
Customizable LiveUSB
If you ever have an emergency and need a rescue disk to recover your Linux install, or maybe you just want to brag to your friends there’s some good LiveCD/USB’s out there and many distro’s now make LiveUSB install images, but it is also possible to create your own customizable LiveUSB. Hey, if you’re willing to put the time in, you can have a portable Linux in your pocket.
There’s alot of articles about creating your own custom CD/LiveUSB but many of them seemed dramatic involving messing with things like syslinux… Plus many of these create a fixed image, meaning that once it’s on your USB it can’t be changed. But having a customizable Linux on a USB flashdrive isn’t that difficult – just install Linux to the USB drive.
Partition the USB Drive
The first thing you’ll need is at least a 2GB flash drive. Anything less and you better plan a real basic install. First thing you might like to do is partition the flash drive. This isn’t necessary but I was pretty sure I wouldn’t need the 4GB for what I needed so I partitioned the flash drive to have a 1GB FAT32 partition first (so that Vista can see any files I put on it) then I partitioned the remaining 3GB as ext4 with kparted (there’s also gparted for gnome users).
Install via VirtualBox
No need to burn an ISO and reboot, use VirtualBox and do it from your desktop. You can follow my Testdrive a LiveCD with VirtualBox post to getting VirtualBox setup. I personally used Arch Linux for this install because it’s easy to configure, Gentoo should work well too, and Ubuntu looks to be easy.
Make sure your user is part of the VirtualBox group to enable usb recognition:
Boot the LiveCD/USB iso/img in VirtualBox then in Devices > USB devices select your flash drive. Now the installer will recognize your flash drive. Proceed to install the distro on the flash drive. If you partitioned beforehand you can skip partitioning and go to setting Filesystem Mountpoints. When you reach GRUB setup be sure to install GRUB on the flash drive itself, for me it was /dev/sdb. Be sure NOT to install GRUB to a partition, it should be at the beginning of the drive.
Fix Grub
Because your BIOS is likely setup to recognize your hard drive before your USB drive you get drive denominations like /dev/sda for your hard disk and /dev/sdb for your flash drive on regular bootup. If booting from a flash drive, many BIOS’s have you enter a key (mine is F10) to get to a Boot Menu. So when you select your flash drive in your BIOS Boot Menu your flash drive now becomes /dev/sda, hard drive /dev/sdb. In grub terminology this is hd0 and hd1. Most BIOS’s are like this (though there a few exceptions). To know for sure you won’t be able to detect this until you try and boot your flash drive (more below).
Close VirtualBox and open your GRUB menu list and change to the first recognized drive:
vim /mnt/usb/boot/grub/menu.lst
or however you edit your system files. Then change:
title Arch Linux
root (hd1,1)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/34393cdf-9f39-431e-88c8-ea89a2518c83 ro
initrd /boot/kernel26.img
to:
title Arch Linux
root (hd0,1)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/34393cdf-9f39-431e-88c8-ea89a2518c83 ro
initrd /boot/kernel26.img
The (hd0,1) value denotes the partition number, again starting with 0. So this denotation tells GRUB the root filesystem is on the first drive, second partition.
Arch-specific Details (Mostly)
If you already did the configuration for your hard disk, you should be able to copy most the configuation files over to the flash drive (rc.conf, mirrorlist, modprobe.conf, local.conf…) and then install xorg, xfce4… by chrooting in. This is my chroot script:
# chrootmount – change root to current directory
cp /etc/resolv.conf etc/resolv.conf
mount -t proc none proc
mount -o bind /dev dev
mount -t sysfs none sys
chroot . /bin/bash
source /etc/profile
grep -v rootfs /proc/mounts > /etc/mtab
source ~/.bashrc
This will allow you to just cd to the mounted directory and enter command to chroot to the new environment. From there you can install a desktop environment (I choose XFCE because I wanted a lightweight environment and limited disk space):
pacman -S xorg xfce4 gdm <few-fonts> nvidia
And a couple other things following the Beginner’s Guide.
The kernel initramfs image will need to be rebuilt too to have usb driver support. In the chrooted environment edit /etc/mkinitcpio.conf and add usb to HOOKS:
Then find the the kernel version name and version:
and build a new initramfs image:
The -k option needs to be specified to use the chrooted kernel and not runtime kernel that is being used by chroot.
When done, exit chroot:
Reboot and Test
Now reboot and get to the BIOS Boot Menu. As I said, all BIOS’s are different so keep an eye for a key to get to it. Once in the Boot Menu select your USB drive.
Try and boot the flash drive. If you get a GRUB 17 error or boot into hard drive OS, you’ll have to edit your menu.lst. You can find the devices Grub sees by starting the flash drive again and in the Grub menu press e to edit. On the root line press e again and delete to:
root (hd
now press tab and it will show you the availble drive and partitions. Enter the correct one, hit escape and then b to boot. That’s it, you should now have your own customizable Linux USB drive.
Troubleshooting
If you get errors loading the kernel, it may be because USB device detection may need a delay before loading root. Try to add this to the end of your kernel line in your menu.lst:
Conclusion
I was a bit surprised. I didn’t think a USB drive would be much different that a CD/DVD but actually it was alot faster. And I just discovered that I’m using a USB 1.1 flash drive. :) Not quite as quick as my hard drive but definitely not bad. This is also the first time I ran without an xorg.conf and my desktop runs great. Definitely worth a try if you ever need a rescue os to fix problems with.
Vim Basics
Introduction
Vim is an advanced text editor that seeks to provide the power of the de-facto Unix editor ‘Vi’, with a more complete feature set. Vim is not a simple text editor like nano or pico. It does require some time to learn, and a great amount of time to master.
About Vim
Vim is probably the most popular incarnation of its predecessor vi, but all vi packages are similar.
Vim is designed to make your fingers work as little as possible, and you should never have to use the mouse. This may seem odd, but once you master Vim, you’ll wonder why other apps don’t behave like it.
Features
- Vim has syntax highlighting.
- No-nonsense editor
- Command mode allows for simple, robust keybindings
- Vim is very powerful for advanced editing tasks
- vimtutor is a vim-based tutorial to learn… indeed… vim
- Uh…vim is good?
Starting Vim
If you start vim with vim somefile.txt you’ll see a blank document (providing that somefile.txt does not exist. If it does, you’ll see what’s in there). You will not be able to edit right away – you are in Command Mode. In this mode you are able to issue commands to vim with the keyboard.
Let’s work on something. It can be any text file, really. Open that file with vim:
Basic Editing
You begin in command mode. If you’re not sure what mode you’re in, press ESC to get to command mode.
You insert text (stick it before the cursor) with the i command. I inserts text at the end of the line. You append text (place text after the cursor, what most people expect) with a. Typing A will place the cursor at the end of the line.
Return to command mode at any time by pressing ESC.
Moving Around
Single Characters
In Vim, you can move the cursor with the arrow keys, but that’s no very efficient is it? You’d have to move your right hand all the way from the standard typing position all the way to the arrow keys, and then back. Not fun.
In vi you can move down by pressing j. You can remember this because the “j” hangs down. You move the cursor back up by pressing k. Left is h (its left of the “j”), and right is l (its right of the “k”).
^ will put the cursor at the beginning of the line, and $ will place it at the end.
^ and $ are commmonly used in regular expressions to match begin and end of the line. Regular expressions are very powerfull and are commonly used in *nix environment, so maybe it is a little bit tricky now, but later you will notice “the idea” behind most of the key mappings. Other commands also use ^ and $ to move/do something from cursor to begin or end of the line.
Multiple Characters
To advance a word, press the w key. W will include more characters in what it thinks is a word. To go back a word, b is used. Once again, B will include more characters in what vim considers a word. To advance to the end of a word, use e. If you haven’t guessed it, E includes more characters to be a word.
To advance to the beginning of a sentence, ( will get the job done. ) will do the opposite, moving to the end of a sentence. For an even bigger jump, { will move the the begining a whole paragraph. } will advance to the end of a whole paragraph.
To advance to the header (top) of the screen, H will get the job done. M will advance to the middle of the screen, and L will advance to the last (bottom).
The repetition department of the repetition department of the…
Here’s an awesome thing: if you press a number before a command, then that command will be executed that number of times over (there are exceptions, but they still make sense, like the s command). For example, pressing 3i then “Help! ” will print “Help! Help! Help!“. Pressing 2} will advance you two paragraphs. This comes in handy with the next few commands…
Deleting
The x command will delete the character under the cursor. X will delete the character before the cursor. This is where those number functions get fun. 6x will delete 6 characters. Pressing . (dot) will repeat the previous command. So, lets say you have the word foobar in a few places, but after thinking about it, you’d like there just to be “foo”. Move the cursor under the b, hit 3x, move to to the next foo bar and hit . (dot). BAM!
The d will tell Vim that you want to delete something. After pressing d, you need to tell Vim what to delete. Here you can use the movement commands. dW will delete up to the next word. d^ will delete up unto the beginning of the line. Prefacing the delete command with a number works well too: 3dW will delete the next three words. D (uppercase) is a shortcut to delete until the end of the line (basically d$). Pressing dd will delete the whole line.
Undo and Redo
vim has a built-in cutboard. Actions and be undone and again redone. Use u to undo and ctrl+r to redo.
Advanced Editing
Pressing s will erase the current letter under the cursor, and place you in edit mode. S will erase the whole line, and place you in edit mode. Pressing 5s will erase 5 letters and place you in edit mode.
Pressing v will put you in visual mode . Here you can move around to select text, when you’re done, you press y to yank the text into the buffer (copy), or you may use c to cut. p pastes after the cursor, P pastes before. V, Visual Line mode, is the same for entire lines. c^v is for blocks of text.
Search and Replace
To search for a word or character in the file, simply use / and then the characters your are searching for and press enter (e.g. /myword). To view the next match in the search press n.
To search and replace use the substitute :s/ command. The syntax is: [range]s//]/[arguments]. Some examples:
:s/xxx/yyy/ Replace xxx with yyy at the first occurence
:s/xxx/yyy/g Replace xxx with yyy global (whole sentence)
:s/xxx/yyy/gc Replace xxx with yyy global with confirm
:%s/xxx/yyy/g Replace xxx with yyy global in the whole file
You can use the global :g/ command to search for patterns and execute a command for each hit. The syntax is: :[range]:g//[cmd]. Some examples:
:g/^#/d Delete all lines that begins with #
:g/^$/d Delete all lines that are empty
To replace the current word. Place the cursor on the word and execute the command cw. This will delete the word and change the mode to “input”. To replace a letter use r.
Other things
Vim will auto indent. This can be annoying when you have to paste something that contains a space or tab at the beginning of the line. In command mode typing :set paste will disable this. Typing :set nopaste will reenable it.
Saving and Quitting
Write a file with :w or if the file doesn’t have a name :w <filename.txt>. Quitting done with :q. If you choose not to save your changes, use :q!. To save and quit :x.
Using Tabs
If you want to edit multiple documents at once you can use tabs to make it easier:
Configuration File
vim is ultimately customizable and can be used for many different program languages, personal preferences… and is done so in the configuration file. There’s a lot you can do in a .vimrc file, for new users here’s a basic one:
Place in your home directory.
Conclusion
You now know how to use Vim to do slightly more than you could do in a simple editor. As your knowledge of Vim grows, you will be able to use it efficiently and do amazing things with text files. And most importantly, you’ll feel right at home playing nethack.
Etc.
Testdrive a LiveCD with VirtualBox
Results will vary depending on your machine but it may be quicker to burn and reboot to testdrive a LiveCD. If you want to try VirtualBox though, this is how you do it.
I decided to take a look at Fedora 11 and I thought that if I wanted to take a look at other LiveCDs in the future may as well set up VirtualBox and save myself the time of burning and restarting to take the look at them. Virtualbox is a bit slow but not terribly though. Note: I don’t have virtualization on my CPU though so load-times may alot better with it.
Install VirtualBox
Virtualbox has been getting some good reviews and is easy to use. Locate you distro’s documentation and find out how to do this.
Once Virtualbox has been installed load the module:
Start VirtualBox
VirtualBox in the KDE menu is under System > Sun VirtualBox, or you can just type VirtualBox in a terminal.
Setup
Click ‘New’ in the VirtualBox window, name it, select OS type and version. Select base memory size as 512MB (most operating systems will need at least 512MB to function properly). Follow the rest of the steps to create a hard disk image.
When the new image has been created click ‘Settings’ then CD/DVD-ROM and check ‘Mount CD/DVD Drive’. Then add the ISO image.
In the ‘General’ dialogue, select the Advance tab and check ‘Enable IO APIC’.
That’s it. You should now be able to load a LiveCD from VirtualBox.
Going Further
I wrote a post on top of this about creating you own LiveUSB:
Kcheckgmail Gets in the KDE 4 Door
There are several programs to get mail notifications in the notification tray in KDE 4 but up until now there have been no native KDE ones: cgmail, and gnubiff rely alot on Gnome. There is the emailnotify plasmoid which isn’t too shabby but I wanted my notifications in the notification area!
Popular KDE 3 applications are making their way gradually to KDE 4 and kcheckgmail just made that plunge. So thanks to the devs that got this done.
Kcheckgmail for KDE 4 would still be considered beta software though as I encountered a couple bugs setting it up. After setup though kcheckgmail has been running good the last few days.


For now if you want to use kcheckgmail you’ll have to compile it from git. Luis has the basic instructions on how to do this.



