Friday 31 October 2014

History of AWK

History of AWK

The name awk comes from the initials of its designers: Alfred V. Aho, Peter J. Weinberger, and Brian W. Kernighan. The original version of awk was written in 1977. In 1985 a new versionmade the programming language more powerful, introducing user-de ned functions, multiple inputstreams, and computed regular expressions. This new version became generally available with System V Release 3.1. The version in System V Release 4 added some new features and also cleaned up the behavior in some of the \dark corners" of the language. The speci cation for awk in the posix Command Language and Utilities standard further clari ed the language.
We need to thank many people for their assistance in producing this manual. Jay Fenlason contributed many ideas and sample programs. Richard Mlynarik and Robert J. Chassell gave helpful comments on early drafts of this manual. The paper A Supplemental Document for awk by John W. Pierce of the Chemistry Department at UC San Diego, pinpointed several issues relevant both to awk implementation and to this manual, that would otherwise have escaped us. David Trueman, Pat Rankin, and Michal Jaegermann also contributed sections of the manual.

The following people provided many helpful comments on this edition of the manual: Rick Adams, Michael Brennan, Rich Burridge, Diane Close, Christopher (\Topher") Eliot, Michael Lijewski, Pat Rankin, Miriam Robbins, and Michal Jaegermann. Robert J. Chassell provided much valuable advice on the use of Texinfo.

Little more About AWK :

The term awk refers to a particular program, and to the language you use to tell this program what to do. When we need to be careful, we call the program \the awk utility" and the language \the awk language." The term gawk refers to a version of awk developed as part the GNU project. The purpose of this manual is to explain both the awk language and how to run the awk utility. The term awk program refers to a program written by you in the awk programming language. Most of the time complete awk programs are used as examples, but in some of the more advanced sections, only the part of the awk program that illustrates the concept being described is shown.

Data Files for the Examples :

Many of the examples in this manual take their input from two sample data les. The rst, called `BBS-list', represents a list of computer bulletin board systems together with information about those systems. The second data le, called `inventory-shipped', contains information about shipments on a monthly basis. Each line of these les is one record.

In the le `BBS-list', each record contains the name of a computer bulletin board, its phone number, the board's baud rate, and a code for the number of hours it is operational. An `A' in the last column means the board operates 24 hours a day. A `B' in the last column means the board
operates evening and weekend hours, only. A `C' means the board operates only on weekends.

aardvark 555-5553 1200/300 B
alpo-net 555-3412 2400/1200/300 A
barfly 555-7685 1200/300 A
bites 555-1675 2400/1200/300 A
camelot 555-0542 300 C
core 555-2912 1200/300 C
fooey 555-1234 2400/1200/300 B
foot 555-6699 1200/300 B
macfoo 555-6480 1200/300 A
sdace 555-3430 2400/1200/300 A
sabafoo 555-2127 1200/300 C

The second data le, called `inventory-shipped', represents information about shipments during the year. Each record contains the month of the year, the number of green crates shipped, the number of red boxes shipped, the number of orange bags shipped, and the number of blue packages shipped, respectively. There are 16 entries, covering the 12 months of one year and 4 months of the next year.
Jan 13 25 15 115
Feb 15 32 24 226
Mar 15 24 34 228
Apr 31 52 63 420
May 16 34 29 208
Jun 31 42 75 492
Jul 24 34 67 436
Aug 15 34 47 316
Sep 13 55 37 277
Oct 29 54 68 525
Nov 20 87 82 577
Dec 17 35 61 401
Jan 21 36 64 620
Feb 26 58 80 652
Mar 24 75 70 495

Apr 21 70 74 514

Friday 8 August 2014

List of Unix and Linux Certifications

List of Unix and Linux Certifications

The UNIX and Linux certifications are highly sought after by the employers today. So wondering which certification to choose? The leaders of the Linux and Unix world like the Red Hat and LPI, Oracle, Solaris, IBM, BSD have their own certifications for Linux professionals. Here's a list of 29 most popular certifications from 6 super popular giants of the industry!


Red Hat


The Red Hat certifications are specially popular for its format. It has 6 Linux certifications based on Red Hat Enterprise Linux which are purely based on Lab. No tests and questions.

Below are the 6 certifications offered:

1. Red Hat Certified System Administrator (RHCSA)
2. Red Hat Certified Engineer (RHCE) Red Hat
3. Certified Virtualization Administrator (RHCVA)
4. Red Hat Certified Datacenter Specialist (RHCDS)
5. Red Hat Certified Security Specialist (RHCSS)
6. Red Hat Certified Architect (RHCA)

LPI

Unlike the Red hat certification, LPI is a neutral company providing you knowledge on standard Linux irrespective of the distro. The group has 4 certifications in its portfolio:

7. Linux Essentials
8. Junior Level Linux Certification (LPIC-1)
9. Advanced Level Linux Certification (LPIC-2) Senior Level Linux
10. Certification (LPIC-3)

Novell

One of the industry legends, Novell, provides 4 Linux certifications for administrators based on SUSE. Below are the certifications:

11. Novell Certified Linux Engineer
12. Certified Linux Administrator
13. Certified Linux Desktop Administrator
14. Novell Certified Linux Professional

Oracle

Oracle not only has created a Linux distro based on Red Hat Enterprise Linux but is also providing Linux certifications. After the group acquired SUN with Solaris operating system, Oracle started Oracle Certified Associate, Professional and Master paths for the Solaris system. The group has 8 certifications on Linux and Solaris.

15. Oracle Solaris System Administrator (OCA)
16. Oracle Solaris System Administrator (OCP)
17. Oracle Solaris Network Administrator (OCE)
18. Oracle Solaris Security Administrator (OCE)
19. Oracle Solaris Cluster System Administrator (OCP)
20. Oracle Linux Administrator (OCA)
21. Oracle Linux Certified Implementation Specialist
22. Managing Oracle on Linux Certified Expert

IBM

While IBM has more than 200 certifications in their portfolio for associate level to advanced lever subjects, we could find 5 specialized Unix certifications for AIX:

23. IBM Certified Systems Expert – Enterprise Technical Support for AIX and Linux
24. IBM CSE – Virtualization Technical Support for AIX and Linux
25. IBM CSE – High Availability for AIX Technical Support and Administration
26. IBM Certified Operator – AIX Basic Operations
27. IBM Certified System Administrator – AIX

BSD
The BSD Certification Group Inc. has specialized certifications based on their BSD operating system. Their portfolio has 2 UNIX certifications:

28. BSD Associate (BSDA)
29. BSD Professional (BSDP)

Tuesday 29 July 2014

PS_13_Perl - Database Access in Perl

Database Access in Perl

Database Access
There are two primary means of accessing databases under Perl. The first (and oldest) makes use of the DBM (Database Management) libraries available for most flavors of UNIX. The second (and more powerful) allows for a platform-independent interaction with more sophisticated database management systems (DBMS’s) such as Oracle, Sybase, Informix, and MySQL.

DBM
A DBM is a simple database management facility for most UNIX systems. It allows programs to store a collection of key-value pairs in binary form, thus providing rudimentary database support for Perl. To use DBM databases in Perl, you can associate a hash with a DBM database through a process similar to opening a file:

use DB_File;
tie(%ARRAYNAME, “DB_File”, “dbmfilename”);

Once the database is opened, anything you do to the hash is immediately written to the database. To break the association of the hash with the file, use the untie() function.

DBI/DBD
DBI is a module that provides a consistent interface for interaction with database solutions. The DBI approach relies on database-specific drivers (DBD’s) to translate the DBI calls as needed for each database. Further, actual manipulation of the contents of the database is performed by composing statements in Structured Query Language (SQL) and submitting them to the database server. DBI methods make use of two different types of handles

1. Database handles (like filehandles)
2. Statement handles (provide means of executing statements and manipulating their results)

Database handles are created by the connect() method:

$db_handle = DBI->connect(‘DBI:mysql:dbname:hostname’,
$username, $password);
and destroyed by the disconnect() method:
$result = $db_handle->disconnect();

The first argument to the connect() method is a string describing the data source, typically written in the form:
DBI:driver_name:database_name:host_name

Statement handles are created by the prepare() method
$st_handle = $db_handle->prepare($sql)
where $sql is a valid SQL statement, and “destroyed” using the finish() method.

The SQL statement is then executed using the execute() method
$result = $st_handle->execute();
and the results obtained using any of the fetch() methods:
@ary = $st_handle->fetchrow_array(); # fetch a single row of the
# query results
$hashref = $st_handle->fetchrow_hashref();
%hash = %$hashref;

Note that you do not directly access the results the SQL statement, but obtain them one row at a time via the fetch() methods.

The following script connects to a MySQL database and prints the contents of one of its tables:
use DBI:
use strict:
my($dsn) = ‘DBI:mysql:test:localhost’; # Data source name
my($username) = ‘user’; # User name
my($password) = ‘secret’; # Password
my($dbh,$sth); # Database and statement handles
my(@ary); # array for rows returned by query
# connect to database
$dbh = DBI->connect($dsn, $username, $password);
# issue query
$sth = $dbh->prepare(‘SELECT * FROM tablename’);
$sth->execute();
# read results of query, then clean up
while(@ary = $sth->fetchrow_array()) {
print join(“\t”, @ary), “\n”;
}
$sth->finish();
$dbh->disconnect();

Thursday 24 July 2014

Bash Script for bulk user creation

 Bash Script for bulk user creation

By using this script you can create users interactively by your choice, from a file and even you can do modifications for a user such as change password, home directory, group and restrict login.

This code has been moved to GITHUB and you can access the code from the below link.

GitHub Link : Bulk User Creation


Sample file for user creation using file:

 adam:Adam_123:testgroup:/home/adam  
 shrikant:Shri_123:root:/uhome/shrikant  
 bob:Bob_1234:testgroup:/home/bob  
 hemant:Hem_123:testgroup:/home/hemant  
 sharat:Shar_123:testgroup:/home/sharat  
 prakash:Prak_123:testgroup:/home/prakash  
 scary:Scary_123:root:/uhome/scary  
 omkar:Omkar_123:root:/uhome/omkar  
 india:India_123:root:/uhome/india  
 bhagat:Bhagat_123:root:/uhome/bhagat  
 linux:Linux_123:root:/uhome/linux  



Monday 14 July 2014

PS_12_Perl - Common Gateway Interfaces

Common Gateway Interfaces

Perl is the most commonly used language for CGI programming on the World Wide Web. The Common Gateway Interface (CGI) is an essential tool for creating and managing comprehensive websites. With CGI, you can write scripts that create interactive, user-driven applications.

Simple CGI Programs
CGI programs are invoked by accessing a URL (uniform resource locator) describing their coordinates:
http://www.mycompany.com/cgi-bin/program.plx

even though the actual location of the script on the hard drive of the server might be something like:
c:\webserver\bin\program.plx

The simplest CGI programs merely write HTML data to STDOUT (which is then
displayed by your browser):
print << ENDOFTEXT;
Content-type: text/html
<HTML>
<HEAD><TITLE>Hello, World!</TITLE></HEAD>
<BODY>
<H1>Hello, World!</H1>
</BODY>
</HTML>
ENDOFTEXT
CGI.pm

CGI.pm is a Perl module written to facilitate CGI programming. It contains within itself the wherewithal to generate HTML, parse arguments and environment variables, and maintain state over multiple transactions. Another feature which is not to be underestimated is the ability to reliably run CGI programs from the command line for the purposes of debugging. A simple example of the CGI.pm module in action is shown below:
use CGI;
$query = CGI::new(); # create CGI object
$bday = $query->param(“birthday”); # get parameters
print $query->header(); # generate Content-type line
print $query->p(“Your birthday is $bday”);

Passing Parameters
CGI programs really shine, however, when they take arguments and format their output depending on those arguments. To pass arguments to a CGI script, ampersand-delimited key-value pairs to the URL:
http://www.mycompany.com/cgi-bin/icecream.plx?flavor=mint&container=cone

Everything after the question mark is an argument to the script. Environment variables provide the script with data about the server, client, and the arguments to the script. The latter are available as the “QUERY_STRING” environment variable. The following example prints all of the environment variables:
# Print all of the necessary header info
print <<ENDOFTEXT;
Content-type: text/html
<HTML>
<HEAD><TITLE>Environment Variables</TITLE></HEAD>
<BODY>
<CENTER><H1>Environment Variables</H1></CENTER>
<TABLE>
<TR><TH>Variable</TH><TH>Value</TH>
ENDOFTEXT
# Now loop over and format environment variables
foreach $key (sort keys %ENV) {
print "<TR><TD>$key</TD><TD>$ENV{$key}</TD></TR>\n";
}
print "</TABLE></BODY></HTML>\n";

CGI.pm is particularly good at extracting parameters in a platform-independent way:
use CGI;
$query = CGI::new();
print $query->header();
print $query->start_html(-title=>'Form Parameters');
print $query->h1('Form Parameters');
foreach $name ( $query->param() ) {
$value = $query->param($name);
print "$name => $value\n";
print $query->br(); # Insert a line break
}
print $query->end_html();

Database Access
There are two primary means of accessing databases under Perl. The first (and oldest) makes use of the DBM (Database Management) libraries available for most flavors of UNIX. The second (and more powerful) allows for a platform-independent interaction with more sophisticated database management systems (DBMS’s) such as Oracle, Sybase, Informix, and MySQL.

DBM
A DBM is a simple database management facility for most UNIX systems. It allows programs to store a collection of key-value pairs in binary form, thus providing rudimentary database support for Perl. To use DBM databases in Perl, you can associate a hash with a DBM database through a process similar to opening a file:
use DB_File;
tie(%ARRAYNAME, “DB_File”, “dbmfilename”);
Once the database is opened, anything you do to the hash is immediately written to the database. To break the association of the hash with the file, use the untie() function.

DBI/DBD
DBI is a module that provides a consistent interface for interaction with database solutions. The DBI approach relies on database-specific drivers (DBD’s) to translate the DBI calls as needed for each database. Further, actual manipulation of the contents of the database is performed by composing statements in Structured Query Language (SQL) and submitting them to the database server.
DBI methods make use of two different types of handles
1. Database handles (like filehandles)
2. Statement handles (provide means of executing statements and manipulating their results)

Database handles are created by the connect() method:
$db_handle = DBI->connect(‘DBI:mysql:dbname:hostname’,
$username, $password);
and destroyed by the disconnect() method:
$result = $db_handle->disconnect();

The first argument to the connect() method is a string describing the data source, typically written in the form:
DBI:driver_name:database_name:host_name

Statement handles are created by the prepare() method
$st_handle = $db_handle->prepare($sql)
where $sql is a valid SQL statement, and “destroyed” using the finish() method.

The SQL statement is then executed using the execute() method
$result = $st_handle->execute();
and the results obtained using any of the fetch() methods:
@ary = $st_handle->fetchrow_array(); # fetch a single row of the
# query results
$hashref = $st_handle->fetchrow_hashref();
%hash = %$hashref;
Note that you do not directly access the results the SQL statement, but obtain them one row at a time via the fetch() methods. The following script connects to a MySQL database and prints the contents of one of its tables:
use DBI:
use strict:
my($dsn) = ‘DBI:mysql:test:localhost’; # Data source name
my($username) = ‘user’; # User name
my($password) = ‘secret’; # Password
my($dbh,$sth); # Database and statement handles
my(@ary); # array for rows returned by query
# connect to database
$dbh = DBI->connect($dsn, $username, $password);
# issue query
$sth = $dbh->prepare(‘SELECT * FROM tablename’);
$sth->execute();
# read results of query, then clean up
while(@ary = $sth->fetchrow_array()) {
print join(“\t”, @ary), “\n”;
}
$sth->finish();
$dbh->disconnect();

Thursday 10 July 2014

PS_11_Perl - Object-Oriented Perl

Object-Oriented Perl

In Perl, modules and object-oriented programming go hand in hand. Not all modules are written in an object-oriented fashion, but most are. A couple of definitions are warranted here:

· An object is simply a referenced thingy that happens to know which class it
belongs to.

· A class is simply a package that happens to provide methods to deal with objects.

· A method is simply a subroutine that expects an object reference (or a package name, for class methods) as its first argument.

To create an object (or instance of a class), use the class constructor. Usually the class constructor will be a function named “new,” but may be called “Create” for some Win32 modules. For example,
$tri = new Triangle::Right (side1=>3, side2=>4);

The constructor takes a list of arguments describing the properties of the object to be created (see the documentation of the module in question to determine what these should be) and returns a reference to the created object.

An example of a class constructor (internal to the module) is shown below:
package critter; # declare the name of the package
sub new {
my $class = shift; # Get class name
my $self = {}; # Initialize the object to nothing
bless $self, $class; # Declare object to be part of class
$self->_initialize();# Do other initializations
return $self;
}

Methods (subroutines expecting an object reference as their first argument) may be invoked in two ways:
Packagename->constructor(args)->method_name(args)

Or:
$object = Packagename->constructor(args);
$object->method_name(args);
Methods are simply declared subroutines in the package source file.

Saturday 5 July 2014

PS_10_Perl - Modules

Modules

Namespaces and Packages:
Namespaces store identifiers for a package, including variables, subroutines, filehandles, and formats, so that they are distinct from those of another package. The default namespace for the body of any Perl program is main. You can refer to the variables from another package by “qualifying” them with the package name. To do this, place the name of the package followed by two colons before the identifier’s name:
$Package::varname
If the package name is null, the main package is assumed.

Modules:
Modules are Perl’s answer to software packages. They extend the functionality of core Perl with additional compiled code and scripts. To make use of a package (if it’s installed on your system), call the use function:
use CGI;

This will pull in the module’s subroutines and variables at compile time. use can also take a list of strings naming entities to be imported from the module:
use Module qw(const1 const2 func1 func2);

Perl looks for modules by searching the directories listed in @INC. Modules can be obtained from the Comprehensive Perl Archive Network (CPAN) at

http://www.cpan.org/modules/

or from the ActiveState site:

http://www.ActiveState.com/packages/zips/

To install modules under UNIX, unarchive the file containing the package, change into its directory and type:
perl Makefile.PL
make
make install

On Windows, the ActivePerl distribution makes use of the “Perl Package Manager” to install/remove/update packages. To install a package, run ppm on the .ppd file associated with the module:
ppm install module.ppd

Tuesday 1 July 2014

PS_09_Perl - Files and I/O

Files and I/O

Filehandles:
A filehandle is the name for the connection between your Perl program and the operating system. Filehandles follow the same naming conventions as labels, and occupy their own namespace.

Every Perl program has three filehandles that are automatically opened for it: STDIN,
STDOUT, and STDERR:
STDIN Standard input (keyboard or file)
STDOUT Standard output (print and write send output here)
STDERR Standard error (channel for diagnostic output)

Filehandles are created using the open() function:
open(FILE,”filename”);
You can open files for reading, writing, or appending:
open(FILE,”> newout.dat”) Writing, creating a new file
open(FILE,”>> oldout.dat”) Appending to existing file
open(FILE,”< input.dat”) Reading from existing file

As an aside, under Windows, there are a number of ways to refer to the full path to a file:
c:\\temp\\file” Escape the backslash in double quotes
c:\temp\file’ Use proper path in single quotes
c:/temp/file” UNIX-style forward slashes

It is important to realize that calls to the open() function are not always successful. Perl will not (necessarily) complain about using a filehandle created from a failed open().

This is why we test the condition of the open statement:
open(F,”< badfile.dat”) or die “open: $!”

You may wish to test for the existence of a file or for certain properties before opening it.

Fortunately, there are a number of file test operators available:
File test Meaning
-e file File or directory exists
-T file File is a text file
-w file File is writable
-r file File is readable
-s file File exists and has nonzero length

These operators are usually used in a conditional expression:
if (-e myfile.dat) {
open(FILE,”< myfile.dat”) or die “open: $!\n”;
}
Even more information can be obtained about a given file using the stat() function.

Using filehandles
After a file has been opened for reading you can read from it using the diamond operator just as you have already done for STDIN:
$_ = <FILE>; or
while (<FILE>) {
statements;
}

To print to your open output file, use the filehandle as the first argument to the print statement (N.B. no commas between the filehandle and the string to print).
print FILE “Look Ma! No hands!\n”;

To change the default output filehandle from STDOUT to another one, use select:
select FILE;

From this point on, all calls to print or write without a filehandle argument will result in output being directed to the selected filehandle. Any special variables related to output will also then apply to this new default. To change the default back to STDOUT, select it:
select STDOUT;

When you are finished using a filehandle, close it using close():
close(FILE);

Formats:
Perl has a fairly sophisticated mechanism for generating formatted output. This involves using pictorial representations of the output, called templates, and the function write.
Using a format consists of three operations:
1. Defining the format (template)
2. Loading data to be printed into the variable portions of the format
3. Invoking the format.
Format templates have the following general form:
format FORMATNAME =
fieldline
$value_one, $value_two, …

Everything between the “=” and the “.” is considered part of the format and everything (in the fieldlines) will be printed exactly as it appears (whitespace counts). Fieldlines permit variable interpolation via fieldholders:

Hi, my name is @<<<<<, and I’m @< years old. <-- Fieldline
$name, $age <-- Valueline
Fieldholders generally begin with a @ and consist of characters indicated alignment/type.
@<<< Four character, left-justified field
@>>> Four character, right-justified field
@||| Four character, centered field
@###.## Six character numeric field, with two decimal places
@* Multi-line field (on line by itself – for blocks of text)
^<<<< Five character, “filled” field (“chews up” associated variables)

The name of the format corresponds to the name of a filehandle. If write is invoked on a filehandle, then the corresponding format is used. Naturally then, if you’re printing to standard output, then your format name should be STDOUT. If you want to use a format with a name other than that of your desired filehandle, set the $~ variable to the format name.

There are special formats which are printed at the top of the page. If the active format name is FNAME, then the “top” format name is FNAME_TOP. The special variable $% keeps a count of how many times the “top” format has been called and can be used to number pages.

Manipulating files & directories:
The action of opening a file for writing creates it. Perl also provides functions to
manipulate files without having to ask the operating system to do it.
unlink(filename)

Delete an existing file. Unlink can take a list of files, or wildcard as an argument as well: unlink(<*.bak>)
rename(oldname, newname)

This function renames a file. It is possible to move files into other directories by specifying a path as part of the new name. Directories also have some special function associated with them
mkdir(dirname, mode)

Create a new directory. The “mode” specifies the permissions (set this to 0777 to be safe).
rmdir(dirname)

Removes (empty) directories
chdir(dirname)

Change current working directory to dirname, File and directory attributes can be modified as well:
chmod(permission, list of files)

Change the permissions of files or directories:
666 = read and write
444 = read only
777 = read, write, and executable
utime(atime, mtime, list of files)
Modify timestamps on files or directories. “atime” is the time of the most recent access, and “mtime” is the time the file/directory was last modified.

Friday 27 June 2014

GRUB Troubleshooting – 5

GRUB Troubleshooting – 5

--> How do I change a forgotten root password?
We can change root password from either single user mode or rescue mode. The method for booting into single user mode depends on your bootloader:
GRUB – No password protection
Booting into single user mode using GRUB is accomplished by editing the kernel line of the boot configuration. This assumes that either the GRUB boot menu is not password protected or that you have access to the password if it is.
When the system boots up, you will see the GRUB countdown, which is set to 5 seconds by default . Press “Esc” to intercept this countdown and go enter a GRUB menu. Then follow these steps:
Press ‘e’ to start editing.
Scroll down to the “kernel…” line. This line tells GRUB which kernel to boot.
Press ‘e’ again to edit this line.
Move to the end of the line. Add the number “1″ to the end.
Once you have finished that change, press Enter to accept the edit.
Press ‘b’ to boot using that kernel and boot into runlevel 1 (single user mode).
Change the root password when the “#” prompt appears by using the “passwd” command.
Note: The switch to runlevel 1 is not persistent. At next boot, the system will start in default runlevel as specified in the /etc/inittab file.
GRUB – Password protection
If the GRUB boot menu is password protected and you do not have access to the password, you will need to use a rescue disk to boot the system.
Follow the instructions given by the rescue disk boot process:
Boot the system from boot disc 1. Once the system has successfully booted from the ISO image and the Red Hat Enterprise Linux boot screen appears, type “linux rescue” without the quotes at the boot prompt and press the enter key.
[F1-Main] [F2-Options] [F3-General] [F4-Kernel] [F5-Rescue]
boot: linux rescue
When prompted for language and keyboard, provide the pertinent information for the system. When prompted to enable the network devices on the system, select “No”.
Select “Continue” when prompted to allow the rescue environment to mount the Red Hat Enterprise Linux installation under the /mnt/sysimage directory.
Run the command “chroot /mnt/sysimage” to change root to your system image.
Use the command “passwd” to change the root password of the system.
--> How do I reinstall a corrupted boot partition in Red Hat Enterprise Linux?
In a system where the “/boot” partition is a separate partition, when /boot is corrupted or be formatted mistakenly, you can not boot the system but do not want to reinstall the whole system.
Reinstall /boot partition manually with the following steps:
1. Boot the system into rescue mode:
Insert the Red Hat Enterprise Linux CD #1 and boot your system. At boot prompt, type “linux rescue”. This will start the rescue mode program.
You will be prompted for your keyboard and language requirements. Enter these values as you would during the installation of Red Hat Enterprise Linux.
Next, a screen will appear telling you that the program will now attempt to find a Red Hat Enterprise Linux installation to rescue. Select “Continue” on this screen.
At the “sh-3.1″ prompt, chroot to /mnt/sysimage:
# chroot /mnt/sysimage
2. Make sure the boot partition is labeled as described in /etc/fstab. (Assuming the boot partition is /dev/sda1):
# e2label /dev/sda1 /boot
3. Make sure the boot partition is mounted:
# mount /dev/sda1 /boot
4. Mount the CD to install the following rpms:
# mkdir /mnt/iso
# mount -o loop,ro /dev/hdc /mnt/iso
# cd /mnt/iso/Server
# rpm -Uvh –replacefiles –replacepkgs grub-0.97-13.i386.rpm
# rpm -Uvh –replacefiles –replacepkgs redhat-logos-4.9.16-1.noarch.rpm
# rpm -ivh –replacefiles –replacepkgs kernel-2.6.18-8.el5.i686.rpm
5. Install the GRUB:
# grub-install /dev/sda
6. If /boot/grub/grub.conf is lost, you need to create it manually. The following is a sample of grub.conf, please make sure the the file “vmlinuz-2.6.18-8.el5″ and “initrd-2.6.18-8.el5.img” exist under the directory of /boot (which should be installed after step 4).
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux (2.6.18-8.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/
initrd /initrd-2.6.18-8.el5.img
7. Make a soft link to grub.conf:
# cd /boot/grub
# ln -s grub.conf menu.lst
Then you can reboot your system.
--> How to disable hyperthreading if GRUB is the boot loader?
During the boot sequence you can add an option to the kernel line.
In the GRUB menu, select the kernel to boot into.
Type ‘e’ to modify the kernel arguments before booting.
Add a space then type ‘noht’ at the end of the line.
Hit return to boot with this options.
Type ‘b’ to boot to this kernel.
Permanently
Edit the /etc/grub.conf file.
Find the kernel line that you want to modify.
Add noht to the kernel line. For example:
title Red Hat Enterprise Linux Server (2.6.18-8.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-8.el5 ro root=/dev/vg0/lv0 noht
initrd /initrd-2.6.18-8.el5.img
--> How do I turn SELinux off during GRUB booting?


During the boot sequence you can add an option to the kernel line.
In the GRUB menu, select the kernel to boot into.
Type ‘e’ to modify the kernel arguments before booting.
Add a space then type ‘noht’ at the end of the line.
Hit return to boot with this options.
Type ‘b’ to boot to this kernel.
Permanently
Edit the /etc/grub.conf file.
Find the kernel line that you want to modify.
Add noht to the kernel line. For example:
title Red Hat Enterprise Linux Server (2.6.18-8.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-8.el5 ro root=/dev/vg0/lv0 rhgb quiet selinux=0
initrd /initrd-2.6.18-8.el5.img
--> How to display the booting log on the display always?
If the kernel entry has “rhgb” and “quiet” at the end of the line, you wont see the boot log. To enable boot log, just modify the entries as below
Before:
title Red Hat Enterprise Linux AS (2.6.9-89.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-89.ELsmp ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-89.ELsmp.img
After:
title Red Hat Enterprise Linux AS (2.6.9-89.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-89.ELsmp ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.9-89.ELsmp.img