Everytime I search the net for the basic steps in compiling and burning my programs. So, I wanted to record it here.
I use ATmega32 microcontroller and USBasp programmer.
Compile
$ avr-gcc -mmcu=atmega32 -Os first.c
Convert to hex
$ avr-objcopy -j .text -j .data -O ihex a.out first.hex
Before burning the hex file set the clock
$ avrdude -p m32 -P usb -c usbasp -tuF
avrdude>sck 10
avrdude>quit
Burn it to the microcontroller
$ avrdude -p m32 -P usb -c usbasp -U flash:w:first.hex
To erase the chip:
$ avrdude -p m32 -P usb -c usbasp -tuF
avrdude>sck 1000
avrdude>e
avrdude>sck 10
avrdude>quit
PS: avrdude requires administrative privilege to execute, so it is suggested to use sudo command.