Skip to main content


Showing posts from 2011
Nowadays normally Ubuntu mounts external hard drives without the executable bit set as a precaution against dangerous scripts from running automatically. Without the executable bit set it becomes impossible to run scripts from external hard drives. However, setting the executable bit is not as hard but little bit laborious. So I wrote a small script to decrease the load.

In order to set the executable bit for the normal user the specific partition has to be unmounted as root and then remounted by the normal user with SSID and setting the executable bit so that he has execution permission. The normal remounting process could be done in the userspace so it is all included in the script but the unmounting requires root privilege. Since, sudden unmount can freeze open files and cause data loss if the mount point is removed forcibly (rm -rf) I have not included it in the script. So the unmounting has to be manually by the user with root privileges. So if using a public computer or a share…

Gateway Netbook LT2802u tinkering

This Gateway Netbook LT2802u is a very compact machine. You need to take it apart in order to even install RAM. So I opened it up for fun and put it back.

In order to open the Gateway netbook there are many guides. First read the instructions on

from (

then see the following video

and then see the tips at

The last link gives crucial tips on how not to scratch your laptop. So use a thin laminated card or a Safeway card (not your credit card) instead of a screwdriver. If you are still using a thin flat screwdriver then cover its tip with some thin paper like a receipt. But do not try to remove those thin T-shaped screws which hold the keyboard in place and visible from the battery compartment. It is unnecessary and you woul…

A script to extract audio from a bunch of video files

This sript extracts the soundtrack from any video format and converts it to mp3. Put all videos in a single folder and run this script on them. This works on all kinds of video. This is specially useful on those bunch of youtube videos.
It works like flv to mp3, mp4 to mp3, avi to mp3 etc.

#!/bin/bash # convert-video-to-mp3 v2.0 by JOnes. # This sript extracts the soundtrack from any video format and converts it to mp3. # Put all videos in a single folder and run this script on them. This works on all kinds of video. This is specially useful on those bunch of youtube videos. echo -e "\nThis sript extracts the soundtrack from any video format and converts it to mp3. Put all videos in a single folder and run this script on them. This works on all kinds of video. This is specially useful on those bunch of youtube videos.\n\n"
if [ ! `which mplayer` ] ; then echo -e "Install mplayer \nsudo apt-get install mplayer" exit 0 fi
if [ ! `which lame`…

Internal Field Separator (IFS)

Internal Field Separator (IFS): This internal variable in bash shell turns out to be an indispensable tool in these days of spaces and other weird characters in filenames. Anyone who has tried to script in bash which involved accessing lot of filenames have definitely come across the problem of spaces in filenames.
The problem is this. It becomes impossible to split a directory listing "ls" into filenames using just the for $i in `ls` command. And the reason is simple. The directory listing separates filenames by spaces but the filenames themselves might have spaces. So the for command cannot figure out where the filename ends and where it begins. That is where this neat trick comes in. We have to tell bash to ignore all separation symbols other than newline while splitting up the directory listing into filenames. This means each line would be a new filename. And we have to make sure that each line has a new filename. This is easily achieved by the "ls -1" command.

A story about fats

Essential fatty acids(EFA)It is required by humans but cannot be synthesized inside the body. e.g. - α-linolenic acid (ω-3, pronounced as omega-3), linolenic acid (ω-6, pronounced as omega-6) are primary EFAs. Others include γ-linolenic acid (ω-6), lauric acid (saturated fatty acid). Unsaturated fat In cellular metabolism unsaturated fat contains less energy than equavalent amount of saturated fat. The greater degree of unsaturation in a fatty acid (more double bonds) makes it vulnerable to lipid peroxidation (LPOX). LPOX is a method where free radicals steal electrons from lipids in a cell membrane causing cell damage. It ruptures RBCs and the end products are mutagenic and carcinogenic. Antioxidants can protect from LPOX. So it is better to take antioxidants along with unsaturated fats. Insulin ResistanceThere is a direct correlatopn between “Insulin resistance” and “inlfammation” and there is also correlation between “inflammation” and “fat ratio” ω-3/ω-6. ω-3 and ω-9 are anti-inf…

World without Jobs

The following post is specially for those Jobs fans who are cried their hearts out for three weeks.
I looked carefully then it is clear that his aura is methodically created by some agency over years using well strung stories of triumph over setbacks.
Does the series of gadgets changed our lives? No. because most of us did not start using those because they are so restricted and expensive.
The real change came with the release of the Android OS. Now, we have a gadget that can moonlight as a mini computer. The credit of genesis of the idea of Droids are sadly attributed to Jobs and iPhone again. But that is not true. Droids might be inspired by it but it is an open source product , light years away from Jobs philosophy of intellectual ownership. Now, who patents finger gestures :) other than you know who.
If greatness is to be measured by the length by which someone pushed the human civillization then Gates takes first place. At least he worked hard to create an OS from scratch and Windo…

mplayer shortcut to change aspect ratio while playing video

The following command tells the available commands for keyboard input.
mplayer -input cmdlist
The keyboard shortcuts to mplayer are stored in two locations - /etc/mplayer/input.conf and ~/.mplayer
I prefer editing the /etc/mplayer/input.conf.
Assign shortcuts to aspect aspect ratio switching as follows
a switch_ratio 1.3333 # 4:3 s switch_ratio 0 # switches back to original aspect ratio b switch_ratio 1.7777 # 16:9 ratio
put his at the end of /etc/mplayer/input.conf.

A script to automount external USB HDD with the executable bit set

Recent releases of Ubuntu mounts external USB HDD in userspace and hence it does not set the executable bit on the drive. As a result if I try to run softwares or scripts installed in the external HDD I have to pmount it manually. So I wrote a small script which would - 1. verify that drive is mounted. 2. it is not empty(from a previous manual mount unmount cycle) 3. then unmount the drive and re-mount it in userspace with the executable bit set.
I wanted this script to be minimal. So I did not make it complicated which accepts a drive LABEL from the user and uses it. Just replace your drives LABEL in place of "passport-2" in the second line of the script. So if your external drive is called Sandisk replace passport-2 with Sandisk. If it turns out that the script fails due the use of $LABEL, then replace all $LABEL in the entire script with your drive label manually.
================================== #!/bin/bash $LABEL=passport-2 cd /media # check if $LABEL exists if [ ! -d &qu…

Minimal install LaTeX without documentation

The LaTeX package for Linux is the texlive package. The normal install of texlive is huge due to the documentation included can go upto 500MB itself. A leaner latex is what we all desire. It is not possible from inside Synaptic.
Use this command to install latex without docs.
sudo apt-get install --no-install-recommends texlive texlive-pstricks texlive-fonts-extra prosper

How to buy a laptop

Laptop is a  very specialized piece of equipment. It has to chosen carefully in order to suit your needs and not just by looking at benchmarks. That procedure is for desktops.

I will not list laptop models or vendors here because the hardware and configurations change so fast that by next day it would be outdated. To figure which ones are topping the list go to, But remember the your final choice might be complete different than the ones they recommend. But if you sure that this is what I need then go ahead.

Now let us see how to choose the right laptop.

To select a laptop answer these first

1. Why do I need it ?
2. What do I expect from it?
3. How much spending can I afford ?
4. How much battery life I want?
5. How long do I want my laptop to be mainstream?


A> Business - This means you have to make presentations with it. And travel a lot.

Options : Business laptops are available to suit this niche. But personally I would say - Buy one lapt…

To give a listing of hidden directories

ls -al | grep "^d" | grep "\." | tr -s " " | cut -d" " -f8

The "ls" lists all files. The first grep chooses the directories only and not files. Remove this to select hidden files too. The second grep selects hidden files - files tarting with a “dot”. It has to be escaped with \ otherwise it matches all characters. tr compresses extra spaces in the listing. “cut” selects the last column which is the hidden directory names. Without the tr compressing the delimiting spaces “cut” will mistake extra spaces to be new columns so the penultimate step is crucial.

A simple laptop battery monitor script

The script displays alert when the battery falls below 20% or charges up beyond 80% which should be the optimal range of its working.

The code is as below. Just copy and paste and save as any file name but preferably The script can independent of what name it is given. Needs to have acpi (default install) and notify-send installed (sudo apt-get install notify-osd).



# battery-notify v1.2 by JOnes

# It is a script to monitor battery and keep it between 20% to 80% the optimal battery working range. If the battery goe beyonds the set limit it gives pop-ups every 10 seconds. No sound warning as sound can easily be muted and ignored.
# Things that could be added : 1> The flexibilty of range. But it is not recommended  hence not implemented. 2> Notification in form of email or sms. 3> Sound / beep for critical state of battery.
# The script goes into background. To kill it at any time use : kill `pgrep battery-no…

How to choose a webcam

I am biased. I prefer Linux. So i am going to talk about webcams which work in Linux.
The primary driver for webcam in Linux is the UVC driver. Goto the UVC site and look for the supported hardware -

Other drivers available are SPCA drivers. The official website .
describes the installation details.

For supported hardware look at -

For step by step procedure, look at the video at

For Skype tested webcams -

For more information go to
To test my webcam and adjust its brightness I use vlc and v4l2ucp. Cheese and v4l2upc combo can also be used. Here's what I do. (vlc needs to be installed)
vlc v4l2:///dev/video0
In another terminal open v4l2ucp, the Video 4 Linux v2 control panel.
Now in the v4…

Top places to live in India

Today we will debate on which is the best city to live at this moment in India. While deciding on the comfortableness of living in a city the following properties are to be kept in mind.
1. Security.
2. Lifestyle and quality of living available to the masses including general economic health.
3. Climate.
3. Public transport.
4. Quality of public life support services offered by the city which includes but not limited to - public health services or hospitals, firefighters.

 I will present both pros and cons of each city. Since cons mostly is the deciding factor, sometimes only that is to be all that is to be mentioned. I will let people decide for themselves.

1. Mumbai is too damp and crowded. Life is hard. So is finding a place to stay. For an old resident it might be easier. And it is always so crowded in the railways, the heart of its public transport. Quality of living is high for certain factions while the rest are left to settle for mediocratic complacency. Its like two masses e…

Split djvu into jpg files

In order to convert a djvu file into a collection of jpg files two tools are needs. One is djvulibre and the other is Imagemagick. Install these first.

One way to convert would be to follow these instructions from
To extract images from a DjVu file, you can use ddjvuddjvu -page=8 -format=tiff myfile.djvu myfile.tif If you done all the pages (without -page=**) you can split the multi-page tiff into single pages png (or any other format)convert -limit area 1 myfile.tif myfile.png
But if the djvu has more than 8 pages then all these pages would be included into the tiff. When Imagemagick tries to convert that tiff and splits it into jpgs then it runs out of cache with the following error.

convert: unable to extend cache file.tif': @ error/cache.c/OpenPixelCache/4175.

It could be remedied but I do not know how. The solution might to limit the memory map

But instead a bash script can…

Make all output formats available in Kdenlive

In Kdenlive more often than not I had found that many render options are grayed out. Particularly the flv formats. It would say "unsupported video codec" when the mouse is hovered over each crossed and grayed out item. This means that these codes are unavailable in the system. Most probably all codecs are correctly installed but some are in the restricted section hence not installed by default. For example, the extra codecs. To install them first we have to turn on the "multiverse" and "Medibuntu" repos. See to find out how to add that repo. (Medibuntu is not needed for what we are going to install now, but add it anyways as it has lot of good useful codecs). Then we can proceed to install all possible extra codecs needed by Kdenlive.

Depending on the system or OS version the following must be installed

libavcodec-extra-52 libavdevice-extra-52 libavfilter-extra-0 libavformat-extra-52 libavutil-extra-49 libpostproc-extra-51 libswscale-extra-0

Latex in chat gmail and pidgin

We write equations in latex to collaborators but most of them have to be read and interpreted in latex. It is only too natural to have some interpreter which converts the latex code into graphical output in the communication mediums like email client and chat clients. I would describe three possible ways to share equations with collaborators.

Gmail - To send equations in email had always been hassle. Either we had to send the raw latex codes or send copy paste of the output from some latex compiler. Now, latex codes could directly be compiled in gmail. Install, gmailtex The site provides all information needed to get it working. I prefer the greasemonkey script method because no fonts etc. needs to be installed. But since it fetches fonts online you need to have good internet connections. For slow connections stick to local install methods.
Note - Just remember to turn off rich text formatting for gmailtex to be able to compile.
Gmail chat - http://users…

Vertical scroll not working HP Pavilion dm3 Notebook Touchpad in Natty/Ubutnu

This is a generic issue and not tied with HP Pavilion dm3 Notebooks. Many notebook touchpads do not have a working edge scroll first time with Ubuntu. The key is to pass a option to the psmouse module.


See if psmouse is running. If not running check here

/lib/modules/`uname -r`/kernel/drivers/input/mouse

Do a ls. If no psmouse.ko is present then it has to be recompiled with latest kernel headers. I would not go into that.

Assuming psmouse is present. Then unload it by

rmmod psmouse

Then inject the following line

sudo echo "options psmouse proto=imps" >> /etc/modprobe.d/psmouse.conf

It might give an error if the file is not present. Then

sudo echo "options psmouse proto=imps" > /etc/modprobe.d/psmouse.conf

Reload the psmouse module

modprobe psmouse

The vertical scroll should work now.

Reinstalling GRUB Legacy after windows reinstall

After Windows reinstall the windows would overwrite the GRUB. If using Ubuntu 9.10 or later or have the GRUB2 installed then see here - 1. 2.
If using older GRUB legacy version then the situation is a little bit tricky but not hard. There are two ways to do this.
A) Use older LiveCD, possibly of Jaunty.
1. Make a bootable USB. Use unetbootin and not the Startup disk creator otherwise you will have the error
vesamenu.c32: not a com32r image
2. Boot into LiveCD.
3. Run grub
sudo grub
4. Find where Grub is.
grub> find /boot/grub/stage1 (hd0,5)
This may or may not be the correct partition where grub resides. If there is /boot partition in addition to a root partition then there might two locations where grub is installed for e.g. /dev/sda5/boot/grub and /dev/sda6/boot/grub. The one that contains the menu.lst is the one that is to be used.…

