Wednesday, June 29, 2011

How to setup Boot Password (Grub)

Even before the operating system is booted, GRUB enables access to file systems. Users without root permissions can access files in your Linux system to which they have no access once the system is booted. To block this kind of access or prevent users from booting certain operating systems, set a boot password.
As the user root, proceed as follows to set a boot password:

At the root prompt, encrypt the password using grub-md5-crypt:

# grub-md5-crypt
Password: ****
Retype password: ****
Encrypted: $1$lS2dv/$JOcHkLosIn7CJk9xShzzJVw/

Paste the encrypted string into the global section of the file menu.lst:

gfxmenu (hd0,4)/message
color white/blue black/light-gray
default 0
timeout 8
password --md5 $1$lS2dv/$JOcHkLosIn7CJk9xShzzJVw/

Now GRUB commands can only be executed at the boot prompt after pressing P and entering the password. However, users can still boot all operating systems from the boot menu.

Thursday, June 23, 2011

Convert RHEL to CentOS

Hi

        Recently i was installed in my desktop RHEL 5 and I was tried to upgrade. On the time it asked Searial Key.  I was tried what the key mentiond in the DVD, but it has not taken. So i decided to convert RHEL to Centos. I Done Using following Steps.

Remove the redhat-release and yum-rhn-plugin repo

rpm -e --nodeps redhat-release
rpm -e --nodeps yum-rhn-plugin

Download the key from

http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

Install the RPM-GPG-KEY-CentOS-5

rpm --import RPM-GPG-KEY-CentOS-5
 
Download and Install the following rpms in this site  
http://mirror.centos.org/centos/5.6/os/i386/CentOS/
centos-release-5-6.el5.centos.1.i386.rpm 
centos-release-notes-5.6-0.i386.rpm   
yum-3.2.22-20.el5.centos.noarch.rpm
yum-updatesd-0.9-2.el5.noarch.rpm  

Then

Yum clean all

Yum upgrade


Your Centos will upgrade

Have the Centos update with help of Redhat Package

Wednesday, June 22, 2011

The trick to recover the lost RHEL installation number

This trick MAY or may NOT work. Since this DELL server is known to have preinstalled RHEL 5.5 with a valid subscription number, the chance to recover RHEL installation number is high:

1) Login to the system as root

2) Change directory to /etc/sysconfig/rhn and uses cat command to display the install-num file. Alternatively, you can just cat the file as this:


cat /etc/sysconfig/rhn/install-num

According to RHEL 5 Release Notes, the installation number is saved in /etc/sysconfig/rhn/install-num, if entered during RHEL installation. This install-num file is referred by rhn_register when registering with Red Hat Network.

Thursday, June 16, 2011

Change Login Screen Image on Fedora 14

       I checked the “/usr/share/backgrounds/” directory and found a “laughlin” folder. Inside it is a folder named “default” that contains three other folders named normalishstandard, and wide and a laughlin.xml file. The three folders contained the default login screen image. If you open the xml file with a text editor, you’ll notice that a part of it specifies the path of the Laughlin wallpaper. Wide, Normalish, and Standard specifies the image dimensions. And using this xml file, we can change the login screen image.


     

          Here’s what I did. First, I edited my image three times using the specified dimensions (this is optional) and saved them as PNG files. I then copied them to the three folders with respect to their dimensions.
[root@machine username]# cp /current/file/location/filename1.png /usr/share/backgrounds/laughlin/default/wide/
[root@machine username]# cp /current/file/location/filename2.png /usr/share/backgrounds/laughlin/default/standard/
[root@machine username]# cp /current/file/location/filename3.png /usr/share/backgrounds/laughlin/default/normalish/
Using vi, edit laughlin.xml and replace the filenames and save the file. See image below.

I logged off and there was my new login screen. I used a random Fedora wallpaper I got from the web. 

Monday, June 6, 2011

How To Install Or Upgrade LAMP: Linux, Apache, MySQL and PHP Stack Using Yum

Installing LAMP stack using yum 

        is very easy and takes only minutes. This is a good option for beginners who don’t feel comfortable installing from source. Also, Installing LAMP stack using yum is a good choice, if you want to keep things simple and just use the default configuration.

1. Install Apache using Yum

Apache
# rpm -qa | grep httpd

[Note: If the above command did not return anything,
          install apache as shown below]

# yum install httpd
 
Verify that Apache got installed successfully

# rpm -qa | grep -i http

