Server Administration & Management

How to change MySQL database directory to another partition as /var patition full

you might have faced the issue of /var partition gettting full regularly due to database directory. If you have a larger partition with free space, then it is possible to move the database directory to the larger partition.  Here are the steps :-

1. Switch off the database server while we are moving the databases.

# /etc/rc.d/init.d/mysql stop

2. As considering that I have enough space in /home partition. Here goes my new database data directory as

# mkdir /home/mysql

3. Now it is better to copy the database first, rather than move.

# cp -prdf /var/lib/mysql  /home/

# mv /var/lib/mysql /var/lib/mysql-bk

4. We are copying the database to the new location since it is better to revert back the settings with minimum downtime, if anything goes wrong. Take a backup of /etc/my.cnf

# cp /etc/my.cnf  /etc/my.cnf.bak

5. Now edit /etc/my.cnf

# vi /etc/my.cnf
log_slow_queries = /var/log/mysql/mysql-slow.log

# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).


Please note that you don’t specify the socket file location in my.cnf since it causes issues with phpMyadmin

1. For, cPanel server, edit the phpMyadmin configuration take a backup of “/usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php”

# cp /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php  /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php.bak

2. edit this file /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php

# vi /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php

3. add the following lines. If they already exist, edit as below.
(the connect_type usually exist at “tcp” change it to “socket”)

$cfg[‘Servers’][$i][‘socket’] = ‘/home/mysql/mysql.sock’;
$cfg[‘Servers’][$i][‘connect_type’] = ’socket’;

4. Now start the database server.

# /etc/ini.d/mysql start

If it starts fine, you are done. Check the database connections of your site. You can now remove the directory /var/lib/mysql-bk

August 31, 2011 Posted by | cPanel, MySQL | , , | Leave a comment

How to clear Disk Space on a Server

Running out of disk space is a very common issue.  Be it a web-hosting service provider or the end-user.  As we know, there are various partitions on a server which are meant for different purposes. So, the methods used to deal with space issues on these partitions will also vary. Let us see them one by one.


/USR partition

1. Restart the httpd service. This might free a little space some times.

2. Check for apache logs like error_log, access_log , suexec_log in /usr/local/apache/logs . These can either be cleared off or if you need the logs then you can take a zipped copy and keep it aside.

3. Same can be done for the files in cPanel logs (/usr/local/cpanel/logs)  as well .

4. Domlogs – Get into  the /usr/local/apache/domlogs/ directory. Run the following command :-

# cd /usr/local/apache/dmlogs/

#  ls -al -SR | head -10        —> It will list 10 files in the decreasing order according to their size

If the domlog file is too large for a domain then it is possible that awstats is not running . Check whether cpanellogd is running on the server  using  pstree . If not, restart it .Else, it is possible that awstats for only that particular domain is not updating. Get into the directory /usr/local/cpanel/base and check if any file as ‘awstats.domainname.com.conf’ exists.   If yes , delete that file. Now,  run /scripts/runweblogs for that user.  It will update the awstats and automatically clear the domlogs file thereafter. Do not delete the domlogs file itself.

# /usr/local/cpanel/base

# rm -rv ‘awstats.domainname.com.conf’

# /scripts/runweblogs

5. Remove old and unwanted backups of  ‘apache’  that might have been taken long ago. Also, check for any other duplicate folders that can be removed safely.

6. Remove core files, if any . Normally, some core files (like core.1234) might be present in /usr/local/cpanel/whostmgr/docroot . Check for these and remove them.


/HOME partition

1.  Check for unwanted cpmove/tar files for the user accounts in /home and delete them.

2.  Check for any cpmove folders as well in /home

3.  Check the folder ‘cprestore’  in /home for any tar files. Be careful. These should  be deleted only if they are very old,say about 4-5 months.

4. Using find command you can check for unwanted tar files(especially cpmove/backup) in the entire home directory. Check their size. If you think that deleting them will  make considerable difference to the disk space then delete them.

5. Check for core files and delete them.