An essay on time : Saugata Chatterjee

Time is something we experience every day. Curiosity about the nature of time dates pre-civilization times, more than 30,00 years ago, when men drew the phases of moon and counted days. But serious thoughts about nature of time was begun only much later, in Europe, by Socrates, who plunged the idea deep into the philosophical school of Greece and taken forward by Plato and in India. where people pondered over true nature of creation. The Greco-Roman concept of time was practical, involving measurement of time. The Indians took it many more leagues further by describing time as infinite (Lord Vishnu floating eternally and creating universe out of nothingness). The concept of infinity might have also entered Vedic culture in the context of creation and the role of time, but infinity might be used from a different perspective. The endless cycles of time divided into 4 major "Yugas" clearly depicts that ancient Hindus conceived time as endless but the only way they could incorp…

Executable bit not set for external USB hard disks problem workaround

Problem : Previously the Linux system could automount external HDDs with executable permissions. Any file could be run directly from the hard disk. But the flip side was that almost many files including text files used to get the executable bit set. Hence Nautilus attempted to autorun the HDD. This apparently confused many first time users. So from 10.10 onwards Ubuntu stopped setting the executable bit on external HDDs. At what level it is done UDEV, HAL or PMOUNT is unclear tome. But since pmount is the final piece the workaround could be applied there.
Workaround :
First plug in the external disk. Display the mount points.
See where is the mount. For eg.
/dev/sdb1 /media/My-Passport
Then unmount the disk as root su umount /media/My-Passport
Then as a normal user mount it using the pmount wrapper for mount with the executable bit set for ALL files.
pmount --fmask 077 -d -e /dev/sdb1 My-Passport
fmask of 0 makes everything executable. pmount man claims that VFAT supports per file umask. B…

