Tuesday, May 29, 2012

rsync Command

rsync is used to perform the backup operation in UNIX / Linux. rsync utility is used to synchronize the files and directories from one location to another in an effective way.  

Example : Synchronize Files From Local to Remote using shell(ssh with port)
rsync -avzi -e "ssh -p 2445" /var/lib/ldap/ username@192.168.32.101:/var/lib/ldap/

Example : Synchronize Files From Remote to Local

rsync -avz username@192.168.200.10:/var/lib/rpm /root/temp

Read More : Click here 

Saturday, May 19, 2012

Filter mail with postfix header_checks


First up under /etc/postfix ensure that you have a file called header_checks. If not create it.
Next we want to ensure Postfix is configured to use this file so you do this from a command line by entering the following:
postconf -e "header_checks = regexp:/etc/postfix/header_checks"
The syntax in the header_checks file is:
/regex_pattern/ ACTION
Example :
#/etc/postfix/header_checks

/^From: "spam/ REJECT

/^To: example@example.com/ REDIRECT @esxe.com

/^Subject:.*viagra/ DISCARD
More Detail Link 1 Link 2

PHP : mysql_real_escape_string() function


The mysql_real_escape_string() function escapes special characters in a string for use in an SQL statement
The following characters are affected
Syntax : mysql_real_escape_string(string,connection)
string : Required. Specifies the string to be escaped
connection  : Optional. Specifies the MySQL connection. If not specified, the last connection opened by mysql_connect() or mysql_pconnect() is used.

Example :
<?php
// Connect$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')    OR die(mysql_error());
// Query$query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
            mysql_real_escape_string($user),      
           mysql_real_escape_string($password));
?>