Saturday, October 30, 2010

Fatal error: Out of memory (allocated +) (tried to allocate + bytes) ?


Please increase the memory size in php.ini file. If it does not work just put following directives in the httpd.conf file and restart apache :

RLimitMEM 447392422
RLimitCPU 240

You may have increased the RLimitMEM size since above has in bytes.

OR : You can set -1 at ini_set('memory_limit', '-1'); This has in the configuration file of the script.

Try :)

Thursday, October 28, 2010



If you get this error just rectify the login details in the /usr/local/cpanel/base/roundcube/config/ file since it's clear the DB connection error.

Example :

root@2red [/usr/local/cpanel/base/roundcube]# cat config/ | grep roundcube
$rcmail_config['db_dsnw'] = 'mysql://roundcube:DB_PASSWORDlocalhost/roundcube';
// postgres example: 'pgsql://roundcube:pass@localhost/roundcubemail';
root@2red [/usr/local/cpanel/base/roundcube]#

PS: Name of the roundcube database : roundcube
DB username : roundcube
DB password : DB_PASSWORD //it has in /root/.my.cnf file

Also give grant privileges to that db.

That's it try :)

How to install roundcube in the cpanel server?


I referred the following steps :

cd /usr/local/cpanel/base
rm -rf roundcube*
mysql -p -e 'drop database roundcube';
chattr -i /usr/local/cpanel/base/frontend/x/webmaillogin.html
chattr -i /usr/local/cpanel/base/webmaillogin.cgi

cd /usr/local/cpanel/base
tar -zxvf roundcube.tar.gz
rm -rf roundcube.tar.gz
mv -f roundcubemail-0.1-rc1 roundcube
cd roundcube
chmod -R 777 temp
chmod -R 777 logs
mysql -e "use roundcube; source SQL/mysql.initial.sql;" -pDATABASEPASSWORD

Now lets sort out the configuration

cd config

Now open



$rcmail_config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail';

Replace with

$rcmail_config['db_dsnw'] = 'mysql://root:DATABASEPASSWORD@localhost/roundcube';

Now Open



$rcmail_config['default_host'] = '';

Replace with

$rcmail_config['default_host'] = 'localhost';
Now we have to configure cPanel to show roundcube in the theme. Please note this is for the X theme(default) only!! If you use another theme please skip the next part and see below.

cd /usr/local/cpanel/base/roundcube/skins/default/images/
cp --reply=yes roundcube_logo.png /usr/local/cpanel/base/frontend/x/images/roundcube_logo.png
cp --reply=yes roundcube_logo.png /usr/local/cpanel/base/webmail/x/images/roundcube_logo.png
cd /usr/local/cpanel/base
patch -p0 < HGpatch-roundcube-0.1-rc1

chattr +i /usr/local/cpanel/base/frontend/x/webmaillogin.html
chattr +i /usr/local/cpanel/base/webmaillogin.cgi


Sunday, October 24, 2010

How to migrate Plesk data manually with Plesk Migration Manager?

Manually migration?

[How to] How to migrate Plesk data manually with Plesk Migration Manager?
Article ID: 1152
Last Review: Nov,24 2009 Author: Bezborodova Anastasiya
Last updated by: Bezborodova Anastasiya APPLIES TO:
Plesk 8.x for Linux/Unix
Plesk 9.x for Linux/Unix
To do this follow the steps below:

1. Upload migration agent and modules to the source server. For example for Parallels Plesk Panel, there are two folders: /usr/local/psa/PMM/agents/shared and /usr/local/psa/PMM/agents/PleskX. Use the command below to copy the Migration Manager:

destination ~# scp -r /usr/local/psa/PMM/agents/shared/* /usr/local/psa/PMM/agents/PleskX/* root@source:/temporary_migration_directory/