6.  Search for large accounts and see if they are hosting any prohibited content or violating your company policies. If yes, take appropriate measures as per your policies.


/VAR partition

1. Restart the mysql service.

2. Log files in /var/log like exim_mainlog, mailmon.log, messages, mysqld.log, mysql_slow_queries.log  can be deleted after taking backups of the required ones.

# cd /var/log

# echo > exim_mainlog

# echo > mailmon.log

# echo > messages

# echo > mysqld.log

# echo > mysql_slow_queries.log

Note that there is no point in deleting these log files if the size is very small. Check whether deleting these would make any difference. If you are deleting them then do re-create the files, or you can use the command ‘echo ” ” > logfile’ to empty the existing files.

3.  Clear Mysql logs like server-name.err or any other  present  in /var/lib/mysql

# cd /var/lib/mysql

# echo > server-name.err

4. Delete mysql-bin.000* file  in /var/lib/mysql, if present.

5. There might be useless large .sql files   in /var/lib/mysql . Delete them.

6.  Remove unwanted emails from spool. You can use the following code to do that :

# exim -bpc

# exim -bpru | grep frozen | awk {‘print $3′}|xargs exim -Mrm

# exim -bpru | grep “<>” | awk {‘print $3′}|xargs exim -Mrm

# exim -bpru | grep “nobody” | awk {‘print $3′}|xargs exim -Mrm

# exim -bpru|awk {‘print $3′}|xargs exim -Mrm

# exiqgrep -o 86400 -i | xargs exim -Mrm

7. There might be yum cache files inside the /var/cache folder which can take space. To remove them do:

#  yum clear all

#  yum list all

8. Again, search for any core files ( core dump ) like core.12* etc.


/BACKUP partition

1. Remove any tar/cpmove files if they are too old and large.

2. Remove any old  configuration backups ( like apache.bkp) or any log file backup , say 3-4 months old.

3. Check for core files and remove them.

These are some of the general steps that can be followed to deal with space issues on the servers.

August 30, 2011 Posted by | cPanel, Tips & Tricks, Unix/Linux | , , , | Leave a comment

mysql has failed, please contact the sysadmin (result was “mysql has failed”)

Now a most common problem we are facing with the mysql on newly installed server if we have mysql 5 we mostly receive following error message when starting mysql service from WHM

“mysql has failed, please contact the sysadmin (result was “mysql has failed”).”

As well as when ever we run mysql from shell its gives error message

“Access denied for user ‘root’@’localhost’ (using password: YES)”.

In that case we need to remove mysql from server and reinstall it by using following commands.

# which mysql

#mv /usr/bin/mysql /usr/bin/mysql-back

# /scripts/mysqlup  –force

Now reset the root password from WHM –> Main –> SQL Services –> MySQL Root Password

Now you will able to access mysql without any problem.


Some time above solution also not allowing to access mysql still throws following error message.

# mysql

“Access denied for user ‘root’@’localhost’

In that case refer following steps but carefully as it will cause you database loss.

# /etc/init.d/mysql stop

# mv /var/lib/mysql/    /var/lib/mysql-back

# mv /etc/my.cnf     /etc/my.cnf-back

# /scripts/mysqlup –force

# /etc/init.d/mysql start

# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1430564
Server version: 5.0.85-community MySQL Community Edition (GPL)

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

mysql> q

Now you can restore the databases from /var/lib/mysql-back to /var/lib/mysql

# cp -rvf /var/lib/mysql-back    /var/lib/mysql

August 29, 2011 Posted by | MySQL | | Leave a comment

How to Installing MyTop on WHM-cPanel Server

MyTop is one of the best MySQL monitoring tools available, Its vital for monitoring your MySQL health, especially in a shared hosting environment. Installation on a RHEL/CentOS (for cPanel) server is quite straight forward with this guide.
First off, we need a few perl modules, cPanel’s realperlinstaller comes in handy, if you aren’t on cPanel, you’ll need to CPAN or manually install these modules.

