Contolling startup scripts using chkconfig. chkconfig examples Linux.

An update to this post if your distro is using upstart or any other service for start up i.e openrc, systemd this might not or wont work!

Alot of distros are migrating from system V init at time of edit (so this may be out dated, Debian/Ubuntu (upstart), RHEL6/CentOS6 (upstart). chkconfig will/might still be available but isnt guaranteed to work! If your using upstart alot may still work as it still sits on top off system V init, it all depends on distro though and what parts are handled by upstart and which are still handled by system V init).

chkconfig examples Linux a guide to controlling which services start during boot.

Listing current chkconfig settings.

chkconfig --list

Add a service to the chkconfig startup list if not already there. In this example vsftpd.

chkconfig --add vsftpd

To set the service to start during boot (Will add to runlevels 2,3,4 and 5).

chkconfig vsftpd on

To add to a specific runlevel 3 in this example.

chkconfig --level 3 vsftpd on

To disable a service on boot will turn to off for all runlevels.

chkconfig vsftpd off

To disable at a specific runlevel.

chkconfig --level 3 vsftpd off

To chkconfig remove a service from the chkconfig setup.

chkconfig  --del vsftpd

Linux runlevels.

Linux has 6 different runlevels all which have there seperate configuration.

Runlevel – System State
0 – Halt the system
1 – Single-user mode
2 – Multi-user mode (without NFS)
3 – Multi-user mode (cli)
4 – unused/reserved
5 – Multi-user mode, graphical login
6 – Reboot the system

runlevels may vary from distro to distro but this is usually only levels 2 and 4 which are usually reserved.

To change the current runlevel from command line

init runlevel


reboot the system.

init 6

Start a gui when booted into terminal (switching from runlevel 3 to runlevel 5).

init 5

Shutdown the system.

init 0

Linux, Virtual & Dedicated Servers , , , , , , , , , ,

Reinstalling Grub legacy Linux boot loader

Reinstalling Grub legacy Linux boot loader. If you have accidentally removed Grub or you set up a dual boot and Windows did here is how to restore it.

1. Boot into a Linux live cd.

2. Make the mount point directory.

mkdir /mnt/recovery

3. Mount the partition(s) of the disk your working on.

sudo mount /dev/sdxx /mnt/recovery

(sdxx being the partition to be mounted i.e sda1).

sudo mount /dev/sda1 /mnt/recovery

Install Grub (yum needs to be substituted to the package manager of your distro, yum, aptitude etc. In this example we will use yum.

chroot /mnt/recovery yum install grub -y

4. Reinstall Grub boot loader to the MBR.

sudo grub-install --root-directory=/mnt/recovery /dev/sda


Linux, Virtual & Dedicated Servers , ,

Forgotten Plesk mailbox password Linux

Forgotten Plesk mailbox password? Plesk mailbox password recovery guide.

If you have forgotten a Plesk mailbox password on Linux servers you can recover the login details by running the following via SSH.

All to be entered on one line!

mysql psa -uadmin -p`cat /etc/psa/.psa.shadow` -e 'select concat(mail.mail_name,"@", as address,accounts.password from mail,domains,accounts where and order by address;'

Email, Linux, Plesk Linux, Virtual & Dedicated Servers ,

Lost Plesk ftp login details. Plesk recover ftp password guide Linux.

Plesk recover ftp password guide.

1. Login to the server using SSH using your SSH client and login to MySQL.

mysql -uadmin -p`cat /etc/psa/.psa.shadow`

2. Run the following MySQL query.

SELECT REPLACE(sys_users.home,’/home/httpd/vhosts/’,”) AS domain, sys_users.login,accounts.password FROM sys_users
LEFT JOIN accounts on
ORDER BY sys_users.home ASC;

Unfortunately the width of this page dumps this to multiple lines, however its a one liner!

This will now display a list of all the FTP accounts including the login details.


Linux, Plesk Linux, Virtual & Dedicated Servers

Howto disable drweb notification Plesk Linux.

Howto disable drweb notification Plesk Linux.

Modify the following file /etc/drweb/drweb_handler.conf .

Look for and change the following.

# Enable or disable sending notifications to persons (yes/no)
SenderNotify = no
AdminNotify = no
RcptsNotify = no

Now edit /etc/drweb/drweb32.ini

And set the following.

CronSummary = no

Now restart DrWeb.

service drwebd restart


Linux, Plesk Linux, Virtual & Dedicated Servers , , , ,

MySQL query failed Table psa.lockout doesn’t exist

MySQL query failed Table psa.lockout doesn’t exist.

This issue can arise after an upgrade of Plesk 9.5 on attempt at logging in to the Plesk panel, you get the following error.

MySQL query failed: Table ‘psa.lockout’ doesn’t exist

0: common_func.php3:206
db_query(string ‘delete from lockout where (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(last_wrong)) > (30 * 60)’)
1: cmd_loginup.php:82
createSession(string ‘admin’, string ‘********’)
2: login_up.php3:22

Part of the Plesk login process checks if the account is locked or not and is missing after the upgrade (I suspect security updates).

The fix is simple just recreate the table.

mysql -uadmin -p`cat /etc/psa/.psa.shadow`

mysql> CREATE TABLE `lockout` (
-> `login` varchar(20) character set utf8 NOT NULL default ”,
-> `last_wrong` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-> `attempts` int(11) NOT NULL default ‘1’,
-> PRIMARY KEY (`login`)
-> ;

Parallels dev could have added this to the login function after the upgrade, but fair play to them or at least benefit of the doubt it could leave the panel open to exploitation If they had. For example brute force and/or MySQL injection. Those kind of exploits could grant a Plesk login and is practically root at web server level but it could also be used to escalate higher privilages.

Linux, MySQL, Plesk Linux, Virtual & Dedicated Servers

MySQL monitoring script Linux. Monitor MySQL daemon.

MySQL monitoring script Linux.

Linux Bash script to monitor MySQL service. Requirements are the nmap port scanner but the script will install it on first run as long as you use yum package manager.

Create the file using nano.

nano -w

Add the following.


#Author Phil Bond Box Admin


#Check if nmap is installed otherwise install (ONLY TESTED WITH YUM)
if [ -e “/usr/bin/nmap” ] ; then
echo “nmap is installed” > /dev/null 2>&1
$packageman install nmap -y > /dev/null 2>&1


while [ $restartchk -gt 0 ]; do

portstatus=`nmap $server -p $port | tail -3 | grep $servicename | awk {‘print $2’}`

case $portstatus in
open)echo “Port is responding. $servicename is accepting connections” > /dev/null 2>&1 && let restartchk=0;;
closed)echo “Port is closed. $servicename is not responding” && echo “Attempting to restart Mysqld” && /sbin/service $service restart;;
filtered)echo “Port is filtered. $servicename is not responding” && /sbin/service $service restart;;

