Archive for the ‘Operating Systems’ Category

Merging VMWare files to single file

May 27, 2010 Leave a comment

A few days back I had to use a VMWare image, being not really a fan of VMWare I wanted to use it with VirtualBox ( and found out that .vmdk files from VMWare are supported in VirtualBox which was a sigh of relief but then got hit with another requirement…

VirtualBox supports single VMWare .vmdk file and the VM I had was using multiple small vmdk files which means it will not work in VirtualBox.

Next step for me was to find a way if possible to convert those multiple files into a single “big” .vmdk file that I can use with VirtualBox and that was in the end a single VMWare commad from the folder where I had all the small vmdk files:

# vmware-vdiskmanager -r smallfiles.vmdk -t 0 bigsinglefile.vmdk
Creating disk 'bigsinglefile.vmdk'
Convert: 100% done.
Virtual disk conversion successful.
….Once this was done it was just a matter of adding this new .vmdk file as a disk in VirtualBox and booting a VM from that.
Shoaib Mir
Categories: Operating Systems Tags: , ,

Reading XML file using shell script

May 2, 2010 2 comments

This was like the first time where I had to write something that will be able to read something out of a XML file using a shell script. Usually I would use Python/Perl as my favorite choices in such a scenario but in this one I really *had* to do all within a shell script.

This is an example of the type of XML file I had to read:

<changelog>Fixed a new bug</changelog>
<name>Shoaib Mir</name>
<date>Sun, 02 May 2010</date>

I ended up having a shell script like this:


#Looking for four keywords in here
for key in changelog name date email
OUTPT=`grep $key log.xml | tr -d '\t' | sed 's/^\([^<].*\)$/\1/' `
eval ${key}=`echo -ne \""${OUTPT}"\"`

# Getting the results in four specific arrays
changelogarr=( `echo ${changelog}` )
namearr=( `echo ${name}` )
datearr=( `echo ${date}` )
emailarr=( `echo ${email}` )

#Print all Arrays
echo ${changelogarr[@]}
echo ${namearr[@]}
echo ${datearr[@]}
echo ${emailarr[@]}

Which gives me an output:

shoaib@shoaib-desktop:~/Desktop$ ./
Fixed a new bug Shoaib Mir
Sun, 02 May 2010

Shoaib Mir

Printing PDF file with images

January 23, 2010 Leave a comment

A few days back I was having a terrible time when I tried to print a few tickets that I had in a PDF document. It all started since I upgraded my desktop Ubuntu to 9.1, didnt have time at that moment so asked a colleague to do the print for me.

Once I got time, after a little bit of googling found out that it was a package that I was missing which is needed for the rendering of images and that needs to be installed before I go on printing PDF docs with images in them.

It was:


Hope it helps someone else who is going through the same pain of not able to print out PDF docs πŸ™‚

Shoaib Mir

Categories: Operating Systems Tags: , ,

Disable notification system in Ubuntu

November 3, 2009 1 comment

I dont know about everyone else but for some reason I just found the notification system really annoying with my Ubuntu setup, after struggling with a few files and settings finally was able to get it all disabled.

Here is a quick how-to in case someone wants to disable/enable it….

For disabling use the following:

sudo mv /usr/share/dbus-1/services/org.freedesktop.Notifications.service 

To re-enable it:

sudo mv /usr/share/dbus-1/services/org.freedesktop.Notifications.service.
disabled /usr/share/dbus-1/services/org.freedesktop.Notifications.service

Shoaib Mir

Converting IMG files to Virtual Box VDI format

September 13, 2009 11 comments

In order to avoid installing the whole VM myself, I got an IMG file from a colleague for the CentOS VM. Now once I had the IMG file, but had not in the past converted it before to a VirtualBox compatible VDI format… after doing a little bit of research I found that to be a very simple process, so thought of sharing it with anyone who will like to do the same….

Once you have the .img file just run the following from command line:

VBoxManage convertfromraw -format VDI [filename].img [filename].vdi

Depending on the size of .img file it might take a little while as for my desktop machine it took like around 5 minutes for converting a 4GB img file to vdi format. Once its all done just add the VDI file as another disk, attach it to a VM in VirtualBox… start the VM and you just got it all working πŸ™‚

Shoaib Mir

Categories: Operating Systems Tags: , , ,

Configuring SSH access for VirtualBox Guest Host

September 13, 2009 6 comments

A few days back at work, I had to configure a CentOS VM and after I was done with installation on the host itself under VirtualBox I tried doing SSH to the CentOS VM and it didnt let me do that. I had it all configured with NAT and never thought that it will give me such a problem, googling it for a little while for an answer I found the solution… here is a quick howto for setting up SSH access to a VirutalBox VM:

Let <VMname> be the guest machine name (use quotes if it contains spaces), here are the commands that you have to execute for host machine console:

$ VBoxManage setextradata <VMname> “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort” 2222
$ VBoxManage setextradata <VMname> “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort” 22
$ VBoxManage setextradata <VMname> “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol” TCP

The HostPort must be greater than or equal to 1024 since listening on ports 0-1023 needs root permssions (and Virtualbox usually doesn’t).

Once all goes good with the commands, you need to exit out (close it) of the guest Machine (different from a reboot as a reboot will not be enough in this case), restart it and then connect via ssh with:

$ ssh -l username -p 2222 localhost

Replace “localhost” with the host machine IP address if you are connecting from another computer.

Shoaib Mir

Categories: Operating Systems Tags: , , ,

Using projector screen with Ubuntu

August 5, 2009 1 comment

Since upgrading to Ubuntu 9.04 I was having problems with using the projector for doing demos and all. It used to detect the signal from the projector to my video but I couldnt make my desktop to show on the projector screen. I didn’t care much about it then as I was able to get a colleague’s laptop and do my presentations but like last week I had to do a PostgreSQL training for which I really needed my laptop as I had setup almost everything on my machine for doing practicals.

So I thought of giving it a try to see if I can somehow make it work…

Googled it and found someone mentioning “Randr” and when I searched the same through apt-get I was able to find “Grandr” which is a GNOME Panel Applet that allows you to select screen resolution and orientation from the GNOME Panel.

Once I got it installed, connected the projector screen and opened up “Grandr” and then in the first try I was able to see my desktop on the projector screen… I did the following:

– Once Grandr was up I could see my laptop screen as LVGS and project screen as VGA
– Selected ‘Auto’ for VGA and used the normal resolution I go with for my laptop screen
– Clicked on Apply and thats it…

“Grandr ” came out very handy during the training and I was able to do the whole thing using my laptop πŸ™‚

Shoaib Mir