2. Login to source server and change to directory /temporary_migration_directory.
Run migration agent ( with parameter --help to get all available options of the migration agent. Start dumping with options you need. For example:

source ~# cd /temporary_migration_directory
temporary_migration_directory ~# chmod 755
temporary_migration_directory ~# ./ --dump-all

3. This will create dump configuration file dump.xml and content dump archives in current directory /temporary_migration_directory.

4. On the destination server create directory /work_dir and copy file dump.xml from /temporary_migration_directory to it.:

source ~# scp /temporary_migration_directory/dump.xml root@destination:/work_dir/

5. On destination Parallels Plesk Panel 8 create subdirectory /work_dir/archives and copy other content dump files to this directory:

source ~# scp -r /temporary_migration_directory/* root@destinationPPP8:/work_dir/archives/

On destination Parallels Plesk Panel 9 dump.xml and all other content files should locate in the same directory. So copy all other files into /work_dir/:

source ~# scp -r /temporary_migration_directory/* root@destinationPPP9:/work_dir/

6. Deploy the data through Parallels Plesk Panel GUI.

Login to Parallels Plesk Panel (PPP) as administrator and change to the Migration Manager page. The page is Server -> Migration Manager in PPP version 8.x and Home -> Migration Manager in PPP version 9.x

Click button "Start a new migration" and choose "Data import" in PPP version 8.x or "Transfer data already processed by the migration agent and located on the local host." in PPP version 9.x.

In version 8.x pay attention for choosing correct Working directory for the data importing, it should the directory where you put the data to be restored (/work_dir).
In version 9.x put location of dump.xml file in the "Migration data file location" field. It should be /work_dir/dump.xml.

Additional information
In Parallels Plesk Panel version 9 restoration logs of manual migration are located on page Backup Manager at Home -> Backup Manager. So that is normal that you you see the Home page after specifying "Migration data file location" and click Next.

try :)

How to reduce server's load?

You can refer following steps to deal with to reduce server's load :

1 )netstat -plan | grep :80 | awk '{print $5}' | cut -d: -f 1 | sort | uniq -c | sort -n

2) netstat -plan | grep :25 | awk '{print $5}' | cut -d: -f 1 | sort | uniq -c | sort -n

3) pstree -paul

4) cd /tmp

5) rm -f dos-* sess_* .spamassassin*

6) find . -user nobody -exec rm -f '{}' \;

7) ps -C exim -fH ewww

8) ps -C exim -fH eww |grep home

9) netstat -ntu | grep ':' | awk '{print $5}' | awk '{sub("::ffff:","");print}' | cut -f1 -d ':' | sort | uniq -c | sort -n

10) mysqladmin proc |grep Sleep |awk {'print $4'}|cut -d_ -f 1|sort|uniq -c|sort -nk 1

11) ps -C exim -fH ewww

12) for i in `ipcs -s | awk '{print $2}'`; do (ipcrm -s $i); done

13) for i in `mysqladmin proc |grep Sleep |cut -d " " -f 2`; do mysqladmin kill $i; done

14) exim -bp |grep "*** frozen ***" |awk '{print $3}' |xargs exim -Mrm

15) exiqgrep -z -i | xargs exim -Mrm;exiqgrep -o 432000 -i | xargs exim -Mrm

Try :)

How to check server's resource usage?

You can use following script :

root@magneto [/var/log]# cat
top -b -c -n 1 >topresult
while read line
awk '{if( $9 >= 20 ) print $2 ":" $9 ":" $12 }' $line
done <"topresult"
root@magneto [/var/log]

cron :

* * * * * /bin/bash /var/log/ 1>>/var/log/server_resusagewq.log

flush log :

root@magneto [/var/log]# cat

rm -f /var/log/server_resusage.log
touch /var/log/server_resusage.log
echo "===================`date`===================" >>/var/log/server_resusage.log
root@magneto [/var/log]#

cron :
0 1 * * * /bin/bash /var/log/


try :)

How to login into the server using bash script?

Here is the script :



VAR=$(expect -c "
spawn ssh -o StrictHostKeyChecking=no $USER@$HOST $CMD
match_max 100000
expect \"*?assword:*\"
send -- \"$PASS\r\"
send -- \"\r\"
expect eof
echo "==============="
echo "$VAR"

Try :)

