Sunday, January 22, 2012

Installing Grub Boot loader in Linux

Grub (GRand Unified Boot Loader) is basically a boot loader which detects the operating systems installed in your computer and then lets you to opt for any of those from a given list.Its commonly distributed with the UNIX(Linux/ Mac) based system.

Reasons why people manually install grub is usually when someone installs windows in a machine where already a Unix based operating system is present, what actually happens is while you install windows, windows thinks/assumes that there is no other  OS in your system and it overwrites your boot loader with its own boot loader which never detects UNIX based OS which causes the system to boot directly into windows without letting the user to choose any other OS.


The situation should be like this that you had a Linux based OS in your system and you installed windows in the same which resulted in disappearance of Linux(In this context I'm talking about Ubuntu) based OS.

Using GUI tool called Boot-repair

This is perhaps the easiest and best way to get out the grub mess, without this tool it will be difficult for a normal user to install grub until and unless he understand the basic of terminal commands.


  • Boot into Ubuntu using a live disk or boot-able usb of Ubuntu (Make sure that its the same version of Ubuntu which you already have in system because grub differs for different versions of Ubuntu)
  • Configure your Internet connection
  • Install Boot-repair using these commands

  • sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
    sudo apt-get install -y boot-repair && boot-repair
  • Now either use the recommended settings or you may try advanced mode but I suggest you to go for the recommended option.It takes a while to complete the re-installation so be patient.

  • In case if you finds that there is any change or mistake in the option that grub is providing you now update grub after booting into your normal Ubuntu by using the following command

    sudo update-grub

Saturday, January 7, 2012

Running your first Assembly Language program using NASM.

Netwide Assembler (NASM) is an assembler and dissembler for the Intel x86 architecture and is commonly used to create 16-bit, 32-bit (IA-32) and 64-bit (x86-64) programs. It is available for multiple operating systems like Linux or Windows, for example.
An assembler can assemble the assembly code.

Here is a sample code(assembly language) which I copied from Nasm website.Now lets try to compile and run it using nasm.

section .data
 hello:     db 'Hello world!',10    ; 'Hello world!' plus a linefeed character
 helloLen:  equ $-hello             ; Length of the 'Hello world!' string
                                    ; (I'll explain soon)

section .text
 global _start

 mov eax,4            ; The system call for write (sys_write)
 mov ebx,1            ; File descriptor 1 - standard output
 mov ecx,hello        ; Put the offset of hello in ecx
 mov edx,helloLen     ; helloLen is a constant, so we don't need to say
                      ;  mov edx,[helloLen] to get it's actual value
 int 80h              ; Call the kernel

 mov eax,1            ; The system call for exit (sys_exit)
 mov ebx,0            ; Exit with return code of 0 (no error)
 int 80h


Compiling and Linking

  1. If you don't have a terminal or console open, open one now.
  2. Make sure you are in the same directory as where you saved hello.asm.
  3. To assemble the program, type
    nasm -f elf hello.asm
    If there are any errors, NASM will tell you on what line you did what wrong.
  4. Now type 
    ld -s -o hello hello.o

    This will link the object file NASM produced into an executable file.
  5. Run your program by typing ./hello
    (To run programs/scripts in the current directory, you must always type ./ before the name, unless the current directory is in the path.)
You should see     Hello world!    printed to the screen. Congratulations! You have just written your first assembly program in Linux!

Courtesy : Nasm website.

How to make touchpad to work with Linux

I have laptop Asus K53SV and the touchpad was recognized as a mouse only. All of the features that it offered were just navigating the pointer, no scrolling, no disable when typing etc.

This tutorial is applicable for Linux Mint and Ubuntu.

There is a patch available (elantech) which solves this issue and the touchpad is recognized with all (at least some :) ) features.

First, install the dkms (Dynamic Kernel Module Support) package if it is not already installed on your machine:

sudo apt-get install dkms

Then, download the patch:

cd /usr/src/
sudo wget

Unpack the patch:

sudo tar jxvf psmouse-elantech-v6.tar.bz2

Add the patch to the psmouse module:

sudo dkms add -m psmouse -v elantech-v6

Build it:

sudo dkms build -m psmouse -v elantech-v6

Install it:

sudo dkms install -m psmouse -v elantech-v6

For successful installation you should get something like this at the end: DKMS: install Completed.

Now, to load the new module with the patch included, you will need to either reboot your machine or reload the new module by executing the following command:

sudo rmmod psmouse && sudo modprobe psmouse

Now, go to System -> Preferences -> Mouse -> Touchpad and you will see all the settings that are available for the touchpad! :)

Courtesy :