Category Archives: linux

bash script to check if a process instance is running

if [ $# -ne 2 ]
echo "$0 process_name instances_count"
exit 1

function count_match {
echo Count Match #Your code goes here

function count_mismatch {
echo Count Mismatch #Your code goes here


run_count=`ps eax | grep ${process} | grep -v grep | wc -l`

if [ ${exp_count} -eq ${run_count} ]

Please note “grep -v grep” is not be required for cygwin, but even if you retain it, it doesn’t alter the behavior.

How to boot Linux using Windows bootloader (XP)

You want to setup dual boot on your computer but do not want to install Grub or Lilo (You still are use LILO?), then read on….

Otherwise, if you are tired of Windows over writing Grub or LILO every time you setup Windows, then you can sacrifice the powers of Grub and shift to Windows Boot Loader to boot you into Linux.

Here are the steps: (Ideal case)

Windows XP Loader (NT Loader) needs Linux Master Boot Record (MBR) to boot into Linux.

If you can boot into Linux, grab the first 512 bytes of boot sector from the root partition of Linux  where Grub is installed (/dev/sdaN) to an external drive.

 dd if=/dev/sdaN of=grub.bin bs=512 count=1

Here is the twist!

In my case, I had an existing Linux installation but I could not boot into Linux and I didn’t have a rescue disk. I installed Ext2 IFS For Windows and copied MBR which I had extracted previously before I wiped out Grub  /boot/grub/stage1 and named it grub.bin (Your MBR is nothing but stage1 boot-loader used by GRUB).

To setup Windows bootloader to load Linux, we need to add an entry corresponding to Linux.

Boot into Windows. Set appropriate attributes for boot.ini so that it is editable.

attrib -r -w -s c:\boot.ini

Add the following entry to the file boot.ini

 c:\grub.bin="Ubuntu Linux 7.10"

Restart the machine and Windows XP boot loader shows Ubuntu Linux 7.10 as one of the options.

Select this option and viola! you should see Linux booting 🙂

For more detailed instructions follow this : provides a specialized rescue disk to restore Windows/Linux. I haven’t used it anytime though.

Adobe Flash Plugin .deb package

To install Adobe Flash plugin for Mozilla Firefox on Ubuntu Gutsy, download .deb package from

sudo  dpkg --install flashplugin-nonfree_9.0.115.0ubuntu2_i386.deb

Sound advice on sound card configuration in Linux

I use HP Compaq nx6325 notebook with ATI – SB450 HDA Audio, with Ubuntu Feisty for x64.
This setup has a strange problem that it can’t switch off speakers when a headphone is connected (and some times vice versa). So Googled a bit and read a couple of postings in the forums.

One of the suggestions was to “rmmod snd-hda-intel && modprobe snd-hda-intel probe_mask=8 model=auto”.
I tried this approach and there was NO SOUND, the best part is no sound card was detected. I reinstalled kernel, alsa-drivers and tried many utilities.

Finally something struck me and then I found that /dev/dsp and /dev/mixer character devices had mysteriously disappeared.
So I went ahead and created this device “mknod /dev/dsp c 14 3”.
Voila!! Now, there is sound every where; I can get a sound sleep 🙂

Developing software using virtualization – VirtualBox

Virtual Machines have made possible development strategies which didnt exist so far.Using my Windows laptop, I can install Linux/Solaris/Or some other version of Windows to develop applications on that platform.This also has additional benefit that in case something goes wrong with the target platform, all you need to do is just copy the back up of VM or revert to a known snapshot. Simple! No formatting/re installation cycles:) A couple of weeks ago, I switched  back to Windows (from Ubuntu). But I find Linux so fast and friendly that I still tend to do my coding under Ubuntu. For this I considered VMWare and VirtualBox.I have used VMWare in the past, it is very good and has many advanced features but it’s a resource hog. I would prefer to keep my CPU and disk activity as low as possible, so I set out to try VirtualBox (which now is a Sun company btw). VirtualBox takes a lot less disk space than VMWare, it can use existing VMWare images and provides almost equivalent functionality. It has decent audio, networking and USB support. Shared folders are useful feature too. However I couldn’t setup networking on my guest OS (Ubuntu 8.04).

I run Windows XP and Ubuntu as guest OS under my Windows XP laptop and performance has been decent. At times disk activity drags my system, but on the whole my 1GB RAM, 5400 rpm HDD and Intel Core Duo processor seem to handle the load gracefully. GNOME development kit, Solaris are now available as VMWare appliances, which can be downloaded and used very easily.