Friday, April 15, 2011

Restore GRUB

GRUB is the default bootmanager in linux. It helps to choose the desired OS to boot on the booting stage.It shows a list of OS, so that we can choose anyone to boot. GRUB is so powerful that can understand the filesystem without booting the system.

The modern linux come with the latest GRUB and they recognize all the existing operating systems and add them into the list.

But the problem comes with the other OS like windowz. They dont believe that the system can have other OS too. They believe that they are the only OS in the earth.

In the dual boot machines, often the windows should be reinstalled because of various reasons. When we do the reinstallation of windows, it erases the GRUB which resides at MBR normally.

So, after re-installing windows, Most of newbies think that we have to re-install linux too. No. No. No. Linux never went out. It is safely in its partition only, until you deleted that partition.

Only the GRUB is washed out by windows. we can recover it easily.

Here are some ways to do it.

Needed Materials:
1. Any LiveCD or Live DVd like ubuntu, knoppix
or
The installation CD of your or any Distro.

Way – 1:

1. Pop in the Live CD, boot from it until you reach the desktop.

2. Open a terminal window or switch to a tty.

3. Type “grub”

4. Type “root (hd0,6)”, or whatever your harddisk + boot partition
numbers are (my /boot is at /dev/sda7, which translates to hd0,6 for
grub).

5. Type “setup (hd0)”, ot whatever your harddisk nr is.

6. Quit grub by typing “quit”.

7. Reboot.

Way -2:

1. Boot from a Live CD, like Ubuntu Live, Knoppix, Mepis, or similar.

2. Open a Terminal. Go SuperUser (that is, type “su”). Enter root passwords as necessary.

3. Type “grub” which makes a GRUB prompt appear.

4. Type “find /boot/grub/stage1″. You’ll get a response like “(hd0)” or
in my case “(hd0,3)”. Use whatever your computer spits out for the
following lines.

5. Type “root (hd0,3)”.

6. Type “setup (hd0)”. This is key. Other instructions say to use
“(hd0)”, and that’s fine if you want to write GRUB to the MBR. If you
want to write it to your linux root partition, then you want the number
after the comma, such as “(hd0,3)”.

7. Type “quit”.

8. Restart the system. Remove the bootable CD.

Way – 3:

1. Boot with any live CD (I’ve done it with Knoppix 3.x and Ubuntu)

2. Get a root shell and make a folder (mkdir ubuntu)

3. mount the root (/) partition of ubuntu (e.g. mount /dev/hdb ubuntu if you have two disks)

4. chroot the mounted partition (chroot ubuntu)

5. grub-install /dev/hda

5. Exit the shell

6. Reboot

Try any of the three ways.

There may be also so many ways to do this same thing. Try yourself and keep learning.

Setting up LAMP on your Ubuntu desktop

Many of you must be wanting to try some web development and would like to setup their own LAMP(Linux, Apache, MySQL, PHP/Perl/Python) stack. Ubuntu has a special Server Edition for setting up your own LAMP server, most of you may want to install it on your desktop (I like it that way).

This involves installing Apache, PHP, Python and MySQL. I think
Python will be installed by default and we only need to install
mod_python for Apache. I use Ubuntu Edgy Eft 6.10.

Apache 2

Apache is the most popular web server and I use it for my
development work. Apache 2 can be installed by running this command in
the terminal.

sudo apt-get install apache2

All your files should be placed in the /var/www/ folder to be viewed from your server.

PHP5

PHP is on version 5 and can be installed by running

sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart

You can easily test whether you have correctly installed PHP by writing a simple test file.

gksudo gedit /var/www/testphp.php

This will open a text editor and here insert this line. There should
be no space between < and ?. WordPress inserts a space in between. < ?php phpinfo(); ?>

Point your browser to http://localhost/testphp.php

MySQL Server

Next install MySQL server

sudo apt-get install mysql-server

MySQL by default allows connections only from 127.0.0.1 i.e., only
from your own computer. This is ok if you are developing only on your
own system. If you want to access your MySQL server from a network,

gksudo gedit /etc/mysql/my.cnf

Find the line bind-address = 127.0.0.1 and comment it. Comments start with ;(semicolon).

If you want to set a different password to your MySQL server (than the default none),

mysqladmin -u root password your-new-password
mysqladmin -h root@local-machine-name -u root -p password your-new-password
sudo /etc/init.d/mysql restart

Install MySQL for Apache

sudo apt-get install libapache2-mod-auth-mysql sudo apt-get install php5-mysql
sudo apt-get install phpmyadmin

After this, you have to enable the MySQL extension in your php.ini. Edit the file

gksudo gedit /etc/php5/apache2/php.ini

Here uncomment the line “;extension=mysql.so”

extension=mysql.so

After this restart Apache 2

sudo /etc/init.d/apache2 restart

Python

Python for Apache can be installed by installing the libapache2-mod-python package.

sudo aptitude install python
sudo aptitude install libapache2-mod-python

Javascript trick to edit the page displayed

Goto any website and paste

javascript:document.body.contentEditable='true';
document.designMode='on'; void 0

in the address bar.

Now you can edit anything in that page. Really cool trick.

Source:
http://fslog.com/2007/01/21/javascript-trick-to-edit-the-page-displayed/