Summer Nights

Let's make the world a better place using digital technologies!

Samba Print Server Problem

I tried connecting to my samba print server from my xp notebook. The printer was always visible, connectable and accepted documents for printing but never led to a physical print. I could solve it by visiting:
and adding the printer to CUPS. It worked immediately!

Continue Reading

Putting Hard Disks to Sleep

In Ubuntu server, you can put any disk that is not used for a give period of time to sleep using hdparm command. Simply do something like:
hdparm -S 20 /dev/sdb
hdparm -S 20 /dev/sda

to put the disks to sleep after 100 seconds (20 x 5)

To have it programmed automatically on bootup, write the same lines into /etc/rc.local.

Continue Reading

Configuring PC-39 Remote Control from ASUS MyCinema P7131 for XBMC

You have to understand the mechanism first:

1. The xbmc recognizes lircd as a generic remote control.
2. lirc further can connect to various remotes based on configuration in /etc/lircd.conf and present them as lirc remote to xbmc.

Now, first of all, you have to know what is the name of your remote device in linux. For this, you need to install input-utils:
apt-get install input-utils

Now when you say:
it shows you all the input devices on your system. In my case, among other, I see:
bustype : BUS_PCI
vendor : 0x1043
product : 0x4876
version : 1
name : "saa7134 IR (ASUSTeK P7131 Hybri"
phys : "pci-0000:05:00.0/ir0"
bits ev : EV_SYN EV_KEY EV_REP

This shows that the remote is indeed connected to the system and recognized as /dev/input/event6 device. This device number may change among different boots. We shall fix it by a trick in the lirc configuration.

Now if you want to see whether the events from your remote are being received by the system or not, issue the following:
input-events -g -t5 6
This shows the events received from event6 device with a 6s timeout. Press the buttons on your remote and you should see the codes received on the console.

If you want to see how the remote is mapping keys to keycodes, then isssue the following command:
input-kbd 6 > keyMapIR.txt
where 6 indicates the device id. You might have a different one.

In case, you decide to change this encoding then you can change the keycodes in the keyMapIR.txt file and upload it back to the remote as:
input-kbd -f keyMapIR.txt 6
But normally this will not be required.

Now that you know that your device is connected and working properly, we can proceed to install lirc.
apt-get install lircd
During its installation, please choose the appropriate remote make. In my case, I chose ASUS MyCinema. That sets it. Now lirc waits for a connection on a given address. We do not go in this detail. If you look in the /etc/lirc/lircd.conf, you would see something like:
After tweaking, I have this file as following:
begin remote
name lirc.conf
bits 16
eps 30
aeps 100
one 0 0
zero 0 0
pre_data_bits 16
pre_data 0x8001
gap 135991
toggle_bit_mask 0x80010188
begin codes
Rec 0x00A7
Close 0x0074
Prev 0x019C
Stop 0x0080
Next 0x0197
Rew 0x00A8
PlayPause 0x0077
Fwd 0x00D0
Up 0x0067
Down 0x006C
Enter 0x8001001C
Left 0x0069
Right 0x006A
Vol+ 0x0073
Vol- 0x0072
Ch+ 0x0192
Ch- 0x0193
Back 0x00AE
1 0x0002
2 0x0003
3 0x0004
4 0x0005
5 0x0006
6 0x0007
7 0x0008
8 0x0009
9 0x000A
FullScreen 0x0174
0 0x000B
Recall 0x0070
Tv 0x0179
Video 0x0189
Home 0x0066
Dvd 0x0185
Picture 0x016E
DvdMenu 0x008B
Radio 0x0181
Music 0x0188
Mute 0x0071
end codes
end remote

Please note that the names of the buttons have been changed a bit to match with the xbmc configuration. Now after changing this file and having restarted lircd, you should issue irw command and press buttons on the remote to check the proper encoding of the keys by lirc. If everything is perfect, then we can now proceed to the xbmc configuration.

The file that we want to edit is /usr/share/xbmc/system/Lircmap.xml. Here you should add a section like the following:
<remote device="lirc.conf">

The device name “lirc.conf” is the same that you see when you run irw command. You can see that the keys correspond to the keys in lircd config file.

Finally, we want lircd to always connect to the right device even if its device number changes after reboot. To this end, we need to change the /etc/init.d/lirc as follows:

build_remote_args ()

#For remote only detection support, we need
if [ -z "$REMOTE_DEVICE" ] && [ -z "$TRANSMITTER_DEVICE" ] && [ -c $dev ]; then

#If we have a REMOTE_DEVICE or REMOTE_DRIVER defined (either because no devices
#were defined, OR if we explicitly did), then populate REMOTE_ARGS
if [ ! -z "$REMOTE_DEVICE" ] || [ ! -z "$REMOTE_DRIVER" ]; then
if [ -n "$REMOTE_DEVICE" ] && [ "$REMOTE_DEVICE" != "none" ]; then
if [ -n "$REMOTE_DRIVER" ] && [ "$REMOTE_DRIVER" != "none" ]; then

#Now, if we ALSO have a transmitter defined, add some args
#To make the first lircd listen up
if [ ! -z "$TRANSMITTER_DEVICE" ] || [ ! -z "$TRANSMITTER_DRIVER" ]; then

whereas $REMOTE_DEVICE is defined as REMOTE_DEVICE=’saa7134*’ in /etc/lirc/hardware.conf. This step makes sure that after a reboot, the lircd always connects to the IR device regardless of its device number assigned by linux kernel.