httpd-tools-2.2.9-1.fc9.i386
httpd-2.2.9-1.fc9.i386
 
Start the Apache as shown below.

# service httpd start 

Starting httpd: [ OK ]

2. Upgrade Apache using Yum

If you’ve selected web server package during Linux installation, Apache is already installed on your Linux. In which case, you can upgrade Apache to the latest version as shown below.
Check whether Apache is already installed.

# rpm -qa | grep -i http 

httpd-tools-2.2.8-3.i386 httpd-2.2.8-3.i386




Check whether latest version of Apache is available for installation using yum. 

yum check-update httpd
Loaded plugins: refresh-packagekit
 
httpd.i386      2.2.9-1.fc9       updates
 
[Note: This indicates that the latest Apache version 2.2.9
       is available for upgrade]

Upgrade Apache to latest version using yum.
 
# yum update httpd


Verify whether the Apache got upgraded successfully.
 
# rpm -qa | grep -i http

httpd-tools-2.2.9-1.fc9.i386
httpd-2.2.9-1.fc9.i386
[Note: This indicates that Apache was upgraded to 2.2.9 successfully]

3. Install MySQL using Yum

MySQL Logo
  Yum is very smart to identify all the dependencies and install those automatically. For example, while installing mysql-server using yum, it also automatically installs the depended mysql-libs, perl-DBI, mysql, perl-DBD-MySQL packages as shown below.
 
# yum install mysql-server


Verify whether MySQL got installed properly.

# rpm -qa | grep -i mysql

php-mysql-5.2.6-2.fc9.i386
mysql-libs-5.0.51a-1.fc9.i386
mysql-server-5.0.51a-1.fc9.i386
perl-DBD-MySQL-4.005-8.fc9.i386
mysql-5.0.51a-1.fc9.i386

# mysql -V

mysql  Ver 14.12 Distrib 5.0.51a, for redhat-linux-gnu (i386) using readline 5.0

Configure MySQL to start automatically during system startup.
 
# chkconfig mysqld on

Start MySQL service.
 
# service mysqld start

     The first time when you start mysqld, it will give additional information message indicating to perform post-install configuration as shown below.
 
Initializing MySQL database:
Installing MySQL system tables... OK
Filling help tables... OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
 
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h dev-db password 'new-password'

Alternatively you can run: /usr/bin/mysql_secure_installation 
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
highly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

Starting MySQL:                                            [  OK  ]

4. Perform MySQL post-installation activities

After the mysql installation, you can login to mysql root account without providing any password as shown below.
 
# mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.51a Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

     To fix this problem, you need to assign a password to mysql root account as shown below. Execute mysql_secure_installation script, which performs the following activities:
  • Assign the root password
  • Remove the anonymous user
  • Disallow root login from remote machines
  • Remove the default sample test database
 
# /usr/bin/mysql_secure_installation

Output of mysql_secure_installation script:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: [Note: Enter the mysql root password here]
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
... Success!

Cleaning up...
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!

Verify the MySQL post-install activities:
 
# mysql -u root

ERROR 1045 (28000):Access denied for user 'root'@'localhost'(using password:NO)
[Note: root access without password is denied]

# mysql -u root -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.0.51a Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)
[Note: test database is removed]

5. Upgrade MySQL using Yum

Check whether MySQL is already installed.

# rpm -qa | grep -i mysql

Check whether a latest version of MySQL is available for installation using yum.

# yum check-update mysql-server

Upgrade MySQL to latest version using yum.

# yum update mysql-server

6. Install PHP using Yum

PHP Logo
# yum install php

Install MySQL module for PHP.

 
# yum search php-mysql

# yum install php-mysql

If you need additional PHP modules, install them using yum as shown below.
 
# yum install php-common php-mbstring php-mcrypt php-devel php-xml php-gd

7. Upgrade PHP using Yum

Check whether PHP is installed.

# rpm -qa | grep -i php

Check whether a latest version of PHP is available for installation using yum.
 
# yum check-update php

Upgrade PHP to the latest version using yum.
 
# yum update php

Upgrade any additional PHP modules that you’ve installed using yum.
 
# yum check-update php-common php-mbstring php-mcrypt php-devel php-xml php-gd

# yum update php-common php-mbstring php-mcrypt php-devel php-xml php-gd

Verify the PHP installation by creating a test.php file as shown below.
 
# cat /var/www/html/test.php

<? phpinfo(); ?>
Invoke the test.php from the browser http://{lamp-server-ip}/test.php , which will display all PHP configuration information and the installed modules.