How to recursively change the permission of the files?

Use the following commands :

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

Try :)

How to get system information using bash script?

Here is the script that you can use :

# - A simple menu driven shell script to to get information about your
# Linux server / desktop.
# Author: Vivek Gite
# Date: 12/Sep/2007

# Define variables

# Purpose: Display pause prompt
# $1-> Message (optional)
function pause(){
local message="$@"
[ -z $message ] && message="Press [Enter] key to continue..."
read -p "$message" readEnterKey

# Purpose - Display a menu on screen
function show_menu(){
echo "---------------------------"
echo " Main Menu"
echo "---------------------------"
echo "1. Operating system info"
echo "2. Hostname and dns info"
echo "3. Network info"
echo "4. Who is online"
echo "5. Last logged in users"
echo "6. Free and used memory info"
echo "7. exit"

# Purpose - Display header message
# $1 - message
function write_header(){
local h="$@"
echo "---------------------------------------------------------------"
echo " ${h}"
echo "---------------------------------------------------------------"

# Purpose - Get info about your operating system
function os_info(){
write_header " System information "
echo "Operating system : $(uname)"
[ -x $LSB ] && $LSB -a || echo "$LSB command is not insalled (set \$LSB variable)"
#pause "Press [Enter] key to continue..."

# Purpose - Get info about host such as dns, IP, and hostname
function host_info(){
local dnsips=$(sed -e '/^$/d' /etc/resolv.conf | awk '{if (tolower($1)=="nameserver") print $2}')
write_header " Hostname and DNS information "
echo "Hostname : $(hostname -s)"
echo "DNS domain : $(hostname -d)"
echo "Fully qualified domain name : $(hostname -f)"
echo "Network address (IP) : $(hostname -i)"
echo "DNS name servers (DNS IP) : ${dnsips}"

# Purpose - Network inferface and routing info
function net_info(){
devices=$(netstat -i | cut -d" " -f1 | egrep -v "^Kernel|Iface|lo")
write_header " Network information "
echo "Total network interfaces found : $(wc -w <<<${devices})"

echo "*** IP Addresses Information ***"
ip -4 address show

echo "***********************"
echo "*** Network routing ***"
echo "***********************"
netstat -nr

echo "**************************************"
echo "*** Interface traffic information ***"
echo "**************************************"
netstat -i


# Purpose - Display a list of users currently logged on
# display a list of receltly loggged in users
function user_info(){
local cmd="$1"
case "$cmd" in
who) write_header " Who is online "; who -H; pause ;;
last) write_header " List of last logged in users "; last ; pause ;;

# Purpose - Display used and free memory info
function mem_info(){
write_header " Free and used memory "
free -m

echo "*********************************"
echo "*** Virtual memory statistics ***"
echo "*********************************"
echo "***********************************"
echo "*** Top 5 memory eating process ***"
echo "***********************************"
ps auxf | sort -nr -k 4 | head -5
# Purpose - Get input via the keyboard and make a decision using case..esac
function read_input(){
local c
read -p "Enter your choice [ 1 - 7 ] " c
case $c in
1) os_info ;;
2) host_info ;;
3) net_info ;;
4) user_info "who" ;;
5) user_info "last" ;;
6) mem_info ;;
7) echo "Bye!"; exit 0 ;;
echo "Please select between 1 to 7 choice only."

# ignore CTRL+C, CTRL+Z and quit singles using the trap

# main logic
while true
show_menu # display memu
read_input # wait for user input

PS: Please note that Vivek Gite has written this script and you can modify as per your choice.

Try :)

Meaning of special characters in bash scripting?

Guys, You can refer the following information for the bash scripting :

1. Basic : Special charecter :
# --> to comment
; --> command separator.
;; --> terminator, used after "case".

like :

