Libre Things

CV
fr

Sunday 20 June 2010

Reverse SSH Tunnel for SSH connection to a NATed machine

This is how to open a SSH connexion to a serveur hidden behind a NAT gateway.

We use a reverse SSH tunnel:

nated-host$ ssh -R 2222:localhost:22 anyuser@public-host
anyuser@public-host$

This command opens 2222 port on public-host, forwarding it to local 22 port on nated-host.

Finally, from public-host we connect to 2222 local port with SSH, to end on nated-host:

public-host$ ssh -p2222 localhost
nated-host$

References:

Windows XP broken after Ubuntu Lucid upgrade

A friend of mine has a PC with Windows XP / Ubuntu in dual boot. After the Lucid upgrade, Windox fails to boot (strange lines on the screen after Grub...).

TestDisk saved us:

sudo aptitude install testdisk
sudo testdisk
  1. Choose [ Create ] Create a new log file
  2. Choose windows physical disk, then [Proceed ]
  3. Choose [ Continue ] Continue even if there are hidden data
  4. Choose [Intel ] Intel/PC partition
  5. [ Advanced ] Filesystem Utils
  6. On Windows XP partition, boot sector is generally bad or non identical to backup sector (Sectors are not identical.).
  7. Choose [ Backup BS ] to copy the backup sector to the master sector.
  8. After that, quit, reboot and test.

Sources:

Tuesday 8 June 2010

Laptops for Languedoc french students in 2011: letter to Georges Frêche

In 2011, my region plans to distribute laptops for lycée students (lycée ~= secondary school).

I just posted a mail to Georges Frêche, the leader of our Languedoc-Roussillon region.

The letter suggests the choice of Linux and Free Software as a software platform for the laptops.

The letter in my French article.

Thursday 3 June 2010

3D performance problems with KMS

With the last Ubuntu Lucid 10.04 come a new graphical module: KMS or Kernel-based Mode-Setting.

If you have performance problems in some games like Quake 3 or TCE / Enemy Territory, try to disable KMS. The problem can also be with the mouse pointer (slowness, lag, delay or inacuracy).

Grub 2

Add nomodeset in /etc/default/grub then issue the command update-grub.

vi /etc/default/grub
GRUB_CMDLINE_LINUX="nomodeset"
update-grub

Grub 1

Add nomodeset at the end of the # kopt line, then issue command update-grub.

vi /boot/grub/menu.lst
# kopt=root=/dev/sda1 ro nomodeset
update-grub

Someone also told me that disabling KMS solved his Firefox javascript speed problem in Yahoo Mail.

Monday 24 May 2010

Catch-all mail with Exim

The main idea is to have a set of anything@ads.mydomain.com addresses, all redirecting to a single mailbox. Then I can use any address @ads.mydomain.com as an alias to my primary mailbox. This way, I give ebay@ads.mydomain.com to Ebay, amazon@ads.mydomain.com to Amazon and so on.

This solutions allows me to disable an alias if unsubscribing on the site doesn't work. I can also use this to track sites selling my address to other sites.

First, Exim has to listen on the network, and accept mail to the ads.mydomain.com domain. Under Debian, put this in /etc/exim4/update-exim4.conf.conf:

dc_local_interfaces='0.0.0.0'
dc_relay_domains='ads.mydomain.com'

Note under Debian: each time Exim starts the /etc/exim4/exim4.conf.template file is filled with variables set in /etc/exim4/update-exim4.conf.conf, générating the /var/lib/exim4/config.autogenerated file. This is to ease Exim configuration in standard cases.

Then edit the /etc/exim4/exim4.conf.template file to add a new router, in first position just bellow begin routers:

catchall_pub:
  driver = redirect
  domains = ads.mydomain.com
  data = user@mydomain.com

The router will be called for any mail @ads.mydomain.com. It give all mails to the redirect transport sending them to the address set in data.

Finally, you can then use a /home/user/.forward file to disable aliases with a Sieve or Exim filter.

References:

Thursday 20 May 2010

Brasero Bug Copying Audio CD in Ubuntu Lucid

Audio CD copy is actually not possible with Brasero on Ubuntu Lucid. All details in the bug report.

As a workaround, you must install cdrdao version 1.2.3, which is not yet available as a package.

To install it, you can use CheckInstall which is a bit cleaner than the old make install:

tar -xjvf cdrdao-1.2.3.tar.bz2
cd cdrdao-1.2.3/
./configure
make
sudo checkinstall make install

Note: the make command can fail because of missing dev packages you'll have to install.