Just in case it is of help to someone, here is my /etc/lirc/hardware.conf file:

# /etc/lirc/hardware.conf
#Chosen Remote Control
REMOTE=”Asus MyCinema P7131″

#Chosen IR Transmitter

#Enable lircd

#Don’t start lircmd even if there seems to be a good config file

#Try to load appropriate kernel modules

# Default configuration files for your hardware if any

#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn’t have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to “false”

Continue Reading

Forward X over ssh

This assumes you use:
1. Putty as ssh client
2. Xming as X server on Windows XP

First you should save a session in Putty that connects to the given server. Now, from a command prompt, execute:
Xming :0 -multiwindow -clipboard
to start the Xming server. And,
plink -X -load RsrvSession xterm
to start the X-based remote connection using Putty session stored as RsrvSession.
If you need all the fonts, then install the Xming-fonts package on Windows. That is all to it.

Continue Reading

Installing Ubuntu from a USB

Taken from ubuntuforums , thanks to vegetarianshrimp.

Windows UNetbootin

  1. Insert your USB flash drive (1GB should be enough, although less may work too, I just haven’t tested it with less)
  2. Go to
  3. Click on Download (for Windows)
  4. Install the .exe
  5. Open Unetbootin.
  6. In the UNetbootin window, there will be a drop-down menu “==Select Distribution==”
    Select Ubuntu
  7. There will also be one called “==Select Version==”
    Select 9.04_Live for the latest version of Ubuntu: 9.04 Intrepid Ibex, or 8.04_Live for 8.04 Hardy Heron LTS (Long Term Support)
  8. In the bottom left corner of the window, there will be another drop down menu. It will either say “Hard Disk” or “USB Drive”. You want it to say USB Drive
  9. Click OK
  10. Wait for everything to finish. While you are waiting, DO NOT CLOSE THE UNETBOOTIN WINDOW OR UNPLUG YOUR USB DRIVE
  11. On the same ordifferent computer, plug in your USB Drive, and restart. Right at the beginning of the boot, press F12 (may be different) repeatedly, select USB Drive with the arrown keys and spacebar, and Ubuntu will boot from USB drive.

Note: If you encounter an error from SYSLINUX on bootup saying “Error: Could not find kernel image”, try formatting the USB drive with FAT16 (or FAT) instead of FAT32.

Continue Reading

Distributed Compiling

mkdir -p /usr/local/distcc/bin
cd /usr/local/distcc/bin
ln -s /usr/local/bin/distcc c++
ln -s /usr/local/bin/distcc cc
ln -s /usr/local/bin/distcc g++
ln -s /usr/local/bin/distcc gcc

DISTCC_HOSTS="localhost otherhost anotherhost"

ping otherhost
distccd --daemon --allow 192.168.X.X (run on otherhost)

time make -j12 CC="ccache gcc"
real    14m17.699s
user    22m24.856s
sys    2m58.579s

On rebuild:
real    1m11.974s
user    0m42.554s
sys    0m7.085s

time make modules -j12 CC="ccache gcc"
real    0m18.586s
user    0m23.875s
sys    0m3.934s

mv /lib/modules/2.6.28 /lib/modules/2.6.28_old

time make modules_install
real    0m6.873s
user    0m2.862s
sys    0m3.232s

time make install
real    0m0.527s
user    0m0.265s
sys    0m0.194s

cd /boot
time mkinitramfs -o initrd.img-2.6.28 2.6.28
real    0m5.947s
user    0m3.812s
sys    0m1.762s

dpkg -i linux-firmware_1.2_all.deb

Continue Reading

Clipboard not working in Windows XP

What will you do, if all of a sudden, without any apparent reason, the clipboard stops working? There is not much except to reboot, eh? Stop. The reason could be a malfunctioning application that is not letting go of the clipboard. Try searching for this GetOpenClipboardWindow utility. It will inform you of the application holding the clipboard lock. Quitting that application should solve this problem without a reboot.

Continue Reading

EXT3-fs: error loading journal

After a power surge, your linux server could be rendered un-bootable because of a corrupt file-system journal. If you are lucky and there are no physical errors, then the following could get your computer back to life.

  1. Boot the linux box using live-cd (any bootable installer for server computers).
  2. Choose “rescue a broken system”.
  3. Get to the shell and issue the following command:
    fsck.ext3 /dev/sda1 (or other, depending on your partition)
  4. The list of partitions can be displayed using:
    fdisk -l
Continue Reading

Shutdown/Reboot Windows Remotely from Linux

To shutdown:

To reboot:
net rpc SHUTDOWN -r -f -I 192.168.XX.XX -U USERNAME%PASSWORD

Works perfectly!

Continue Reading

Useful ‘sed’ commands

Delete all empty lines containing a space in the input.txt and save the result as output.txt:
cat input.txt | sed '/^ $/d' > output.txt
In case when the line is completely empty (i.e., no space either), then:
cat input.txt | sed '/^$/d' > output.txt

Tip:To see what a file really contains including non-printable characters, etc. use:
cat -A input.txt

Delete a line containing a given string in file input.txt:
sed '/string/d' input.txt

Replace all case insensitive occurrences of string1 with string2 in file input.txt and save to file output.txt:
sed 's/string1/string2/Ig' input.txt > output.txt
Note: I is for case-Insensitive and g for global replace (multiple matches per line). string1 and string2 are regular expressions.

Insert a blank line before every line where the regexp matches:
sed '/regexp/{x;p;x;}' < input.txt > output.txt

Continue Reading