Sunday, June 6, 2010

Ubuntu: Enable Ctrl-Alt-Backspace to restart the X server

By default, this key combination comes disabled. Here's an excerpt from ubuntugeek on how to enable it:
Since Ubuntu 9.04, the Ctrl-Alt-Backspace key combination to force a restart of X is now disabled by default, to eliminate the problem of accidentally triggering the key combination. In addition, the Ctrl-Alt-Backspace option is now configured as an X keymap (XKB) option, replacing the X server “DontZap” option and allowing per-user configuration of this setting.
As a result, enabling or disabling the Ctrl+Alt+Backspace shortcut can now be done easily from the desktop.
Enabling Ctrl-Alt-Backspace for Ubuntu 10.04
* Select “System”->”Preferences”->”Keyboard”
* Select the “Layouts” tab and click on the “Layout Options” button.
* Select “Key sequence to kill the X server” and enable “Control + Alt + Backspace”.

Saturday, June 5, 2010

Ubuntu: time command

The time command comes very useful for long running scripts. It lets you know among other thigs, how long a particular command takes to run.

# sudo time updatedb

0.27user 1.00system 0:40.50elapsed 3%CPU (0avgtext+0avgdata 4256maxresident)k
119752inputs+11560outputs (1major+367minor)pagefaults 0swaps

The command output shows you:
user avgerage load
system average load
command elapsed time
CPU average use
memory average use
I/O inputs & outputs
memory page faults

Ubuntu: checking for bad blocks on a hard drive

I have an old 80Gb disk I recovered from an old notebook, and it's been giving me read inconsistencies on some files, probably because of bad sectors. Since the disk it's mounted on a crappy USB craddle, it's not passing any SMART data. So I did this the old way.

# sudo time e2fsck -v -cc /dev/sdc1

e2fsck 1.41.11 (14-Mar-2010)
Checking for bad blocks (non-destructive read-write test)
Testing with random pattern:   0.26% done, 1:42 elapsed

Wednesday, June 2, 2010

Ubuntu Lucid: VMWare player hangs on notebook

VMWare player was constantly hanging after about 5 minutes of running on the Ubuntu host. I found this problem is related to CPU frequency scaling (Intel Speedstep on my Lenovo T60).
This is easily solved by installing the CPU frequency scaling applet on Ubuntu, then click on it and select a fixed CPU frequency while running VMWare. I recommend switching it back to on demand when you're done to save power.

Ubuntu Lucid: Enable fingerprint authentication on Lenovo T60

I configured fingerprint authentication on my Lenovo T60, here's the procedure.

NOTE: This is supposed to work with any compatible fingerprint hardware not just T60.

NOTE2:under some circumstances fprint stops responding, so this is not stable enough for production purposes.

Here's how:
  1. Install fprint-demo (sudo apt-get install fprint-demo)
  2. Run the fprint-demo application and configure the fingers you want to use to log in.
    TIP: make sure to verify the fingerprint before leaving this application, otherwise, you may not be able to use it for authentication
  3. sudo gedit /etc/pam.d/common-auth 
  4.  Add this line to the file: auth sufficient pam_fprint.so. 
NOTE: The changes on this file apply inmediately, this means, if you screw things up, and even lock your computer, you may not be able lo log in back again. Just in case, have a live cd available. Log in using the live cd, mount the ext partition and edit this file manually, this will get you back in. At least this worked for me ;-)


Here's how my file looks like: 

#
# /etc/pam.d/common-auth - authentication settings common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of the authentication modules that define
# the central authentication scheme for use on the system
# (e.g., /etc/shadow, LDAP, Kerberos, etc.).  The default is to use the
# traditional Unix authentication mechanisms.
#
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
# To take advantage of this, it is recommended that you configure any
# local modules either before or after the default block, and use
# pam-auth-update to manage selection of other modules.  See
# pam-auth-update(8) for details.
auth sufficient pam_fprint.so
# here are the per-package modules (the "Primary" block)pam.d
auth    [success=2 default=ignore]    pam_unix.so nullok_secure
auth    [success=1 default=ignore]    pam_winbind.so krb5_auth krb5_ccache_type=FILE cached_login try_first_pass
# here's the fallback if no module succeeds
auth    requisite            pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
auth    required            pam_permit.so
# and here are more per-package modules (the "Additional" block)
# end of pam-auth-update config
#auth required pam_unix.so nullok_secure

After these steps, try locking your session, when unlocking you will be prompted for a fingerprint, if you fail to provide the correct fingerprint, the system will failover to ask a password.

Tuesday, June 1, 2010

CMU Sphinx error: ./wave2feat: error while loading shared libraries: libsphinxbase.so.1: cannot open shared object file: No such file or directory

I'm doing some research on voice recognition. Really doing my first steps on this field. I've been struggling to get started using CMU sphinx for the last two days. The tutorial published on the CMU sphinx site has some flaws. For instance, it says you need to build the trainer first, but if you don't build the sphinxbase code first, it wont let you build it, saying it's missing sphinxbase. Then, it doesn't say you need to install sphinxbase either. So after building sphinxbase, make sure to run

# cd sphinxbase
# make install

Now, when you think you have everything in place, and you get to the point where you perform a preliminary training run

# perl scripts_pl/make_feats.pl -ctl etc/an4_train.fileids
The, I started getting this error:

./wave2feat: error while loading shared libraries: libsphinxbase.so.1: cannot open shared object file: No such file or directory

This drove me nuts, until I stumbled into this post, and this gave me the idea to run this command:

# sudo ldconfig -v | grep sphinx

you should get an output like this:
libsphinxbase.so.1 -> libsphinxbase.so.1.1.1
libsphinxad.so.0 -> libsphinxad.so.0.0.1

If there's no output, try editing the /etc/ld.so.conf file and add a /usr/local/lib line at the end of the file. I tried this at first bout found it's not neccesary if you run the ldconfig command it will refresh the references automatically.

Ubuntu Lucid - dual monitor flickers on Lenovo T60 ATI card

I had some issues with Ubuntu 10 Lucid and my Lenovo T60 (ATI rage card). When I plugged in my secondary monitor (DELL 19'' LCD) the display started flickering. Turns out there seems to be an specific issue with the ATI video card. I found a forum post that solves the problem by editing /boot/grub/menu.lst and adding radeon.modeset=0 to the startup parameters.
The first problem I encountered was that the article said you should edit menu.lst but the Ubuntu Lucid setup installs grub 2 which has no menu.lst file.

I found this other article that explains how to edit the startup settings. I recommend booting up and editing the startup settings on the grub menu before changing the config files. This way if the parameters fail, you don't end up crashing your boot.

So in a nutshell, menu.lst has been replaced by /boot/grub/grub.cfg, so my file (first section, looks something like this:

some other sections code here

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-22-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd1,1)'
search --no-floppy --fs-uuid --set f5046c00-0fb3-4b57-9968-cac7b8fc3fa9
linux /boot/vmlinuz-2.6.32-22-generic root=UUID=f5046c00-0fb3-4b57-9968-cac7b8fc3fa9 ro radeon.modeset=0 quiet splash
initrd /boot/initrd.img-2.6.32-22-generic



Editing this file and rebooting does the trick, although I'm not sure what this parameter does, I'll look it up later to see if there are other interesting settings.