RAW record audio streams playing thorugh the PC speakers

RAW record audio streams playing in browsers like Firefox, Chromium or any streaming player like Quicktime, Realplayer, Helixplayer etc.
The best way to copy the audio streams available through the PC speakers is to stream copy through Pulse in Ubuntu.
Lucid Lynx 10.04 and Maverick Meerkat 10.10
These instructions describe how to record any audio stream that are piped through to your sound system (e.g., external speakers, headphones) using Audacity. Any KDE recording software should work. For the purposes of this example, the audio (voice, music, or soundtrack) player will be Sonic Visualiser but could be any sound source (e.g., MPlayer, VLC, Firefox Flash video, MIDI device). The "PulseAudio Volume Control" program is not installed by default, but can be installed by typing the command sudo apt-get install pavucontrol from a terminal window, or using the System Settings' Software Management to install the pavucontrol package. 1. Click the K menu. 2. Click Multimedia » PulseA…

Bulk rename files in Linux

Use the rename command :

To add the album title at the beginning :$ rename -v 's/^/TITLE-HERE-/' *.mp3

-v : verbose
s : substitute. it acts in the same way as regular expressions do in SED.

To replace a part of filename: $ rename -v 's/MISC\.\ -/Fossils-/' *.mp3

e.g. :-
MISC. - 01.mp3 to Fossils-01.mp3
MISC. - 02.mp3 to Fossils-02.mp3
MISC. - 03.mp3 to Fossils-03.mp3

To rename to lower case: $ rename 'y/A-Z/a-z/' *

To rename recursively: $ find ./ -type f -exec rename 'y/A-Z/a-z/' {} \;

Linux command : find

find & xargsPart of the reason why the Linux command line is so POWERFUL! Finding files can be a daunting task, given the vast number of files on your average Linux filesystem. The number of system files in an average Linux install is well into the tens of thousands, or even hundreds of thousands of files. That's not counting user files!
The command `find` is, as it's name implies, used to aid you in finding files you are looking for, anywhere in your filesystems. Plus much more (see below).

find can use a large number of other criteria to find a file.
The first argument to "find" is the directory (or directories) to perform the search. Example: find (and display) every file in your home directory: find $HOME"-name" the name of a file, or a partial name (basic regex). Example: find the file named "bookmarks.html" in your home directory: find $HOME -name bookmarks.htmlExample: find all files starting with the name "…