Thursday, December 29, 2011

How to send mails using telnet

Advertisements

This post explains how to send mails to the users in the same system. From the user aswath to the user ajith. This is useful to troubleshoot mail server issues.

[root@localhost ~]# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 localhost.localhost.com ESMTP Sendmail 8.13.8/8.13.8; Fri, 30 Dec 2011 04:04:06 +0530
helo 127.0.0.1
250 localhost.localhost.com Hello localhost.localdomain [127.0.0.1], pleased to meet you
mail from:<aswath@localhost.localdomain>
250 2.1.0 <aswath@localhost.localdomain>... Sender ok
RCPT TO:<ajith@localhost.localdomain>
250 2.1.5 <ajith@localhost.localdomain>... Recipient ok
data
354 Enter mail, end with "." on a line by itself
subject:test1
hi test1
.
250 2.0.0 pBTMY6ln018613 Message accepted for delivery
quit
221 2.0.0 localhost.localhost.com closing connection
Connection closed by foreign host.
You have new mail in /var/spool/mail/root
[root@localhost ~]#

The mail log is as follows.

[root@localhost ~]# tail -f /var/log/maillog
Dec 30 04:05:02 localhost sendmail[18613]: pBTMY6ln018613: from=<aswath@localhost.localdomain>, size=23, class=0, nrcpts=1, msgid=<201112292234.pBTMY6ln018613@localhost.localhost.com>, proto=SMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Dec 30 04:05:02 localhost sendmail[18615]: pBTMY6ln018613: to=<ajith@localhost.localdomain>, ctladdr=<aswath@localhost.localdomain> (501/501), delay=00:00:38, xdelay=00:00:00, mailer=local, pri=30380, dsn=2.0.0, stat=Sent

Thursday, December 8, 2011

how to enable mod_speling on directadmin

Advertisements


mod_speling how to
Enabling mod_speling in directadmin

[root@www custombuild]# cd /usr/local/directadmin/custombuild
[root@www custombuild]# mkdir -p custom/ap2
[root@www custombuild]# cp -Rp configure/ap2/configure.apache custom/ap2/configure.apache
[root@www custombuild]# vi custom/ap2/configure.apache
add     "--enable-speling" \ after    "--enable-so" \
save the file
[root@www custombuild]# ./build apache

add the following lines to /etc/httpd/conf/httpd.conf
[root@www custombuild]#  vi /etc/httpd/conf/httpd.conf
CheckSpelling On
CheckCaseOnly On
then save the file

Restart httpd
[root@www custombuild]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: [Fri Dec 09 00:10:58 2011]
[root@www custombuild]#

Checking
[root@www custombuild]# httpd -l | grep spel
  mod_speling.c
[root@www custombuild]#

How to remove the spam mails from qmail queue

Advertisements


How to remove spam mails from qmail mail queue

This post helps you to remove spam mails containing a string (subject) or from a particular user from the qmail mail queue. You have to install a open source

software qmail-remove.

Go to the directory /usr/local/src
[root@host ~]# cd /usr/local/src

Download the qmail-remove package
[root@host ~]# wget http://www.linuxmagic.com/opensource/qmail/qmail-remove/qmail-remove-0.95.tar.gz

Untar the package
[root@host ~]# tar xvzf qmail-remove-0.95.tar.gz

cd to the untared directory
[root@host ~]# cd qmail-remove-0.95/

compile
[root@host ~]# make

Install
[root@host ~]# make install

You can check the options with -h option
[root@host ~]# qmail-remove -h

Now the package is installed but you have to create a yanked directory to store the mails you are removing. You have to create it in the qmail base

directory. In this case it is /var/qmail/queue/ yours may differ.
[root@host ~]# cd /var/qmail/queue/
[root@host ~]# mkdir yanked

And before running the commands using this package you must stop qmail
[root@host ~]# /etc/init.d/qmail stop

There is one helpful tool with you can count and list the spam mails. Install it. You can get the directions from here
http://www.atomicorp.com/wiki/index.php/Spam

You can use -s option to get the total no.of spam mails in queue
[root@host ~]# /usr/bin/qmhandle.pl -s
Total messages: 253998
Messages with local recipients: 17
Messages with remote recipients: 253965
Messages with bounces: 1
Messages in preprocess: 16
[root@host ~]# /usr/bin/qmhandle.pl -s
Total messages: 185000
Messages with local recipients: 17
Messages with remote recipients: 184962
Messages with bounces: 1
Messages in preprocess: 20
[root@host ~]#

You can use -l option to list the spam mails in queue
[root@host ~]# /usr/bin/qmhandle.pl -l

You can read a message using the option -m
[root@host ~]# /usr/bin/qmhandle.pl -m22616314
 --------------
MESSAGE NUMBER 22616314
 --------------
Received: (qmail 25932 invoked by uid 502); 7 Dec 2011 12:17:40 +1100
Date: 7 Dec 2011 12:17:40 +1100
Message-ID: <20111207011740.25927.qmail@host.xxxxxx.com>
To: lyttmab@ppppp.com
Subject: I WISH TO HAVE YOU AS A PERSONAL ASSISTANT.
From: Mr.Morgan Kent <mr.morgankent2@ppppp.com>
Reply-To: morgankent202@ppppp.com
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
morgankent2011@ppppp.com
mr.morgankent2011@ppppp.com
######OUTPUT TRUNCATED########

You can read the headers of the mails in the queue using the following command
[root@host ~]# /var/qmail/bin/qmail-qread
7 Dec 2011 14:22:43 GMT  #22708222  3232  <anonymous@host.xxxxxx.com>
        remote  crehkow@ppppp.com
