Archive for the ‘Redhat’ Category

How to use RSYNC

Posted: May 26, 2011 in Linux-Scripts, Redhat

How do I use rsync command?

if you would like to sync’d between www1 and www2(master) servers, type the following command on www1 server:rsync -avrR --links --rsh=/usr/bin/ssh WWW2:/var/html/ /var/htmlWhere,

  • -avrR : archive mode (a), verbose (v), recurse into directories (r), use relative path names (R) [ I did not use R in my scripts for simplicity ]
  • –links : copy symlinks as symlinks
  • –delete                delete files that dont exist on master
    –rsh=/usr/bin/ssh : Use to specify the remote shell ssh to use (secure copy).
  • WWW2:/var/html/ : WWW2 server IP address and path to synchronize to www1 server
  • /var/html : WWW1 server path

A sample shell script for same job


rsync -avr --links --delete --rsh=$SSH $MASTER:$DIR $LDIR


SSH is strongly recommended but just in case if you need Telnet server…

In order to turn Telnet on make sure that you have install the telnet-server and telnet RPMs:

yum install telnet-server telnet


you can mount the RHEL DVD and copy Telnet RPM and run the following. ( /mnt/Server/telnet-server-0.17-39.el5.i386.rpm )
rpm - Uvh telnet-server-0.17-39.el5.i386.rpm

Open /etc/xinetd.d/telnet

vi /etc/xinetd.d/telnet

Make sure that disable = yes is changed to read disable = no.

disable = no

Type following to enable and start service on port 23:

chkconfig telnet on
chkconfig xinetd on
service xinetd restart



Again, I recommend that you use SSH to connect to a system instead of Telnet for security purposes.

Ref :

To Shutdown Oracle :

1. Log in to Oracle Server as user oracle . You can log in as root and then su to oracle as well.

[root@hkrhel33 ~]# su –
[root@hkrhel33 ~]# su oracle
[oracle@hkrhel33 root]$ ps -ef | grep pmon

root     25524 25413  0 15:14 pts/7    00:00:00 grep pmon
oracle   27243     1  0 May16 ?        00:00:06 ora_pmon_WMS852 <— This is DB name

[oracle@hkrhel33 root]$ . oraenv

ORACLE_SID = [ora_pmon_WMS852] ? WMS852
The Oracle base has been set to /u01/app/oracle
[oracle@hkrhel33 root]$ sqlplus ‘/as sysdba’

SQL*Plus: Release Production on Thu May 19 15:22:53 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Release – 64bit Production

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit

To Start up Oracle :

[oracle@hkrhel33 root]$ ps -ef | grep pmon
oracle    4720  4516  0 15:42 pts/2    00:00:00 grep pmon
[oracle@hkrhel33 root]$ . oraenv
ORACLE_SID = [oracle] ? WMS852
The Oracle base has been set to /u01/app/oracle
[oracle@hkrhel33 root]$ sqlplus ‘/as sysdba’

SQL*Plus: Release Production on Thu May 19 15:43:07 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Release – 64bit Production

SQL> startup

How to create SOSREPORT

Posted: May 4, 2011 in Redhat

What is an “sosreport” and how do I create it in Red Hat Enterprise Linux 4.6 and later?


The “sosreport” command is a tool that collects information about a Red Hat Enterprise Linux system, such as what kernel is running, what drivers are loaded, and various configuration files for common services. It also does some simple diagnostics against known problematic patterns.


  • Red Hat Enterprise Linux 4.6 and later


To run  “sosreport”, the “sos” package must be installed. The package should be installed by default, but if the package is not installed, follow the steps below:

Red Hat Enterprise Linux 4.6 and later

If the system is registered with Red Hat Network (RHN), “sos” can be installed using the up2date command:

# up2date sos

Red Hat Enterprise Linux 5 and later

If the system is registered with RHN, use the yum command:

# yum install sos

If the system is not registered with RHN, the “sos” package can be downloaded from the RHN website or found on the installation CDs. The RPM command can be used to install the package on any version of Red Hat Enterprise Linux:

# rpm -Uvh sos-<version>.<arch>.rpm 

Once the package has been installed, issue the following command:

Note: sosreport requires root permissions to run.

# sosreport

The sosreport will run for several minutes, according to different system, the running time maybe more longer.

Once completed, “sosreport” will generate a compressed a bz2 file under /tmp. Provide this file to the support representative.

Normally, the size of the bz2 file will be about 3MB, but if your system has a large amount of log files, it maybe very big.

The sosreport has some plugins which can be turn on/off, the following command lists the plugins:

# sosreport -l 

For example, turning off the rpmva plugin will save time running sosreport.

# sosreport -k rpm.rpmva=off 