# /scripts/realperlinstaller –force Getopt::Long

# /scripts/realperlinstaller –force DBI

# /scripts/realperlinstaller –force DBD::mysql

# /scripts/realperlinstaller –force Term::ReadKey

Now, we download and install mytop.

# wget http://jeremy.zawodny.com/mysql/mytop/mytop-1.6.tar.gz

# tar zxpfv mytop-1.6.tar.gz

# cd mytop-1.6

# perl Makefile.PL && make && make install

NOTE: You may get following error in CentOS 5.x
Error in option spec: “long|!”

Search for the line in Makefile.PL

“long|!”              => $config{long_nums},

Change it to by commenting using #

#”long|!”              => $config{long_nums},

Easy fix.
After installing mytop you need to create a new file under /root/.mytop (mytop config file for root) with the lines below (mysql root password is found on /root/.my.cnf:

pass=<your mysql password>

Now you can run mytop

# mytop -d mysql

August 28, 2011 Posted by | cPanel, MySQL | , , | Leave a comment


## load_alert.sh ##
SUBJECT=”Alert $(hostname) load average is $L05″
echo “Load average Crossed allowed limit.” >> $TEMPFILE
echo “Hostname: $(hostname)” >> $TEMPFILE
echo “Local Date & Time : $(date)” >> $TEMPFILE
echo “| Uptime status: |” >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
/usr/bin/uptime >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
echo “| Top 10 CPU consuming processes: |” >> $TEMPFILE
ps aux | head -1 >> $TEMPFILE
ps aux –no-headers | sort -rn +2 | head -20 >> $TEMPFILE
echo “| Top 10 memory-consuming processes: |” >> $TEMPFILE
ps aux –no-headers| sort -rn +3 | head >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
echo “| Memory and Swap status: |” >> $TEMPFILE
/usr/bin/free -m >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
echo “| Active network connection: |” >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
/bin/netstat -tnup | grep ESTA >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
echo “| Disk Space information: |” >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
/bin/df -h >> $TEMPFILE
echo “—————–THE END——————-” >> $TEMPFILE
L05=”$(uptime|awk ‘{print $(NF-2)}’|cut -d. -f1)”
if test $L05 -gt $TOPLOAD
mail -s “$SUBJECT  $L05” “$EMAIL” < $TEMPFILE

August 27, 2011 Posted by | Shell Script | | Leave a comment

InnoDB: No valid checkpoint found

You may find this error while restarting the mysql service on the server. Error is as follows:-

# /etc/init.d/mysql restart
Shutting down MySQL…                           [  OK  ]
Starting MySQL.                                         [  OK  ]

# tail -f /var/log/mysqld.log
100825 08:25:02  mysqld started
InnoDB: No valid checkpoint found.
InnoDB: If this error appears when you are creating an InnoDB database,
InnoDB: the problem may be that during an earlier attempt you managed
InnoDB: to create the InnoDB data files, but log file creation failed.

To fix this goahead with the steps given below;-

# cd /var/lib/mysql/

# rm -rvf  ib_logfile0

# rm -rvf  ib_logfile1

# rm -rvf  ibdata1

# /etc/init.d/mysql restart
Shutting down MySQL…..                         [  OK  ]
Starting MySQL……                                 [  OK  ]

Check the InnoDB engine status now. It should be enabled now.

mysql> show engines;
| Engine     | Support | Comment                                                        |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance         |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      |
| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys     |
| BerkeleyDB | NO      | Supports transactions and page-level locking                   |
| BLACKHOLE  | YES     | /dev/null storage engine (anything you write to it disappears) |
| EXAMPLE    | YES     | Example storage engine                                         |
| ARCHIVE    | YES     | Archive storage engine                                         |
| CSV        | YES     | CSV storage engine                                             |
| ndbcluster | NO      | Clustered, fault-tolerant, memory-based tables                 |
| FEDERATED  | YES     | Federated MySQL storage engine                                 |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          |
| ISAM       | NO      | Obsolete storage engine                                        |

August 26, 2011 Posted by | MySQL | | Leave a comment

cPanel Backend files

cPanel Back-end files

+ bin- apache binaries are stored here – httpd, apachectl, apxs
+ conf – configuration files – httpd.conf
+ cgi-bin
+ domlogs – domain log files are stored here
+ htdocs
+ include – header files
+ libexec – shared object (.so) files are stored here – libphp4.so,mod_rewrite.so
+ logs – apache logs – access_log, error_log, suexec_log
+ man – apache manual pages
+ proxy –
+ icons –
Init Script :- /etc/init.d/httpd – apache start script
Cpanel script to restart apache:- /scripts/restartsrv_httpd

Conf : /etc/exim.conf – exim main configuration file
/etc/localdomains – list of domains allowed to relay mail
Log : /var/log/exim_mainlog – incoming/outgoing mails are logged here
/var/log/exim_rejectlog – exim rejected mails are reported here
/exim errors are logged here
Mail queue: /var/spool/exim/input
Cpanel script to restart exim – /scripts/restartsrv_exim
Email forwarders and catchall address file – /etc/valiases/domainname.com
Email filters file – /etc/vfilters/domainname.com
POP user authentication file – /home/username/etc/domainname/passwd
catchall inbox – /home/username/mail/inbox
POP user inbox – /home/username/mail/domainname/popusername/inbox
POP user spambox – /home/username/mail/domainname/popusername/spam
Program : /usr/sbin/exim (suid – -rwsr-xr-x 1 root root )
Init Script: /etc/rc.d/init.d/exim

Program :/usr/sbin/proftpd
Conf: /etc/proftpd.conf
Log: /var/log/messages, /var/log/xferlog
FTP accounts file – /etc/proftpd/username – all ftp accounts for the domain are listed here
Init Script :/etc/rc.d/init.d/proftpd

Program : /usr/sbin/pure-ftpd
Conf: /etc/pure-ftpd.conf
Anonymous ftp document root – /etc/pure-ftpd/ip-address
Init Script :/etc/rc.d/init.d/pure-ftpd

Frontpage Extensions
Program – (Install): /usr/local/frontpage/version5.0/bin/owsadm.exe
Uninstall and then install for re-installations
FP files are found as _vti-bin, _vti-pvt, _vti-cnf, vti-log inside the public_html

Program : /usr/bin/mysql
Conf : /etc/my.cnf, /root/.my.cnf
Data directory – /var/lib/mysql – Where all databases are stored.
Database naming convention – username_dbname (eg: john_sales)
Permissions on databases – drwx 2 mysql mysql
Socket file – /var/lib/mysql/mysql.sock, /tmp/ mysql.sock
Init Script : /etc/rc.d/init.d/mysql

Program :/usr/local/sbin/sshd
Log: /var/log/messages
Init Script :/etc/rc.d/init.d/sshd

Program :/usr/bin/perl
Directory :/usr/lib/perl5/5.6.1/

Program :/usr/local/bin/php, /usr/bin/php
ini file: /usr/local/lib/php.ini – apache must be restarted after any change to this file
php can be recomplied using /scripts/easyapache

Program: /usr/sbin/named
db records:/var/named/
Init Script: /etc/rc.d/init.d/named

cPanel installation directory structure
+ 3rdparty/ – tools like fantastico, mailman files are located here
+ addons/ – AdvancedGuestBook, phpBB etc
+ base/ – phpmyadmin, squirrelmail, skins, webmail etc
+ bin/ – cpanel binaries
+ cgi-sys/ – cgi files like cgiemail, formmail.cgi, formmail.pl etc
+ logs/ – cpanel access log and error log
+ whostmgr/ – whm related files

WHM related files
/var/cpanel – whm files
+ bandwidth/ – rrd files of domains
+ username.accts – reseller accounts are listed in this files
+ packages – hosting packages are listed here
+ root.accts – root owned domains are listed here
+ suspended – suspended accounts are listed here
+ users/ – cpanel user file – theme, bwlimit, addon, parked, sub-domains all are listed in this files
+ zonetemplates/ – dns zone template files are taken from here

August 25, 2011 Posted by | cPanel | | Leave a comment

Horde Session Issue

There is a very common  issue where Horde prevents access to webmail by repeatedly redirecting viewers to Language Selection screen. The following commands, executed as root, will solve these issues:

# /usr/local/cpanel/bin/checkperlmodules

# /scripts/fullhordereset

# myisamchk -r /var/lib/mysql/horde/horde_sessionhandler.MYI

If still you have problem then check the ownership for session directory present in /var/cpanel/userhomes/cpanelhorde directory.

# ll /var/cpanel/userhomes/cpanelhorde

drwx–x–x 4 cpanelhorde cpanelhorde 4096 Jun  5  2011 ./
drwx–x–x 7 root        root        4096 Dec 17 01:48 ../
drwxr-x— 2 cpanelhorde cpanelhorde 4096 Jun  5  2011 mail/
drwx—— 2 cpanelhorde cpanelhorde 4096 Jan 27 14:01 sessions/

Session directory should be cpanelhorde.cpanelhorde ownership recursively.



August 24, 2011 Posted by | MySQL | , | Leave a comment

Install pdo_mysql

1. Basically, you will need to compile pear and mysql from your Apache. Run the command as below to get it updated.

# yum install php-devel php-pear mysql-devel httpd-devel

# pecl install pdo

# PHP_PDO_SHARED=1 pecl install pdo_mysql

2. Open your php.ini file and insert the line as below.


3. Restart the Apache services.

# /etc/init.d/https restart

August 23, 2011 Posted by | MySQL, PHP | , , | Leave a comment


Q: – What is a zombie?

Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table.

Zombie : The process is dead but have not been removed from the process table.

August 22, 2011 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

MySQL database Directory

MySQL uses files to store data. By default, these data files are locate under the “/var/lib/mysql” directory, where databasename is the name of the database. Also we can store mysql database under desire location with the help of my.cnf, Basically my.cnf file is MySQL configuration file. MySQL Database are three file types:

.FRM –> file contain the table schema.
.ISD –> is the file that actually holds the data.
.ISM –> is the file that provides quick access between the two of them.

August 21, 2011 Posted by | MySQL | | Leave a comment

Features of MySQL

MySQL is a full-featured relational database management system. It is very stable and has proven itself over time. MySQL has been in production for over 10 years.

– MySQL is a multithreaded server. Multithreaded means that every time someone establishes a connection with the server, the server program creates a thread or process to handle that client’s requests. This makes for an extremely fast server. In effect, every client who connects to a MySQL server gets his or her own thread.

– MySQL is also fully ANSI SQL92-compliant. It adheres to all the standards set forth by the American National Standards Institute.

– Another feature of MySQL is its portability, it has been ported to almost every platform. This means that you don’t have to change your main platform to take advantage of MySQL. And if you do want to switch, there is probably a MySQL port for your new platform.

– MySQL also has many different application programming interfaces (APIs). They include APIs for Perl, TCL, Python, C/C++, Java (JDBC), and ODBC.

August 20, 2011 Posted by | MySQL | | Leave a comment

MySQL Commands Tips

Set root password of MySQL as redhat
mysql> set password = password (‘redhat’);

Provide access to all database from IP address by password redhat
mysql> grant all on *.* to `root`@`` identified by ‘redhat’;

Provide access to all database from all IP addresses by password redhat
mysql> grsnt all on *.* to `root`@`%` identified by ‘redhat’;

Provide access to all database from localhost by password redhat
mysql> grant all on *.* to `root`@`localhost` identified by ‘redhat;

Create database name as unixserver_test
mysql> create database unixserv_test;

Take backup of freshnew, depots database to tables.sql file under / directory by user root & password redhat
mysql> mysqldump -u root -p redhatfreshnew depots > /tables.sql;
mysql> mysqldump -u root -p redhat unixserv > unixserv.sql;
mysql> mysqldump -h unixse > unoxse.sql;

mysql> show users;

mysql> show databases;

mysql> use information_schema;

mysql> show tables;

mysql> select * from USER_PRIVILEGES;

mysql> show processlist;

mysql> show full processlist;

mysql> update ibrs_users set password = md5(‘redhat’) where user_cd = ‘mvyw’;

mysqlimport for importing data files,

mysqldump for making backups,

mysqladmin for server administration, and

mysqlcheck for checking the integrity of the database files.

mysql> status;  It will display information about the current connection to the server, as well as status information about the server itself.

:- The MySQL Query Browser is a graphical tool designed to provide a user friendly environment in which to construct and execute SQL statements.

:- The myisamchk utility performs table maintenance on MyISAM tables.

August 19, 2011 Posted by | MySQL, Tips & Tricks | , | Leave a comment

Enable & Configure Firefox for Java Console & Plugins

To configure the Java Plugin follow these steps:

1. Exit Firefox browser if it is already running.
2. Uninstall any previous installations of Java Plugin.
3. Only one Java Plugin can be used at a time. When you want to use a different plugin, or version of a plugin,
remove the symbolic links to any other versions and create a fresh symbolic link to the new one.
4. Create a symbolic link to the libnpjp2.so file in the browser plugins directory
5. Go to the plugins sub-directory under the Firefox installation directory
6. cd <Firefox installation directory>/plugins
7. Create the symbolic link
8. ln -s <Java installation directory>/lib/i386/libnpjp2.so

Note: If you are upgrading your Java version then before creating new symbolic link you should remove old symbolic
link to enable latest downloaded Java.

1. To remove old symbolic link:
2. type cd <Firefox installation directory>/plugins
3. rm libjavaplugin_oji.so

If Firefox is installed at this directory:

# /usr/lib/<Firefox installation directory>/

# mkdir plugins

# cd plugins

Enter the following command to create a symbolic link to the Java Plug-in for the Mozilla browser.

# ln -s /usr/java/latest/lib/i386/libnpjp2.so

Start the Firefox browser, or restart it if it is already up. In Firefox, type about:plugins in the Location bar to confirm that the Java Plugin is loaded. You can also click the Tools menu or Type “about:config” in address bar to confirm that Java Console is there.


August 18, 2011 Posted by | Java, Tips & Tricks, Tomcat, Unix/Linux | , , | Leave a comment

How to check if innodb is enabled in MySQL Server

MySQL database server has the capability to use different database storage engines. The database storage engine is what actually do the work of storing and retrieving data from the underlying database tables. The storage engines work like a modular code which can be plugged into MySQL.

Among the storage engines MyISAM is the one, used most widely and also the default storage engine for MySQL. However it do lack some high level functionalists which are requirement for any enterprise level database server e.g. it do not have proper support for transaction or foreign key.

This is where InnoDB storage engine comes into play, InnDB is a transaction safe storage engine with support for foreign keys along with commit, rollback and crash recovery capabilities. InnoDB is a product of Innobase Oy, which a Finnish company now owned by Oracle. MySQL has a licensing agreement with Innobase Oy which allows it to provide the InnoDB.

As we have covered some InnoDb background lets take a look at main ‘how to’ topic , i.e. how we can check if the MySQL server we are running has InnDB support enabled or not. There is a MySQL system variable have_inndb and its value can be checked to see if the support enabled or not. You can do this by using following command :

# mysqladmin varitables | grep have_innodb

If this returns YES then it means that the InnoDB support is enabled.

If you have ‘–skip-innodb’ in your /etc/my.cnf MySQL configuration file then InnoDB engine would be disabled. And in that case you can comment out this option to enable InnoDB. It is enabled by default and unless there is some related disable configuration added to my.cnf configuration, there should be no issues. Also if you would like to use InnoDB as the default storage engine, you can do that by using below configuration in /etc/my.cnf :


But make sure to do your homework before setting the storage engine, it do have performance benefits over MyISAM once its configured properly, but do have higher administrative cost. InnoDB can be configured to have per table innodb file, which do help in isolating any individual database corruptions.

August 17, 2011 Posted by | MySQL | , | Leave a comment

Increasing Datacenter Resolver Cluster Efficiency

Every server in every datacenter has a default set of resolvers to reach the outside world.  Some have 3 or 4, some even have up to 8!  Whatever the case, you know if they have a lot of servers, their clients have to be hammering it with DNS lookups, right?  Well, should your hosting provider provide multiple servers for DNS recursion, please do them a favor and rotate through them, don’t just use the first one!  Here’s how:

A standard webhosting [unixserveradmin.com] /etc/resolv.conf looks like:

search unixserveradmin.com
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx

All we’re going to do is add 1 line right before nameservers, so it looks like this:

search unixserveradmin.com
options rotate
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx

What this will do is rotate which resolvers you have setup in /etc/resolv.conf defined as nameserver. While you’re there, you should also update /etc/host.conf to say:

order hosts,bind
multi on
nospoof on

Order in this case will set the lookup priority to search /etc/hosts first, then do a DNS lookup using /etc/resolv.conf if that fails. Multi controls whether or not /etc/hosts is allowed to have Multiple IP addresses. Nospoof prevents PTR spoofing by double checking that the IP address used by the querying client is actually associated with the hostname the client is trying to present itself as. If all the above are done, then you may not see a difference, even at all.  But your hosting provider will, and we thank you!

August 16, 2011 Posted by | Tips & Tricks, Unix/Linux | , | Leave a comment

Logs files in linux (cPanel)

In a cPanel server, you may find logs are often stored differently comapring a control panel less server. Even Plesk saves logs in different paths. Here is a list of services and their log path that may help you finding the logs.


hostname should be resemble your hostname.




/var/log/xferlog  (symlinked to /usr/local/apache/domlogs/ftpxferlog)

System (cron, syslog, named, etc)

Security (ssh, ModSecurity, etc)

August 15, 2011 Posted by | Apache, cPanel, Cron, DNS, Exim, Mod_Security, MySQL, Pure-FTPd, SSH, Tips & Tricks, Unix/Linux | , , , , , , , , , , | Leave a comment

“unauthenticated user” problem in mysql logs

While running following command.

# mysqladmin -i3 pr

We are getting result.

056 | unauthenticated user | localhost |    | Connect |      | Reading from net |

To avoid such problem add following lines in /etc/my.cnf file to avoid access for unauthenticated user.

# vi  /etc/my.cnf

# /etc/init.d/mysql restart

Now restart the mysql service and check mysql process logs again.

August 14, 2011 Posted by | MySQL | | Leave a comment

MySQL history file

MySQL history commands are stored in MySQL history file :-

Check your Mysql history file

# vi /root/.mysql_history

If you don’t find the file under /root, find out the file using

# locate .mysql_history

August 13, 2011 Posted by | MySQL | | Leave a comment

How to change Exim IP Address

If you are not able to send mails with server IP OR If you are in the danger of getting your main server IP block by SpamCop because you had a few anoying spamers abusing your server then you could simply change your exim mailserver IP to avoid the effect of your main IP beeing blacklisted, then you can try changing the IP that exim uses by default. You can set exim to use any of the free Ip on the server. So here is process to change interface ip address for exim. Inside both incoming and outgoing exim mail server you will need to add an interface : so just edit

# vi /etc/exim_outgoing.conf and vi /etc/exim.conf

2) Check for the following parameters.
driver = smtp

Change to like this:
driver = smtp

Add following lie :- “add interface = ip.you.want.to.use” and Replace “x.x.x.x” with your IP address.

# /etc/init.d/exim restart

NOTE: Just a reminder – If there is an exim update when you upgrade your cpanel server you will need to re-enter the interface again Once this is done, Also restart exim for the changes to take effect.

August 12, 2011 Posted by | Exim | | Leave a comment