Monday, January 31, 2011

My first Gtk based C program

Information: GTk+ is a C Library used to build graphical user interfaces (GUIs). Although Gtk is written in C, but can be binded with other languages like C++, Python and C#.
To learn Gtk, I found gnome document library to be a great place.The tutorial are explained in detail and provide a great platform for the beginners to start using Gtk.



int main(int argc,char *argv[])


    GtkWidget *window;




    return 0;



Thursday, January 13, 2011

Restoring GRUB2

PROBLEM: Restoring the Grub2

INFORMATION: This post is for the dual-boot people who find their booting screen has been missing some operating system after fresh installation of fresh Ubuntu(grub2)/Windows 7.

NOTE: The steps given for restoring grub2 are for Ubuntu version later than 9.10 .


Restoring Grub2(Ubuntu 9.10 or later)

1)  Boot with bootable pen-drive or cd of Ubuntu.

2) Type this in terminal

sudo fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf4caf4ca

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20482843+  42  SFS
/dev/sda2            2551        9730    57666845   42  SFS

Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x329e329d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sdb2              14        1810    14432040    7  HPFS/NTFS
Partition 2 does not end on cylinder boundary.
/dev/sdb3            1913        9729    62785769+   5  Extended
Partition 3 does not end on cylinder boundary.
/dev/sdb4            1810        1913      824040   82  Linux swap / Solaris
Partition 4 does not end on cylinder boundary.
/dev/sdb5            1913        4023    16949488+  83  Linux
/dev/sdb6            5929        9167    26006368+   7  HPFS/NTFS
/dev/sdb7            9167        9729     4520848+   7  HPFS/NTFS
/dev/sdb8            4023        5929    15307776   83  Linux

The above output shows presence of 2 hard-disks . One /dev/sda and other one being /dev/sdb.
I have 2 linux partition present(Ubuntu 11.10-(/dev/sdb8) & Ubuntu 11.04:(/dev/sdb5))

3) Check your partition on which your Ubuntu is installed. I am using /dev/sdb5

4) Make a directory in /media using the command:

sudo mkdir /media/sdb5

5) Now mount your partiotion into above created directory

sudo mount /dev/sdb5 /media/sdb5

6) To install your grub on your drive use grub-install as follows. Note: /dev/sdb is used as it is the boot partition (look at the fdisk output)

sudo grub-install --root-directory=/media/sdb5 /dev/sdb

7) If you miss “grub.cfg” file,use following to recreate:

mount --bind /proc /mnt/proc
 mount --bind /dev /mnt/dev 
mount --bind /sys /mnt/sys 
chroot /mnt update-grub 
umount /mnt/sys 
umount /mnt/dev 
umount /mnt/proc

Some useful Keyboard Shortcuts

INFORMATION: As well as using your mouse to operate software, you can also use your keyboard to perform specific functions. This post provides a list of keyboard shortcuts which you may find useful.The list has been made for Ubuntu 10.04.
To find (and change) system-level keyboard shortcuts, one can (at least in later, GNOME-based distros, e.g. ubuntu karmic) run the Keyboard Shortcuts applet, e.g. via System>Preferences>Keyboard Shortcuts on the main menu.

NOTE: Although most of the shortcuts works in all the versions but with development of new Ubuntu versions you may find some of them to be obsolete.


1.) Open TERMINAL : Ctrl + Alt + T

2.) Minimizing all windows(or toggle Show Desktop): Ctrl + Alt + D

3.) Open RUN window: Alt + F2

4.) Take Screen-shot of Whole Screen : Prt Sc

5.) Take Screen-shot of the current window: Alt + Prt Sc

6.) Switching between currently opened windows in Forward direction : Alt + Tab

7.) Switching between currently opened windows in Reverse direction : Alt + Tab + Shft

8.) Switching between workspaces Left/Right :  Alt + Ctrl + Left/Right Arrow

9.) Move Current window to Left/Right Workspace : Alt + Ctrl +Shft +Left/Right Arrow

10.) Switch to Console Mode:  Ctrl + Alt + F1 (F2-F6)

11.) Switch between Consoles in Console Mode: Alt + F1(F2-F6)

12.) Switch to GNOME GUI mode : Alt + F7 or type startx (in CLI) 

13.) Create a folder : Ctrl + Shft + N

14.) Copy/Paste content from terminal: Ctrl + Shft + (C/V)

15.) Clear the screen in terminal: Ctrl + L





Sunday, January 2, 2011

Broadcom STA wireless driver installation with NO internet access

PROBLEM : Wireless network connection was not established in Ubuntu 10.04 (Lucid Lynx) .

INFORMATION : I had a wireless BSNL modem connection. Ubuntu 10.04 was unable to detect wireless connection. Although windows 7 had previously established wireless connection automatically.The problem with ubuntu was that the Broadcom STA wireless driver was not installed by default. Being without wired connection I was unable to install/update the drivers.We need to install bcmwl-kernel-source package to solve the problem.But bcmwl-kernel-source package is dependent on 3 other packages.So we need to install those packages first.


1) Identify your Card/Driver.If your card/driver is of BCMxx type then only you should go with following steps.

2) I had a problem in installation because of ndiswrapper package. As ndiswrapper was blocking bcmwl to work upon. So I removed ndiswrapper package first, then went on to install bcmwl with steps given below.


1) Identifying your Card/Driver

1.1) Open the terminal window by pressing (Ctrl+Alt+T) and enter the following command (in red color):
lspci -vvnn

1.2) Check the network Controller information, Ex.(grey color) :
03:00.0 Network controller [0280]: Broadcom Corporation BCM4322 802.11a/b/g/n Wireless LAN Controller [14e4:432b] (rev 01)
Note:To follow more instructions, Your card should be of BCMxx type in above command output

2) If your driver is STA and have no Internet access then perform following steps.

2.1) Browse through the LIVE USB/CD or ISO file of the Ubuntu10.04. Navigate and install the packages listed below by double clicking.

a) ../pool/main/d/dkms
b) ../pool/main/p/patch
c) ../pool/main/f/fakeroot
d) ../pool/restricted/b/bcmwl

2.2 ) Under the desktop menu System > Administration > Hardware/Additional Drivers, the STA drivers can be activated for use.


a)For temporary use with the LiveCD and LiveUSB environments, instead of a computer restart, in a terminal issue the following commands(in red color):

~$ sudo modprobe -r b43 ssb wl
~$ sudo modprobe wl

b)For permanent use, restart may be required before using the wifi card.

2.4)Your wireless connection must be activated now.