Friday, February 29, 2008

Basic qmail commands

These files are in location /var/qmail/bin

qmail-clean
--- clean up the queue directory

qmail-getpw -- qmail-getpw finds the user that controls a particular address, local.

qmail-inject --- preprocess and send a mail message

qmail-qread --- list outgoing messages and recipients. qmail-qread must be run either as root or with user id qmails and group id qmail.

qmail-qstat ---- summarize status of mail queue

qmail-queue -- queue a mail message for delivery. qmail-queue reads a mail message from descriptor 0. It then reads envelope information from descriptor 1. It places the message into the outgoing queue for future delivery by qmail-send.

qmail-remote -- send mail via SMTP

qmail-remote host sender recip [ recip ... ] mail-remote reads a mail message from its input and sends the message to one or more recipients at a remote host.

qmail-send ----- deliver mail messages from the queue

qmail-start - turn on mail delivery. invokes qmail-send, qmail-lspawn, qmail-rspawn, and qmail-clean. These four daemons cooperate to deliver messages from the queue.

splogger - make entries in syslog

qmail-showctl - analyze the qmail configuration files

The mail log file in the location /var/log/send/current . Here you can find the log of send/received mail.
.

Monday, February 25, 2008

Tips & Tricks

Linux Tips & Tricks

How to See the SSH password guesses

First, find the PID of the listening SSH daemon process:
# ps axuww | egrep 'PID|ssh'
Now become root and attach to the running daemon with strace:
#
strace -f -e 'read,write' -p12345

Convert 'man' pages to pdf format

Here is the way to convert man pages to PDF format
# man -t man | ps2pdf - > man.pdf

Cpanel Tips & Tricks

Installing imagemagick on a cpanel server

1. Log into your server as root
2. Create a new directory as below :
mkdir /home/cpimins
3. cd /home/cpimins
4. wget http://layer1.cpanel.net/magick.tar.gz
5. tar zxvf magick.tar.gz
6. cd magick
7. /scripts/installrpm ImageMagick
8. /scripts/installrpm ImageMagick-devel
9. sh ./install


Addhandler
apache 1.3.x vs apache 2.x

---------------------------------

PHP CGI vs Apache Module Install

There are two ways to install PHP on your server:

1) As an APACHE module: This method provides the fastest operation of PHP and is generally more compatible with scripts and other server software.

2) As a CGI binary: This method is used when security is key. When there are several web sites on one server, this method provides better tracking of each domains use of PHP. The price is slower PHP.

If you have your own server, you want to install PHP as an Apache module.

What are the steps to compile php as CGI?

Just run ./configure again and don't specify "--with-apxs" or "--with-apache".

You can see a good tutorial of installing php as cgi and as an apache module in below link

for linux :

http://blazonry.com/scripting/install_apache.php

for windows :

http://www.php-mysql-tutorial.com/install-apache-php-mysql.php
.

.htaccess

.htaccess is an access control file that provides a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof. .htaccess files should be used in a case where the content providers need to make configuration changes to the server on a per-directory basis, but do not have root access on the server system. In the event that the server administrator is not willing to make frequent configuration changes, it might be desirable to permit individual users to make these changes in .htaccess files for themselves.

Note: If you want to call your .htaccess file something else, you can change the name of the file using the AccessFileName directive. For example, if you would rather call the file .config then you can put the following in your server configuration file:

AccessFileName .config

Some tips about .htaccess file
-------------------------------------
CHMOD the htaccess file to 644 or (RW-R--R--)

htaccess files must be uploaded as ASCII mode, not BINARY

htaccess files affect the directory they are placed in and all sub-directories.

The use of .htaccess files can be disabled completely by setting the AllowOverride directive to "none" AllowOverride None [Options, FileInfo, AuthConfig, Limit]

.htaccess files can override the sections for the corresponding directory, but will be overriden by other types of configuration sections from the main configuration files. This fact can be used to enforce certain configurations, even in the presence of a liberal AllowOverride setting. For example, to prevent script execution while allowing anything else to be set in .htaccess you can use:


Allowoverride All



Options +IncludesNoExec -ExecCGI

Another common use of .htaccess files is to enable Server Side Includes for a particular directory. This may be done with the following configuration directives, placed in a .htaccess file in the desired directory:

Options +Includes
AddType text/html shtml
AddHandler server-parsed shtml



Finally, you may wish to use a .htaccess file to permit the execution of CGI programs in a particular directory. This may be implemented with the following configuration:

Options +ExecCGI
AddHandler cgi-script cgi pl

To stop people from viewing a particular directory in your site, include this line in the .htaccess:
order allow,deny
deny from all

To stop everyone expect one from viewing a particular directory in your site add the following in
.htaccess file. Replace IP with the public IP of the one who you want to enable access to the link

order deny,allow
deny from all
allow from IP

You can use .htaccess file to redirect your website. Two examples using redirect rules are as follows

RewriteCond %{HTTP_HOST} ^.*mysite-1.com$ [NC]
RewriteRule ^(.*)$ http://mysite-1.myothersite.com/$1 [R=301,L]


RewriteEngine On

RewriteCond %{HTTP_HOST} ^subdomain.domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.subdomain.domain.com$
RewriteRule .* http://otherdomain.com/ [r]

To redirect public_html directory to a subdirectory (for example to redirect www.domain.com to www.domain.com/test)

put the following code in a .htaccess file in public_html directory

RewriteEngine On

RewriteRule ^(.*)$ test/$1 [L]

To execute php files in the directory as php5 code
AddHandler application/x-httpd-php5 .php



Wednesday, February 13, 2008

Welcome to Art of Linux



Articles in this blog are just an overview of what they are... If you need a deeper knowledge you have stepped into a wrong location. :)