CheckInstall builds and installs a nice Debian package.

You can also use cdrdao directly. ps axf shows us the command Brasero is using:

cdrdao read-cd --device /dev/sr0 --read-raw --datafile /home/dooblem/brasero.toc.bin -v 2 /home/dooblem/brasero.toc

Here we go!

Links :

Audio CD Backup/Archive

It's not possible to backup an audio CD as an iso image. This format is for data CDs.

You should use cdrdao.

Example:

cdrdao read-cd --read-raw --datafile FILE_NAME.bin --device /dev/cdrom --driver generic-mmc-raw FILE_NAME.toc

Under Ubuntu, you can use Brasero with "CD copy" mode. ps axf shows us the command Brasero is using:

cdrdao read-cd --device /dev/sr0 --read-raw --datafile /home/dooblem/brasero.toc.bin -v 2 /home/dooblem/brasero.toc

Note: there is a Brasero Bug in Ubuntu Lucid with cdrdao.

Links:

Thursday 6 May 2010

Featured Pictures RSS Feed on Wikimedia Commons with Catfood

If you like beautiful images, you certainly knows Featured Pictures on Wikimedia Commons project.

Magnus created a small tool to see all the last selected features pictures : Catfood.

Catfood works for any Wikimedia Commons category.

The RSS feed:

http://toolserver.org/~magnus/catfood.php?category=Featured_pictures_on_Wikimedia_Commons

Links:

Wednesday 14 April 2010

Login form bookmarklet generator

Bookmarklets are links containing Javascript code. They are useful when you save them in your bookmarks, in order to achieve some processing on the current page displayed in your browser.

It is possible to create bookmarklets authenticating you on a site with a login form. Note that it requires storing your login and passwordin the bookmarklet source code.

Login bookmarklet example

The bookmarklet code on several lines:

javascript:
document.body.appendChild(document.createElement('div')).innerHTML='
<form name="BletForm" method="POST action="http://www.woozweb.com/loginctrl">
<input type="hidden" name="login" value="MONLOGIN" />
<input type="hidden" name="pass" value="MONPASS" />
</form>';
document.forms['BletForm'].submit();

This code generates a POST HTTP request with two parameters, from your bookmarks. Writing this kind of code is easy for Web developpers, but hard for regular users.

So I wrote a bookmarklet that itself can generate login form bookmarklets, easily.

It's very simple:

  1. Drag the generator bookmarklet in your bookmarks: generator
  2. Open a web page with a login form.
  3. Click on the generator in your bookmarks: a message appears next to the form.
  4. Fill in the login form.
  5. Click on the generation link: the bookmarklet appears.
  6. Drag the generated bookmarklet in your bookmarks.
  7. Finally, test your automatic login bookmarklet!

The generator bookmarklet even works with the login screen of my bank account. Obviously, your login information is stored directly in the bookmark, which is not very secure...

Notes:

  • Only tested with Firefox. Some work to make it compatible with Safari and IE.
  • Find a way to use Firefox password storage to retrieve the password.
  • If the bookmarklet doesn't work for you, give me some feedback.

Links:

Tuesday 9 March 2010

Clictap: how to convert your mouse into a remote control

Here is a small C program I wrote some years ago: Clictap. It's very convenient and I'm still using it to watch my movies.

It makes use of Xlib and Xtest libraries to replace your mouse buttons by keyboard keys.

I made a small Debian package a few days ago:

clictap_0.6-1_i386.deb

soon included in the official repositories ?

Configuration file example including profiles for totem, xmms, rhythmbox and mplayer:

# ClicTap configuration file
# You can copy this example to ~/.clictap.conf

# When this key is pressed, Clictap will ungrab your mouse and quit
# Examples :
# quit_key q
# quit_key ctrl+q
quit_key q

# Profile used by default
default_profile mplayer

# List of profiles
# For each profile, a set of buttons to keys translations is given,
# each translation on a separate line.
# For a translation, the first field is the set of buttons,
# the second is the set of keys.
# Buttons are specified by their numbers.
# Keys are specified by their KeySym (Key Symbols).
# To know the button numbers and KeySyms, use the xev program to test X events.
# Example :
#
# profile foo
# 	1   a
# 	2   b+c
# 	3+1 space
# 	3+2 Control_L+d

profile totem
	1 b
	2 p
	3 n
	4 Up
	5 Down

profile xmms
	1 w
	2 c
	3 b
	4 Up
	5 Down