case "$variable" in
abc) echo "\$variable = abc" ;;
xyz) echo "\$variable = xyz" ;;
. --> used to create hidden file and denotes current directory.
" -->partial quoting.
' --> full quoting.
\ -->escape [backslash]
/ -->Filename path separator [forward slash]
` -->command substitution. The `command` construct makes available the output of command for assignment to a variable.
: -->null command [colon]
! --> reverse
* -->wild card [asterisk] and arithmetic multiplication.
$ -->Variable substitution (contents of a variable) and end-of-line.
${} --> Parameter substitution.
$*, $@ --> positional parameters.
$$ -->process ID variable.
{} --> Block of code.

{} --> placeholder for text. ex : ls . | xargs -i -t cp ./{} $1
{} \; --> pathname.
[ ] -->test, array element,range of characters.
> &> >& >> < <> --> redirection.

Example :

scriptname >filename redirects the output of scriptname to file filename. Overwrite filename if it already exists.

command &>filename redirects both the stdout and the stderr of command to filename.

command >&2 redirects stdout of command to stderr.

scriptname >>filename appends the output of scriptname to file filename. If filename does not already exist, it is created.

\<, \> --> word boundary , ex : bash$ grep '\' textfile
| --> pipe , echo ls -l | sh

>| --> force redirection

|| and & , && --> logical operator, & = Run job in background
- --> option, ls -al
^ --> beginning-of-line
Ctl-A -->Moves cursor to beginning of line of text (on the command-line).
Ctl-b -- >Backspace
Ctl-E -->Moves cursor to end of line of text (on the command-line).
Ctl-C -->Break. Terminate a foreground job.
Ctl-D -->Log out from a shell
Ctl-F -->Moves cursor forward one character position (on the command-line).
Ctl-B -->Moves cursor backward one character position (on the command-line).
Ctl-H -->Erases characters the cursor backs over while backspacing.
Ctl-I -->Horizontal t
Ctl-L --> clear the terminal screen
Ctl-P -->old command that has been executed.
Ctl-O -->Issues a newline (on the command-line).
Ctl-y --> PASTE

Try to test :)

How to create fork bomb?

Here is the script to create fork bomb on linux machine.

Please note that once you execute this script, the load of the server will be automatically increased and it'll be hanged.

$0 &

Prevention :

Try :)

Who is using more cpu resources on the linux server?

Guys, Here is the script that you can use :

This script is used to identify overloading script (http & non-http scripts)...


echo "Date/Time CPU% ProcessID ScriptPath"
echo =======================================================================
ps auxw | grep -v root | grep -v /mysql/ | awk '{printf "%d %d\n",$2,$3}' | \
( while read psid cpu; do

if [ $cpu -gt 2 ]; then
lsof -p $psid | grep /home | grep -v sess_ | awk '{print $9}' | \
( while read script_path; do

date +"%m/%d/%Y %H:%M:%S $cpu $psid $script_path"
date +"%m/%d/%Y %H:%M:%S,$cpu,$psid,$script_path" >> /root/sshd-script-overload.log
#mail -s "DDOS ALRT: ESTAB atk on from $ips ($num conn). Atkr blocked." root < /dev/null > /dev/null




try :)

How to send mail using bash script?

You can use following script to send mail(Pls change the e-mail address and its content)
# script to send simple email
# email subject
# Email To ?
# Email text/message
echo "This is an email message test"> $EMAILMESSAGE
echo "This is email text" >>$EMAILMESSAGE
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

try :)

Addition, multiplication etc in bash script?

x=5 # initialize x to 5
y=3 # initialize y to 3

add=$(($x + $y)) # add the values of x and y and assign it to variable add
sub=$(($x - $y)) # subtract the values of x and y and assign it to variable sub
mul=$(($x * $y)) # multiply the values of x and y and assign it to variable mul
div=$(($x / $y)) # divide the values of x and y and assign it to variable div
mod=$(($x % $y)) # get the remainder of x / y and assign it to variable mod

try :)

How to fetch line by line from the file using bash script?


I used following scripts :

while read line
echo-e "$ line \ n"
done ----

where file name is "file.txt".

Try :)

Convert mp4 file to flv ?

use following linux command :

/usr/local/bin/mencoder "video.mp4" -o "video.flv" -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050 -ofps 24 -vf harddup

Input file name :video.mp4
Output file name : video.flv

try :)

How to convert mpg file to flv file using ffmpeg or mencoder?

Here are the steps those I once used :

I converted the video using ffmpeg command line as below.
ffmpeg -i lions.mpg lions-ffmpeg.flv

PS: input file name : lions.mpg

The video was converted fine.

Then I converted the video using mencoder using the command mentioned below.

mencoder lions.mpg -o lions-mencoder.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=450:400 -srate 22050

Then I generated a thumbnail using ffmpeg command mentioned below.

ffmpeg -i lions-ffmpeg.flv -ss 1 -t 00:00:01 -s 120x90 -r 1 -f mjpeg lions.jpg

Then I added meta data to the video.

flvtool2 -U -P lions-ffmpeg.flv
hasKeyframes: true
hasMetadata: true
duration: 9.976
audiosamplerate: 44000
audiodatarate: 63.0167957356935
datasize: 482188

Try :)

How to Install PAE kernel?

To install PAE kernel, use yum command:

yum install kernel-PAE

Just reboot the server and make sure you boot with PAE kernel i.e. 2.6.18-8.1.15.el5PAE:


First, update to the latest current kernel, then install the correct -devel package --

yum update kernel
yum install kernel-devel

Finally, reboot and ensure that you are now running kernel-2.6.18-164.11.1.el5 by "uname -a" command.

kernel-PAE-debuginfo rpm build for : RedHat EL 5. For other distributions click here.

Name : kernel-PAE-debuginfo

Version : 2.6.18
Vendor : Red Hat, Inc_
Release : 164.19.1.el5
Date : 2010-05-24 23:43:01
Group : Development/Debug
Source RPM : kernel-2.6.18-164.19.1.el5.src.rpm
Size : 409.63 MB

src :

Try :)

Friday, October 1, 2010

Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable

Guys, The steps didn't work on our server but it worked for some other guys.

From one xterm run "su oracle-user" then run "export DISPLAY=localhost:0.0"
From another xterm run: "xhost +" and then from the first xterm run the installer.

$ xhost + # this allows any host to connect to the local X11 session

Try :)

How to install oracle database 10g on linux server?

Guys, I referred following steps to do the same :

Oracle 10G Installations on linux 64 or 32 arch) :-


1. Minimum Requirement 40 GB Hard disk and 512 RAM.
2. Check following latest packages has been installed on 32 bit linux machine :-

Note : Please note that try search in google like "download name + rpm". As an example : download Imlib _ + rpm. Then download latest rpm and use "rpm -Uvh package name " to install them. Always try download from


3. For 64 bit architechture following packages must be there :

Note : please note that try search in google like "download name + x86_64.rpm". As an example : download Imlib _ x86_64.rpm. Then download latest rpm and use "rpm -Uvh package name " to install them. Always try download from It's very fast and reliable.


3a). Make sure following Kernel parameters has been tuned :

shmmax = 2147483648
shmmni = 4096
shmall = 2097152
shmseg = 10
semmsl = 250
semmns = 32000
semopm = 100
semmni = 128
file-max = 65536
ip_local_port_range = 1024 65000
rmem_default = 262144
rmem_max = 262144
wmem_default = 262144
wmem_max = 262144

Run :
/sbin/sysctl -p

3b) Add the following lines to the /etc/security/limits.conf file:

* soft nproc 2047
* hard nproc 16384
* soft nofile 1024
* hard nofile 65536

Add the following line to the /etc/pam.d/login file, if it does not already exist:

session required

Disable secure linux by editing the /etc/selinux/config file, making sure the SELINUX flag is set as follows:


4. Creating Oracle User Accounts :
As a root user :

groupadd dba
groupadd oinstall
useradd -c "Oracle software owner" -g oinstall -G dba oracle
passwd oracle

Note : //option -G : oracle is supplemntary user in the group dba

5. Creating directories :

mkdir /u01/app /u01/app/oracle /u01/oradata
chown oracle:oinstall /u01/app /u01/app/oracle /u01/oradata
chmod 775 /u01/app /u01/app/oracle /u01/oradata

6. Download the oracle database source file for 64 or 32 bit linux machine. Here is the site :


a). Download the Oracle 10g release 2 ( software from Oracle website.
Extract the files using following command: For 32bit installation archive

cd /usr/local/src/


b) For 64bit installation archive

gunzip 10201_database_linux_x86_64.cpio.gz
cpio -idmv <10201_database_linux_x86_64.cpio

For RHEL 5, Centos 5: Modify database/install/oraparam.ini file and add "redhat-5" to "Certified Versions" section.

[Certified Versions]

8. Login as root and issue the following command:

xhost +
Note : Either use only + or use mc ip where x windows has. + will search all attached mc where x windows has.

9. Login as the oracle user and add the following lines at the end of the .bash_profile file:

# Oracle Settings
TMP=/tmp; export TMP

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
PATH=/usr/sbin:$PATH; export PATH


if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
ulimit -u 16384 -n 65536

10. cd /home/oracle
. .bash_profile //activating current settings for oracle user

Installation :

11. Log into the oracle user. If you are using X emulation then set the DISPLAY environmental variable : like

su - oracle
DISPLAY=:0.0; export DISPLAY

or : DISPLAY=localhost:0.0; export DISPLAY

You may have to execute as a oracle user :

export TMP=/oratmp
export TEMPDIR=/oratmp

12. Start the Oracle Universal Installer (OUI) by issuing the following command in the database directory:

Go to database directory :

cd /usr/local/src/database

13. You may see x11 windows could not find error. In that case make it sure that one x11 machine has connected to your server.

If it goes fine, try to proceed further to install oracle via GUI.

A) Post-Instalation Tasks : Auto Startup and Shutdown of Database and Listener :-

Login as root and modify /etc/oratab file and change last character to Y for apropriate database.


As root user create new file "oracle" (init script for startup and shutdown the database) in /etc/init.d/ directory with following content:

# oracle Init file for starting and stopping
# Oracle Database. Script is valid for 10g and 11g versions.
# chkconfig: 35 80 30
# description: Oracle Database startup script

# Source function library.

. /etc/rc.d/init.d/functions


case "$1" in
echo -n $"Starting Oracle DB:"
echo "OK"
echo -n $"Stopping Oracle DB:"
echo "OK"
echo $"Usage: $0 {start|stop}"

Execute (as root) following commands (First script change the permissions, second script is configuring execution for specific runlevels):

chmod 750 /etc/init.d/oracle
chkconfig --add oracle --level 0356

2. Auto Startup and Shutdown of Enterprise Manager Database Control :-

As root user create new file "oraemctl" (init script for startup and shutdown EM DB Console) in /etc/init.d/ directory with following content:

# oraemctl Starting and stopping Oracle Enterprise Manager Database Control.
# Script is valid for 10g and 11g versions.
# chkconfig: 35 80 30
# description: Enterprise Manager DB Control startup script

# Source function library.

. /etc/rc.d/init.d/functions


case "$1" in
echo -n $"Starting Oracle EM DB Console:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "OK"
echo -n $"Stopping Oracle EM DB Console:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "OK"
echo $"Usage: $0 {start|stop}"

Execute (as root) following commands (First script change the permissions, second script is configuring execution for specific runlevels):

chmod 750 /etc/init.d/oraemctl
chkconfig --add oraemctl --level 0356

3. You may consider to use rlwrap for comfortable work with sqlplus and rman utility :-
RPM package for RedHat compatible (x86) distribution you can download here.
RPM package for RedHat compatible (x86_64) distribution you can download here.
su -
# rpm -ivh rlwrap*.rpm
# exit
echo "alias sqlplus='rlwrap sqlplus'" >> /home/oracle/.bash_profile
echo "alias adrci='rlwrap rman'" >> /home/oracle/.bash_profile
. /home/oracle/.bash_profile

That's it try :)