7 Dec 2011 12:12:16 GMT  #22609322  3233  <anonymous@host.xxxxxx.com>
        remote  jbilodeau1@ppppp.com
7 Dec 2011 10:55:48 GMT  #14396666  3237  <anonymous@host.xxxxxx.com>
        remote  izzy46martinez@ppppp.com

For listing the mails in the mail queue with a particular content use the following command
[root@host ~]# qmail-remove -i -p "I WISH TO HAVE YOU AS A PERSONAL ASSISTANT"
It will list the mails with content I WISH TO HAVE YOU AS A PERSONAL ASSISTANT in it

The above command will only list the mails. for deleting them use option -r. Then all those mails will be moved to yanked directory.
[root@host ~]# qmail-remove -i -p "I WISH TO HAVE YOU AS A PERSONAL ASSISTANT"  -r
[root@host yanked]# pwd
/var/qmail/queue/yanked
[root@host yanked]# ls | wc -l
593379
[root@host yanked]#

Useful links
http://www.atomicorp.com/wiki/index.php/Spam
http://kb.parallels.com/en/1711
http://kb.parallels.com/en/766
http://www.linuxmagic.com/opensource/qmail/qmail-remove

NRPE: Command 'check_mem' not defined

Advertisements

This error is coming because the missing of check_mem command on the client machine

open the following file and add the command as follows

root@server1 [/opt/Nagios/Nagios_NRPE/nrpe-2.12]# vi /usr/local/nagios/etc/nrpe.cfg
command[check_mem]=/usr/local/nagios/libexec/check_mem 85 95
save the file. That it.

root@server1 [~]# /usr/local/nagios/libexec/check_mem 85 95
OK - Memory usage is 2.000%
root@server1 [~]#

NRPE: Command 'check_disk' not defined

Advertisements

This error is coming because the missing of check_disk command on the client machine
open the following file and add the check_disk command as follows

root@server1 [/opt/Nagios/Nagios_NRPE/nrpe-2.12]# vi /usr/local/nagios/etc/nrpe.cfg
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda
save the file. That it.

You can also test the command as below on the client server.
root@server1 [/opt/Nagios/Nagios_NRPE/nrpe-2.12]# /usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda
DISK OK - free space: / 863034 MB (99% inode=99%);| /=4696MB;731966;823462;0;914958

CHECK_NRPE: Error - Could not complete SSL handshake

Advertisements

You may get an error like this while configuring nrpe with nagios
root@server1 [/opt/Nagios/Nagios_NRPE/nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x
CHECK_NRPE: Error - Could not complete SSL handshake.
root@server1 [/opt/Nagios/Nagios_NRPE/nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H localhost
CHECK_NRPE: Error - Could not complete SSL handshake.
The problem is you didnt give the ip address in /etc/xinetd.d/nrpe

Saturday, December 3, 2011

Error occurred during initialization of VM on javac

Advertisements

root@server [~]# /etc/init.d/red5  restart
Shutting down red5:                                        [FAILED]
Starting red5:                                                   [  OK  ]

root@server [~]# javac
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

export _JAVA_OPTIONS="-Xms20m -Xmx64m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:NewSize=10m -XX:MaxNewSize=10m -XX:SurvivorRatio=6 -XX:TargetSurvivorRatio=80 -XX:+CMSClassUnloadingEnabled -XX:+CMSClassUnloadingEnabled"

Thursday, December 1, 2011

Checking the php script sending the spam mails

Advertisements

This post explains how to check the php script sending the spam mails in exim.

Go to the mail sending directory of exim

root@server1 [~]# cd /var/spool/exim/input

Search for php scripts sent the spam mails
root@server1 [/var/spool/exim/input]#  egrep "X-PHP-Script" * -R

how to use a file as a hard disk partition.

Advertisements


This explains how to use a file as a hard disk partition. 

First we have to create a file(var.dsk) of  big size according to our need. Here we use dd command for this. A 1gb size file.
root@cpaneltest [~]# dd if=/dev/zero of=var.dsk bs=1024 count=1000000

Now you have to attach that file to a loop device. Using the command losetup.
root@cpaneltest [~]# losetup /dev/loop7 var.dsk

Now format the file with any filesystem. Here we use ext3.
root@cpaneltest [~]# mkfs.ext3 /dev/loop7

Now create a mount point.
root@cpaneltest [~]# mkdir /var_test

Mounting the attached loop device to the mount point
root@cpaneltest [~]# mount -t ext3 /dev/loop7 /var_test

Checking mount. See the last line.
root@cpaneltest [~]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw,usrquota,acl)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/usr/tmpDSK on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0)
/tmp on /tmp type none (rw,noexec,nosuid,bind)
/dev/sdb1 on /root/dev_test type ext3 (rw)
/dev/loop7 on /var_test type ext3 (rw)

If you want to mount it permanantly so that it can survive reboots.
root@cpaneltest [~]# vi /etc/fstab
/dev/VolGroup00/LogVol00 /                       ext3    defaults,usrquota,acl        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/usr/tmpDSK             /tmp                    ext3    noexec,nosuid,nodev,noatime,noauto        0 0
/tmp             /var/tmp                    ext3    noexec,nosuid,nodev,noatime,usrquota,bind,noauto        0 0
/dev/loop7      /var_test                       ext3    defaults        0 0
root@cpaneltest [~]# mount -a

For detaching the loop device and unmounting it.
root@cpaneltest [~]# umount  /var_test
root@cpaneltest [~]# losetup -d /dev/loop7
Remove the entry from fstab and run mount -a