Wednesday, September 5, 2012

Find Which PHP Application is sending mail from Linux Box

Add the follwing line in php.ini

sendmail_path = /usr/local/bin/sendmail-php -t -i

Create a shell script file in /usr/local/bin/sendmail-php and paste the following code in this file


#!/bin/sh

logger -p mail.info sendmail-php: site=${HTTP_HOST}, client=${REMOTE_ADDR}, script=${SCRIPT_NAME}, filename=${SCRIPT_FILENAME}, docroot=${DOCUMENT_ROOT}, pwd=${PWD}, uid=${UID}, user=$(whoami)

/usr/sbin/sendmail -t -i $*

restart the apache server

and view the apache error log using

#tail -f /var/log/httpd/error_log 


Monday, September 3, 2012

Basic Linux commands

Basic Linux Commands
mkdir - make directories
Ex:
mkdir folder1

cd - change directories

mv- change the name of a directory
Ex:
mv oldfolder newfolderr

pwd - print working directory
will show you the full path to the directory you are currently in.

rmdir -Remove an existing directory
Ex:
rm -rf folder1
Force to remove directories and files within the directories recursively.

chown - change file owner and group
Ex:
chown owner:group file
chown -R owner :group folder
R -recursive operate on files and directories recursively

chmod - change file access permissions
Usage
chmod 644 filenames
chmod -R 755 folder
R -recursive operate on files and directories recursively
4 = r (Read)
2 = w (Write)
1 = x (Execute)


CHMOD can also to attributed by using Numeric Permissions:
400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody

ls - Short listing of directory contents
-a list hidden files
-dlist the name of the current directory
-F show directories with a trailing '/'
-R list all subdirectories encountered
-t sort by time modified instead of name

cp - Copy files and folders
Ex:
cp exsistingfile newfile
Copy the files "exsistingfile" to the file "newfile" in the current working directory.
cp -i exsistingfile newfile
With the "-i" option, if the file "newfile" exists, you will be prompted before it is overwritten.
cp -avf onefolder anotherfolder
Options
a-All
v-Verbose
f-Force


find – find files and folders
Ex:
$ find . -name diag
./Downloads/diag