1. Before Red Hat Enterprise Linux 4.5, please use “sysreport” instead: What is a sysreport and how do I run it ?

2. In the sos package, there is also a command called “sysreport”, but it is just a soft link to the sosreport command:

# ls -l /usr/sbin/sysreport lrwxrwxrwx 1 root root 19 Nov  3  2008 /usr/sbin/sysreport -> /usr/sbin/sosreport 

If you do want to use the legacy version of sysreport, please use the sysreport.legacy command in sos package.

Ref :

Adding Swap File in Linux

Posted: April 19, 2011 in Redhat

Procedure to add a swap file

You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.

a) Login as the root user

b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

c) Set up a Linux swap area:
# mkswap /swapfile1

d) Activate /swapfile1 swap space immediately:
# swapon /swapfile1

e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
# vi /etc/fstab

Append following line:
/swapfile1 swap swap defaults 0 0

So next time Linux comes up after reboot, it enables the new swap file for you automatically.

g) How do I verify swap is activated or not?
Simply use free command:
$ free -m

Ref :

Installing MediaTomb uPnP Server

Posted: October 24, 2010 in Personal, Redhat

Installing latest MediaTomb on CentOS 5.x 32-bit

If I ever have to do it again.. since it turned out to be extremely easy (if you look a little longer and resists compiling it from source), here is how to install MediaTomb on CentOS (or in my case ”Installing MediaTomb on CentOS 5.4″);

“[MediaTomb is] an open source (GPL) UPnP MediaServer with a web user interface and AV transcoding support” (Wikipedia)

MediaTomb can be read about and downloaded (in source form) from

1. download MediaTomb RPM.

[root@mediatomb ~]# wget

2. download Required lib;

[root@mediatomb ~]# wget

3. Install the Library

[root@mediatomb ~]# rpm -ivh taglib-1.5-1.el5.kb.i386.rpm

[root@mediatomb ~]# rpm -ivh mediatomb-0.11.0-1.el5.kb.i386.rpm

4. Find out which netword card to use (most likely its ‘eth0′)

[root@mediatomb ~]# ifconfig -a|egrep "inet addr|eth|wlan"
eth0 Link encap:Ethernet  HWaddr 00:0F:EA:8A:F7:76
inet addr: Bcast:  Mask:
inet addr:  Mask:
wlan0     Link encap:Ethernet  HWaddr 00:0F:B5:4F:79:71
In my case you see the only card with an IP address is ‘eth0′

5. Change the config and select your network card;

[root@mediatomb ~]# vi /etc/mediatomb.conf
In my case, change FROM;

6. See which port it runs on;

[root@mediatomb ~]# grep MT_PORT /etc/mediatomb.conf

7. Start it;

[root@mediatomb ~]# /etc/init.d/mediatomb start

8. Make sure Mediatomb is up and running;

[root@mediatomb ~]# /etc/init.d/mediatomb status
[root@mediatomb ~]# cat /var/log/mediatomb
2010-02-23 22:15:55    INFO: MediaTomb configuration was created in: /etc/mediatomb/config.xml
2010-02-23 22:15:55    INFO: Loading configuration from: /etc/mediatomb/config.xml
2010-02-23 22:15:55    INFO: UUID generated: 384f1086-4063-4390-acdf-b79771c60b6d
2010-02-23 22:15:55    INFO: Checking configuration...
2010-02-23 22:15:55    INFO: Setting filesystem import charset to UTF-8
2010-02-23 22:15:55    INFO: Setting metadata import charset to UTF-8
2010-02-23 22:15:55    INFO: Setting playlist charset to UTF-8
2010-02-23 22:15:55    INFO: Configuration check succeeded.
2010-02-23 22:15:55 WARNING: Sqlite3 database seems to be corrupt or doesn't exist yet.
2010-02-23 22:15:55    INFO: no sqlite3 backup is available or backup is corrupt. automatically creating database...
2010-02-23 22:15:55    INFO: database created successfully.
2010-02-23 22:15:55    INFO: Initialized port: 50500
2010-02-23 22:15:55    INFO: Server bound to:
2010-02-23 22:15:56    INFO: MediaTomb Web UI can be reached by following this link:
2010-02-23 22:15:56    INFO:

9. You can see its available now on;

10. Go to that address above in a browser and have fun!

(remember if your firewall is enabled, you must open the port – do this in GNOME if you have the UI under “System” -> “Administration” -> “Security Level and Firewall”)

Just added a 1.5 TB HDD in one of my RHEL Server but fdisk -l does not show me the New HDD. Check below.

Here is the way to scan the scsi for the new HDD

Now I can see the 1.5 TB HDD . Click here for my post of how to format it and make partition.