Wednesday, June 24, 2009

How to convert mbox to maildir for a single domain on a cpanel server?

Suppose we are performing the conversion for the user@domainname.com user.

Take the backup of “/home/username/mail/domain.com/user/” before doing this.

Run this command as the user of the mailboxes.
================================================
/usr/local/cpanel/3rdparty/mb2md/mb2md -s /home/username/mail/domain.com/user/inbox -d /home/username/mail/domain.com/user/
================================================

Source Mbox is /home/username/mail/domain.com/user/inbox

The main Maildir directory will be created if it does not exist. It has the following subdirectories:

/home/username/mail/domain.com/user/tmp/
/home/username/mail/domain.com/user/new/
/home/username/mail/domain.com/user/cur/




Usage:

mb2md -h
mb2md -m [-d destdir]
mb2md -s sourcedir [-R|-f somefolder] [-d destdir] [-r strip_extension]

For further details please view the following link.
http://www.akadia.com/services/converting_mbox_mdir.html

Useful Exim Commands.

1. How to remove How to remove all mails from exim queue?
==================
rm -rf /var/spool/exim/input/*

2. Deleting Frozen Mails:
==================
To remove all frozen mails from the exim queue, use the following command -
exiqgrep -zi -o 86400 | xargs exim -Mrm
exim -bpr | grep frozen | awk {'print $3'} | xargs exim -Mrm
exiqgrep -z -i | xargs exim -Mrm
exiqgrep frozen | awk '{print $3}' | xargs exim -Mrm

3. If you want to only delete frozen messages older than a day:
=============================================
exiqgrep -zi -o 86400 | xargs exim -Mrm
where you can change 86400 depending on the time frame you want to keep.( 1 day = 86400 seconds. ).

4. To forcefully deliver mails in queue, use the following exim command:
=====================================================
exim -bpru |awk '{print $3}' | xargs -n 1 -P 40 exim -v -M

To flush the mail queue:
======================
exim -qff
/usr/sbin/exim -qff

To clear spam mails from Exim Queue:
==============================
grep -R -l [SPAM] /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

To clear frozen mails from Exim Queue.
==============================

grep -R -l '*** Frozen' /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm


To clear mails from Exim Queue for which recipient cannot not be verified.
=====================================================================
grep -R -l 'The recipient cannot be verified' /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

To find exim queue details. It will show ( Count Volume Oldest Newest Domain ) details.
=====================================================================

exim -bp |exiqsumm


How to remove root mails from exim queue ?
==================================

When mail queue is high due to root mails, and you only need to remove the root mails and not any other valid mails.

exim -bp |grep ""|awk '{print $3}'|xargs exim -Mrm

Replace "HOSTNAME" with server hostname


How to remove nobody mails from exim queue ?
==================================
When you need to clear nobody mails, you can use the following command.

exiqgrep -i -f nobody@HOSTNAME | xargs exim -Mrm (Use -f to search the queue for messages from a specific sender)
exiqgrep -i -r nobody@HOSTNAME | xargs exim -Mrm (Use -r to search the queue for messages for a specific recipient/domain)

Replace "HOSTNAME" with server hostname

Run a pretend SMTP transaction from the command line, as if it were coming from the given IP address. This will display Exim's checks, ACLs, and filters as they are applied. The message will NOT actually be delivered.
===========================

# exim -bh

For details please view the following link.
===========================
http://bradthemad.org/tech/notes/exim_cheatsheet.php
===========================

How to read exim main log?

Suppose here are two sample mail server logs.

**************************************************************
1995-10-31 08:59:13 0tACW1-0005MB-00 => marv
D=localuser T=local_delivery
1995-10-31 09:00:10 0tACW1-0005MB-00 => monk@holistic.fict.book
R=lookuphost T=smtp H=holistic.fict.book [234.234.234.234]
**************************************************************


Here I am giving the view how to read the different fields.

1) The H and U fields identify the remote host and record the RFC 1413 identity of the user that sent the message, if one was received.
2) The number given in square brackets is the IP address of the sending host.
3) Misconfigured hosts (and mail forgers) sometimes put an IP address. Only the final address in square brackets can be relied on. U field contains the login name of the caller of Exim.
***************************
H=(10.21.32.43) [123.99.8.34]
H=([10.21.32.43]) [123.99.8.34]
***************************
4) P field specifies the protocol used to receive the message. This is set to `asmtp' for messages received from hosts which have authenticated themselves using the SMTP AUTH command.

5) A= followed by the name of the authenticator that was used. If an authenticated identification was set up by the authenticator's server_set_id option, this is logged too, separated by a colon from the authenticator name.

6) The size of the received message is given by the S field.When the message is delivered, headers may get removed or added, so that the size of delivered copies of the message may not correspond with this value (and indeed may be different to each other).

7) If the log_subject option is on, the subject of the message is added to the log line, preceded by `T=' (T for `topic', since S is already used for `size').

8) A delivery error message is shown with the sender address `<>', and if it is a locally-generated error message, this is normally followed by an item of the form
R=
which is a reference to the local identification of the message that caused the error message to be sent.



9) If a shadow transport was run after a successful local delivery, the log line for the successful delivery has an item added on the end, of the form

ST=

10) '>' FIELD: The generation of a reply message by a filter file gets logged as a `delivery' to the addressee, preceded by `>'. The D and T items record the director and transport. For remote deliveries, the router, transport, and host are recorded.

11) CC FIELD: When more than one address is included in a single delivery (for example, two SMTP RCPT commands in one transaction) then the second and subsequent addresses are flagged with `->' instead of `=>'. When two or more messages are delivered down a single SMTP connection, an asterisk follows the IP address in the log lines for the second and subsequent messages.

12) '*>' FIELD: When the -N debugging option is used to prevent delivery from actually occurring, log entries are flagged with `*>' instead of `=>'.

13) '**' FIELD: If a delivery fails, a line of the following form is logged:
-----------------------------------------------------------------------------------
1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.film
: unknown mail domain
-----------------------------------------------------------------------------------
This is followed (eventually) by a line giving the address to which the delivery error has been sent.

14) -N FIELD: -N options has been used to suppress the delivery faliure report.

14) `*>' FIELD: If a delivery does not actually take place because the -N options has been used to suppress it, an apparently normal delivery line is written to the log, except that `=>' is replaced by `*>'.

15) Completed FIELD:

A line of the form
-------------------------------------------------------------------------
1995-10-31 09:00:11 0tACW1-0005MB-00 Completed
--------------------------------------------------------------------------
is written to the main log when a message is about to be removed from the spool at the end of its processing.


That's all.

For further details please view the following link.
http://www.exim.org/exim-html-3.20/doc/html/spec_51.html

Tuesday, June 23, 2009

How to Upgrade Wordpress Manually?



There are two different procedure to Upgrade Wordpress. One is manually and the other is automatically. To upgrade Wordpress automatically, just download wpau plugin, upload and activate the plugin.

Here are the steps to Upgrade it manually.

Step A

1. Download to your hard drive the latest Wordpress http://wordpress.org/latest.zip
2. Now create an test directory and extract the zip file in that folder.
3. There are three folder such as: wp-admin, wp-content and wp-includes


Step B

1. Backup your website’s data or folder such as wp-admin, wp-content and wp-includes, you can use Wordpress database backup plugin.
2. Create a backup of wordpress database using the following commands.


You can use Cpanel to take this backup. Here is the video tutorial to do it.
==================================================================================
http://www.gotmyidea.com/70116-cpanel-tutorial-taking-site-or-database-backup.php
http://matthewhelmke.net/2008/01/30/making-automatic-backups-for-your-website/
http://matthewhelmke.net/2008/02/01/automatic-mysql-backups-using-php/
==================================================================================


Step C

1. Now just copy the following files from your old wordpress folder to new test directory.
===================================================================
* wp-content (Here is an sample location of thet file: /home/username/public_html/wordpress/wp-content )
** wp-config.php (Here is an sample location of thet file: /home/username/public_html/wordpress/wp-config.php )
***/home/username/public_html/wordpress/wp-includes/languages ( If you are using a custom language file.
===================================================================
2. Now move the /test/wordpress directory to your original wordpress directory i.e /home/username/public_html/
3. Access the following link from browser.
http://www.yoursite.com/wp-admin/upgrade.php


Here is the detailed exact syntactical description of the total procedure.
======================================================================

*Take the database backup using the following command.

# mysqldump databasename > databasename.sql

**Suppose your wordpress directory location is /home/username/public_html/wordpress.
Take a backup of your wordpress directory using the following command.
.
#cp -rp /home/username/public_html/wordpress /home/username/public_html/wordpress.bak

***Suppose you are using the following test directory to download the new WordPress.
/home/username/public_html/test

#cd /home/username/public_html/test
#wget http://wordpress.org/latest.tar.gz
#tar -xvzf latest.tar.gz
#cd wordpress
#rm -rf wp-content wp-config.php
#cp -rp /home/username/public_html/wordpress/wp-content wp-content
#cp -rp /home/username/public_html/wordpress/wp-config.php wp-config.php
#cp -rp /home/username/public_html/wordpress/wp-includes/languages /wp-includes/languages (if you are using a custom language file.)

****Now remove the directory /home/username/public_html/wordpress/ completely.

#rm -rf /home/username/public_html/wordpress/
move the /home/username/public_html/test/wordpress directory to /home/username/public_html/wordpress using the following command.
#mv /home/username/public_html/test/wordpress /home/username/public_html

*****Now access the following link from browser.

http://www.yoursite.com/wp-admin/upgrade.php

Wait for 40sec. You have finished the upgrade process.





For further details please view the following links.

http://kipram.com/how-to-upgrade-wordpress-manually/
http://www.kimwoodbridge.com/upgrading-wordpress-manually/

Tuesday, June 16, 2009

How to configure services to run at different runlevels?

Once the kernel has been loaded and has started to run, it calls the /sbin/init program. This program runs as root and sets the "run level" to that requested at initial boot time.

Now what is run level?

A run level is simply a number that Linux uses to distinguish different types of high-level configurations that the machine should be booted into.

For Red Hat Linux system here are the different run levels described below.

Typical Linux run levels:
===========================================================================
ID Name Description

0 Halt the system

1 Single-User Mode Does not: configure network interfaces, start
daemons, or allow non-root logins.(generally
only used for administration purposes)

2 Multi-user mode with networking disabled Does not: configure network interfaces or start
daemons.

3 Multi-User Mode with Networking Starts the system normally.

4 Unused run level

5 Multi-user mode with networking Enabled Multi-User mode with network and
running the X Window System, and/or to start X

6 Reboot

===========================================================================

How init initializes the system?

INIT uses an ASCII configuration file (/etc/inittab) to tell it how to change the runlevel. Usually, this configuration file instructs init to run the script /etc/rc.d/rcRunLevelNumber.d, thus passing it to the runlevel number.


Suppose you have to configure your newly installed service to run it at RunLevel-5. Here is the procedure how to access it.


Primarily all your service starter demon resides into the following path.
----------------
/etc/rc.d/init.d/servicename
----------------

But when Linux startup on a specific run level suppose (n) it will find the find the service starter script at the following location.

------------
/etc/rc.d/rcRunLevelNumber/servicename
------------

So you have to create a soft link with /etc/rc.d/rcRunLevelNumber.d/servicename to /etc/rc.d/init.d/servicename



But how the system will know if the process will start or stop at the booting time. Also how to decide the sequence of starting the process.

Here is the description how it solves the problem.

The link described above is suffixed with the name of the service it is linked to.
The prefix is made up of two parts: a single uppercase character followed by a two-digit decimal number. The single uppercase character is either a "S" (meaning "start") or a "K" (meaning "kill," or stop). The two-digit number can range from 00 to 99. This number signifies the priority of process started in order. Lesser in value denotes higher priority.

Here is an example of the structure.

==========================
lrwxrwxrwx 1 root root 16 Jun 29 2008 K03smartd -> ../init.d/smartd
lrwxrwxrwx 1 root root 21 Jun 29 2008 S01tog-pegasus -> ../init.d/tog-pegasus
lrwxrwxrwx 1 root root 22 Jun 29 2008 K02avahi-daemon -> ../init.d/avahi-daemon
lrwxrwxrwx 1 root root 24 Jun 29 2008 K02avahi-dnsconfd -> ../init.d/avahi-dnsconfd
lrwxrwxrwx 1 root root 16 Jun 29 2008 K02dhcdbd -> ../init.d/dhcdbd
==========================

This command will help you a lot to solve this problem. Through the command you can add or delete any service from the startup links.
---------------------------
/sbin/chkconfig (For details man chkconfig)
---------------------------



After running the service if you want to check the service is running or not, this command below will help you a lot to understand.


================
/sbin/chkconfig --list

===============


For details please view the following links.

http://www.ibm.com/developerworks/linux/library/l-boot.html
http://en.wikipedia.org/wiki/Runlevel

That's all.

 Linux Interview  Linux booting process EXT4 XFS file system runlevel scan disk hba driver systool -c fc_host lspci -nn | grep -i hba single...