Quicktip: BASH (Shell) script – show duration/time taken to execute script

Simple BASH script example for showing the elapsed time for a script to execute:


start_time=`date +%s`

end_time=`date +%s`

echo "Script execution took $time_elapsed seconds."


Passwordless SSH (Public Key Authentication) for CentOS 5, CentOS 6, Ubuntu, Debian, Linux in General


You have two servers, ServerA and ServerB – you would like ServerA to be able to SSH in to ServerB without a password. Use this simple tutorial to achieve this:


Step 1: Generate public key on ServerA

SSH in to ServerA and enter the following command. Keep pressing enter (accept the defaults) – do not enter a passphrase.
ssh-keygen -t dsa

This should have generated a file, /root/.ssh/id_dsa.pub

Copy the contents of the file above:
cat /root/.ssh/id_dsa.pub

Step2: Copy ServerA’s public key to ServerB

SSH in to ServerB and paste the contents from /root/.ssh/id_dsa.pub from ServerA (above) in to /root/.ssh/authorized_keys on ServerB:

If the /root/.ssh directory does not exist, create it first:
mkdir /root/.ssh
vim /root/.ssh/authorized_keys

Set the required permissions on the authorized_keys file:
chmod 0600 /root/.ssh/authorized_keys

Now try and SSH to ServerA from ServerB – you should not be prompted for a password. The same process can be used for other users, apart from root. If you want ServerB to have passwordless SSH access to ServerA, perform the same steps as above, but swap ServerA for ServerB the next time you do it.


Fix for Windows 7 & wmic: Invalid XSL format (or) file name

In Windows 7, there is a bug with wmic and the /format switch. When using the /format switch, you will get the error “Invalid XSL format (or) file name.”

1. Example:

C:\Tmp>wmic /output:C:\tmp\procinfo.html CPU get Description,
DeviceID, Manufacturer, MaxClockSpeed, Name, Status, SystemName /format:hform.xsl
Invalid XSL format (or) file name.

2. Cause:

Windows looks for the XSL stylesheets but cannot find them, which produces the error above.

3. Resolution:

Copy *.xsl from x:\Windows\system32\wbem\en-US\ to x:\Windows\system32 – this can be done quicky from command prompt:

copy /y %WINDIR%\system32\wbem\en-US\*.xsl %WINDIR%\system32\

If you run your original wmic command (example in Section 1), there will be no errors and wmic will export data in the format required.


Install mod_rpaf on CentOS 5, CentOS 6

This is a quick guide on how to install mod_rpaf on CentOS 5 and CentOS 6. (This guide can also be used to install mod_rpaf on RHEL and Fedora Core)

1. Retrieve and Extract mod_rpaf packages:

# cd /usr/local/src
# wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
# tar xzvf mod_rpaf-0.6.tar.gz
# cd mod_rpaf-0.6

2. Build and install mod_rpaf

# apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

[ httpd-devel is the package required to run apxs ]

3. Add mod_rpaf to Apache configuration

# vim /etc/httpd/conf/httpd.conf

- Find the “LoadModule” list (near the top)
- Add the following lines at the bottom of the “LoadModule” list:

LoadModule rpaf_module modules/mod_rpaf-2.0.so

# mod_rpaf Configuration

RPAFenable On
RPAFsethostname On
RPAFheader X-Forwarded-For

Important: Where “″ is, add your proxy server IP address(es). This will tell mod_rpaf which hosts to get X-Forwarded-For headers from.

4. Finish

Restart Apache for the changes to take effect

/etc/init.d/httpd restart

5. Troubleshooting

The following dependencies may need to be installed before installing mod_rpaf:

httpd-devel, gcc

They can be installed using the following commands:

yum install httpd-devel gcc


How to stop and reset/clear MySQL replication

This is a quick article that describes how to reset/delete/disable/clear MySQL replication in master-master or master-slave replication.

For each server that you wish to reset/clear MySQL replication on, do the following:

1. Enter MySQL prompt and run the following commands:


2. Remove replication user(s). In this example, we remove replication user “replicator”:

 mysql> use mysql;
 mysql> delete from user where User="replicator";
 mysql> flush privileges;

3. Exit MySQL prompt and open up /etc/my.cnf – remove any reference to replication (eg: replicate-* master-* etc)

# vim /etc/my.cnf

4. Lastly, restart your MySQL instance:

# /etc/init.d/mysqld restart




Previous Page Next Page

Random Posts Recent Comments

  • Tony Says:

    Thanks it works! Just close the cmd windows and open a new one...

  • greenhart Says:

    I found another way around it. For the /format switch I used: /format:"%WINDIR%\system32\wbem\en-...

  • Jari Aalto Says:

    To determine OS, you can also use command lsb_release(1). See the options how to extract only part o...

  • shadovice Says:

    thanks! it worked like a charm, although there is still minor typo remained: rpm -Uvh http://downlo...

  • Joh Says:

    Great, thank you. Also works with the new version and Centos 6.3 without test repo, just install ...

  • sierprinsky Says:

    Muchas gracias por tu aporte :)...

  • kilby Says:

    The listed solution worked fine for me under Win7 64bit Though I had to run the copy as Asministr...

  • Viper5112 Says:

    The files are already in the C:\Windows\SysWOW64\wbem\en-US and they need to be in the system32 fold...

  • slowmOoh Says:


  • Jørgen Says:

    @Jordan, I had the same problem also on Windows 7 64 bits. It worked for my user account and Admini...

Tag Cloud

backup mail backup mail server backup mailserver backup mx cd burner control multiple computers with one keyboard and mouse control panel DAG disk benchmark disk performance test DNS DNS check enable dag repo free cd burner free DNS check hdd benchmark http proxy install keyboard over network kloxo kloxo 64-bit kvm lxadmin lxadmin-master lxlabs mouse over network mtr ping plotter proxy proxy hide IP qmail repo RPM rpmforge share keyboard and mouse over network share keyboard over network share mouse and keyboard share mouse over network software kvm squid squid hide IP squid proxy trace traceroute tracert