profile rhythmbox
	1 Alt_L+Left
	2 Control_L+space
	3 Alt_L+Right
	4 Control_L+Up
	5 Control_L+Down

profile mplayer
	1 Left
	2 space
	3 Right
	4 asterisk
	5 KP_Divide

profile mplayersub
	1 x
	2 space
	3 z
	4 asterisk
	5 KP_Divide

profile test
	1 XF86AudioLowerVolume
	2 space
	3 z
	4 asterisk
	5 KP_Divide

Tuesday 2 March 2010

Camusiciel

A music group from Québec: Camusiciel. A friend of mine plays in it.

Here is their first video clip:

The video is made from a set of photos shooted from a fixed camera. Imagine the number of photos... and the work of assembly!

In the film, you can see me putting some glasses at the beginning :)

Visit their website: www.camusiciel.ca

Wednesday 10 February 2010

Disable a service with update-rc.d under Debian (update resistant)

The well known way to remove a service from system boot under Debian / Ubuntu, without removing the package:

update-rc.d -f mysql remove

This command removes all /etc/rc*/*mysql* symbolic links. At next boot, the service is not started.

Problem: when you update the mysql package (aptitude update), symlinks are created again.

Solution: in the last update-rc.d versions, there are disable / enable commands:

update-rc.d mysql disable

Useful if like me you only start apache or mysql some times for Web development. Also useful if you share files with Samba and only want to start the daemon occasionaly.

Note: update-rc.d --help tells us that The disable|enable API is not stable and might change in the future.

References:

Tuesday 26 January 2010

Launch Nautilus as a super user

Under Ubuntu, or any distribution using Gnome, you can do almost anything without using the command line.

To configure some things, you still have to edit a configuration file. To configure your desktop, a lot of online documentation still requires you to to edit /etc config files.

To help non linux experts, you can try the nautilus-gksu package. It permits you to edit any file as administrator with a simple right-click on the file.

Personnaly, I prefer launching Nautilus as root, as it allows more than simple file edition power (permission change, deleting...).

I create a launcher for this task, a bit like the Administrator Terminal in Applications > System Tools:

  1. Right-click on the panel > Add to panel, Custom Application Launcher.
  2. Name: Nautilus superuser
  3. Command: gksu nautilus

Et voila.

Configure user directories (Download, Documents, Images, Music, Vidéos)

In some modern distributions like Ubuntu, there are preconfigured user directories like Desktop, Download, Documents, Images, Music, Vidéos.

ubuntu_user_dirs.png

You can remove some of the directories you don't use, or rename some of them.

If you change their name, you can set their new place in your ~/.config/user-dirs.dirs file:

# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
# 
XDG_DESKTOP_DIR="$HOME/Bureau"
XDG_DOWNLOAD_DIR="$HOME/telech"
XDG_TEMPLATES_DIR="$HOME/"
XDG_PUBLICSHARE_DIR="$HOME/public"
XDG_DOCUMENTS_DIR="$HOME/docs"
XDG_MUSIC_DIR="$HOME/zic"
XDG_PICTURES_DIR="$HOME/images"
XDG_VIDEOS_DIR="$HOME/cine"

Then restarting Nautilus should be sufficient. Otherwise restart your Gnome session.

References:

Sunday 10 January 2010

[Ubuntu Karmic] Disable USplash

When Ubuntu starts, the USplash screen hides you the Linux boot and commands. If you're a geek spirit, you'll prefer those "cabalistic writings". Here is how to disable USplash without removing the usplash and usplash-theme-ubuntu packages (because package ubuntu-desktop depends on them).

usplash_karmic.png

Disable USplash, then rebuild initramfs:

sudo vi /usr/share/initramfs-tools/conf-hooks.d/usplash
USPLASH=n
sudo update-initramfs -u

Links:

See also:

[Ubuntu Karmic] Disable XSplash

XSplash is new in Ubuntu Karmic. If you don't like this ugly screen like me, here is how to disable it.

xsplash_karmic.png

The dpkg -l | grep xsplash command tells you that two package are responsible for this horrible screen: xsplash and ubuntu-xsplash-artwork. To remove them, you also have to remove the ubuntu-desktop package. That is not recommended if you don't want to miss something in the next Ubuntu upgrade.

Here it is:

sudo rm /etc/dbus-1/system.d/xsplash.conf
sudo touch /etc/dbus-1/system.d/xsplash.conf

We remove the file and create an empty one. Why ? Because if we just delete the file it will be created back again during the next update. If you create an empty file in place, the next update will ask you what to do with the file.

Et voila, restart and enjoy the "visual peace".

Link:

See also:

Saturday 9 January 2010

Generate persistent udev net rules

Under Arch Linux, your network cards are sometimes named differently between two reboot. Configuring your network connection is hard if you don't know if you card will be called eth0 or eth1.

A file /etc/udev/rules.d/75-persistent-net-generator.rules.optional can be used to tell udev to generate persistent network rules.

It's very simple:

mv /etc/udev/rules.d/75-persistent-net-generator.rules.optional /etc/udev/rules.d/75-persistent-net-generator.rules

Reboot your system. A /etc/udev/rules.d/70-persistent-net.rules file has been generated. Now you can disable the generator:

mv /etc/udev/rules.d/75-persistent-net-generator.rules /etc/udev/rules.d/75-persistent-net-generator.rules.optional

Link:

Wednesday 6 January 2010

Resize an ext3/ext4 partition

Before doing anything: backup your sensible data!

To extend a partition and it's filesystem, you have to:

  1. Extend the partition
  2. Extend the filesystem

To shrink a partition and it's filesystem, you have to:

  1. Shrink the filesystem
  2. Shrink the partition

For an ext3 partition, simply use parted:

parted /dev/sdx
print
resize N

Parted doesn't support ext4 (yet?). For an ext4 partition or if parted refuses to resize your ext3 partition (Error: File system has an incompatible feature enabled.), use resize2fs:

To extend:

cfdisk /dev/sdx
# delete the partition and create it again with the desired size
resize2fs /dev/sdxY

Without giving any size, resize2fs extends the filesystem to the partition's size.

To shrink, it's almost as simple:

# example if you want a 10G partition
# resize filesystem with a size smaller than the desired size
resize2fs /dev/sdxY 9G
cfdisk /dev/sdx
# delete the partition and create it again with the desired size
# (a little bigger than the filesystem!!)
# then launch resize2fs again
resize2fs /dev/sdxY

Doing so we get the good partition size without loosing any space.

Notes:

  • If your partition is over LVM, you can use the lvresize or lvextend or lvreduce commands to resize the partition, instead of deleting/creating the partition with cfdisk.
  • The method also works for other filesystems like NTFS. For NTFS, you will use the ntfsresize command, or parted if it works.

Links :

Sunday 3 January 2010

Thinkpad fingerprint reader under Ubuntu Karmic

Here is how to configure easily your Thinkpad fingerprint reader under Ubuntu Karmic, using ThinkFinger.

Install the thinkfinger-tools (for acquiring/verifying) and libpam-thinkfinger (for PAM integration):

sudo aptitude install thinkfinger-tools libpam-thinkfinger

Then you can test acquisition/verification. As a user, issue the commands:

tf-tool --acquire
# swipe 3 times your finger
tf-tool --verify
# swipe your finger, then another finger...

Note: tf-tools should work without being root if the user belongs to the plugdev group.

Then plug the reader to PAM as explained in /usr/share/doc/libpam-thinkfinger/README.Debian:

sudo /usr/lib/pam-thinkfinger/pam-thinkfinger-enable

Now restart your system and try swiping your finger in place of typing the password. A "Password or swipe finger:" prompt displays to authenticate you at GDM login and when you type "sudo".

Notes:

  • Test several programs in the Administration menu. "swipe finger" is not always showed but should work though.
  • To my knowing, it doesn't work when locking screen (gnome-screensaver).

References :

Saturday 2 January 2010

A lightweight terminal : urxvt

Looking for a simple and lightweight terminal, I found urxvt.

xvt and rxvt don't support Unicode characters. You have to use urxvt :

aptitude install rxvt-unicode

Not that I find xterm too slow for my use. My "geek curiosity" took over. I don't like terminal tabs but instead open plenty of different terminal windows. urxvt could certainly do the job.

Then you can customize urxvt using the ~/.Xdefaults file :

vi ~/.Xdefaults
Rxvt*scrollBar: False
Rxvt*background: black
Rxvt*foreground: white
Rxvt*geometry: 110x35

The geometry I use allow me to open 4 terminal windows in my screen.

Note: you can also put parameters in ~/.Xresources but you'll have to restart X or use the xrdb -merge ~/.Xresources command to load parameters.

I also suggest you the use of a keyboard shortcut to start your terminals. In Gnome :

  1. Set your default terminal in System > Preferences > Prefered Applications
  2. Then in System > Preferences > Keyboard Shortcuts, set the Start Terminal entry. I use Alt+X.

References :

- page 1 of 2