if [ $attempts -eq 3 ]; then
echo “Mysqld is failing to start after 3 attempts exiting”
exit 1

let attempts=attempts+1


exit 0

Press ctrl+x to exit you will be prompted to save.

Now add the script as a cronjob. Unless you changed your editor variable this will open in Vi.

crontab -e

Now press the insert key on your keyboard to enter edit mode and add the following.

*       0-23    *       *       *       /root/

Press the esc key on your keyboard to exit edit mode.

Press shift+:

Type wq and hit enter to save.

Now when ever MySQL is not responding you receive an email informing you and the script will attempt to restart the service but will quit if the service fails after 3 attempts. The destination email will be the email set for your cronjobs.

Bash Scripting, Linux, MySQL , ,

The webpage at https://yourip:11444/relay might be temporarily down or it may have moved permanently to a new web address.

The webpage at https://yourip:11444/relay might be temporarily down or it may have moved permanently to a new web address.

You mainly see this error in Plesk 9.x if you are trying to access it using Google Chrome. The reason you see this is becuse of the way it handles Plesks SSO or “single sign on”.

SSO is mainly used to provide intergration with Parrallels Plesk Billing by providing you with a single login between products without having relogin everytime you switch between products.

There are two fixes for this. Either you upgrade to the latest Plesk build, Plesk 10.x or you disable SSO. The easyest is to disable it.

To disable login to your Plesk server via SSH and run the command:

/usr/local/psa/bin/sso --disable

To renable SSO run:

/usr/local/psa/bin/sso --enable


Linux, Plesk Linux, Virtual & Dedicated Servers , ,

Installing Mcrypt extension PHP Linux from source

Installing mcrypt Linux howto guide. Guide for Red Hat 5 CentOS 5 using PHP53 packages.

Install the PHP development packages.

yum install php53-devel

Install the Mcrypt development packages.

yum install libmcrypt-devel

Download PHP.


Extract the PHP archive and cd into the Mcrypt directory.

tar -zxf php-5.3.3.tar.gz && cd php-5.3.3/ext/mcrypt/

Install The PHP Mcrypt module.





make test

make install

Add the Mcrypt extension to the PHP configuration.

echo “” > /etc/php.d/mcrypt.ini

Restart Apache.

service httpd restart

Other versions of PHP can be found in the downloads section.



Linux, PHP, Virtual & Dedicated Servers , , ,

Plesk ftp not working Linux.

Plesk ftp not working Linux?

If you are unable to connect to ftp on your server, xinetd failing to start the service due to being unable to resolve the hostname is one possible cause.

Attempt a connection to the ftp daemon.

[root@linserv01 ~]# ftp localhost
Connected to localhost.localdomain.
421 Service not available, remote server has closed connection

Check the system messages log for errors

tail - f /var/log/messages

Here we see the error that ProFTPD is unable to resolve the servers hostname.

Feb 21 07:22:03 linserv01 xinetd[1614]: START: ftp pid=7454 from=
Feb 21 07:22:03 linserv01 proftpd[7454]: warning: unable to determine IP address of ‘linserv01’
Feb 21 07:22:03 linserv01 proftpd[7454]: error: no valid servers configured
Feb 21 07:22:03 linserv01 proftpd[7454]: Fatal: error processing configuration file ‘/etc/proftpd.conf’
Feb 21 07:22:03 linserv01 xinetd[1614]: EXIT: ftp status=1 pid=7454 duration=0(sec)

Add the hostname to /etc/hosts

nano -w /etc/hosts


hostname ipaddress



Now press ctrl +x to exit and save.

[root@linserv01 ~]# ftp localhost
Connected to localhost.localdomain.
220 ProFTPD 1.3.1 Server (ProFTPD) []
500 AUTH not understood
500 AUTH not understood
KERBEROS_V4 rejected as an authentication type
Name (localhost:root):

Now your Plesk ftp is working.

FTP, Linux, Plesk Linux, Virtual & Dedicated Servers , , , , , , ,