Friday, September 17, 2010

Protect GRUB with password

GRUB is very important since it is the first software program that runs when the computer starts
and we have to secure it as much as possible to avoid any possible problem. Below is a default GRUB configuration file and security I recommend you to apply. The text in bold are the parts of the configuration file that must be customized and adjusted to satisfy our needs.
Edit the grub.conf file (vi /boot/grub/grub.conf) and set your needs. Below is what we recommend you:
default=0
timeout=0

splashimage=(hd0,0)/grub/splash.xpm.gzpassword --md5 $1$oKr0ÝmFo$tPYwkkvQbtqo1erwHj5wb/
title Red Hat Linux (2.4.18-3)
root (hd0,0)
kernel /vmlinuz-2.4.18-3 ro root=/dev/sda5
initrd /initrd-2.4.18-3.img


password --md5 $1$bgGCL/$4yF3t0py.IjU0LU.q7YfB1

This option “password” is used to inform GRUB to ask for a password and disallows any
interactive control, until you press the key <p> and enter a correct password. The option --md5
tells GRUB that a password in MD5 format is required as a value. If it is omitted, GRUB assumes
the specified password is in clear text.
When we have installed the operating system, we have already configured GRUB with a
password protection. This password is what you see here. If you want to change it, you have to
use the “grub-md5-crypt” command to generate a new encrypt password it in MD5 format.
• This can be done with the following command:
[root@dev /]# grub-md5-crypt
Password:
$1$bgGCL/$4yF3t0py.IjU0LU.q7YfB184

Once the above command has been issued, you have to cut and paste the encrypted password
to your configuration file.

Monday, September 06, 2010

tar Magic

Tar is commonly used for packaging files on Linux. Tar uses many command-line options like following:

-f    To use a tarfile
-c   To create a new tarfile
-x   To extract files from a tarfile.

You also can compress the resulting tarfile via two methods. 
-j    To use bzip2
-z    To use gzip

You can tar up a directory and all of its subdirectories by using:
tar cf archive.tar dir

Then, extract it in another directory with:
tar xf archive.tar

When creating a tarfile, you can assign a volume name with the option -V . You can move an entire directory structure with tar by executing:
tar cf - dir1 | (cd dir2; tar xf -)

You can move an entire directory structure over the network by executing:
tar cf - dir1 | ssh remote_host "( cd /path/to/dir2; tar xf - )"

If you want to get a dump of your current filesystem to a secondary hard drive, use (as root):
tar -cvzf /dev/hdd /

If you are writing your tarfile to a device that is too small, you can tell tar to do a multivolume archive with the -M option.

You can back up your home directory to a series of floppy disks by executing:
tar -cvMf /dev/fd0 $HOME

If you are doing backups, you may want to preserve the file permissions. You can do this with the -p option. If you have symlinked files on your filesystem, you can dereference the symlinks with the -h option. This tells tar actually to dump the file that the symlink points to, not just the symlink.

Along the same lines, if you have several filesystems mounted, you can tell tar to stick to only one filesystem with the option -l.

Wednesday, September 01, 2010

Recover Your Fedora Core

In case of dual OS, if u install windows (with pre-installed fedora), the boot loader will be lost and fedora become inaccessible. You can recover your Fedora by the following method:
Enter ur first CD of fedora core, reboot it.
Type linux rescue
Then on shell type chroot /mnt/sysimage
grub-install /dev/XXX (choose XXX=sda or hda or hdb as per ur system )
Reboot your Syatem
To know what is XXX type
# /sbin/fdisk -l
u'll see some lines with /dev/XXX , get what is XXX