Monthly Archives: August 2012

File Synchronization Between Two Ubuntu Servers using Unison

Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.

This tutorial shows how to set up file synchronization between two Ubuntu 12.04 servers with Unison that are on the same network but you can use the same approach on the servers that are not placed on the same network.

Before installing the unison,generate the ssh key pair on PrimarySrv and copy the public key to the SecondarySrv:

scp ~/.ssh/ arbab@

Read more of this post


How to recover deleted Apache Log

Scenario: The server is running Apache and by mistake one of the log files gets deleted. How, we can recover it?

Currently, Apache server is working perfectly:

Login/Switch to as root user:

Move to the httpd in log directory:

cd /var/log/httpd

Delete the log file:

rm -f access_log

So the log file has been deleted,now find the process number for main apache procees that owned by root:

ps aux | grep httpd

In this case, the pid for the main apache process is 1784.

Now lets list the file descriptors:

ls -lsa /proc/1784/fd

Stop the apache service:

service httpd stop

Now copy the access log file that is marked as deleted (In this case it is 7) into the log directory:

cp /proc/1784/fd/7 /var/log/httpd/access_log

Start the apache service again:

service httpd start

Access the webpage again from your server:

Verify the log file:

tail -f /var/log/httpd/access_log

It’s working 🙂

Hope this will help you!

Please Remember me in your prayers!

How to Install and Configure Dropbox on Ubuntu Server 12.04 LTS

Dropbox is a file hosting service that offers cloud storage, file synchronization, and client software. In brief, Dropbox allows users to create a special folder on each of their computers, which Dropbox then synchronises so that it appears to be the same folder (with the same contents) regardless of the computer it is viewed on. In this tutorial, I will try to show you the steps to make dropbox features and services available on ubuntu server.

Download dropbox from it’s Official website:

Dropbox for 32-bit Server:

wget -O dropbox.tar.gz ""

Dropbox for 64-bit Server:

wget -O dropbox.tar.gz ""

Extract the Dropbox archieve:

tar -zxvf dropbox.tar.gz

Run the dropbox client deamon with this command:


Ubuntu server will keep showing this message after few second, if it is not link to any dropbox account yet.

Copy the highligeted text and paste into the browser on separate computer and Dropbox will ask for authentication:

It will ask the password again in order to link Ubuntu server to this dropbox account.

Once it succeeds you’ll see the message

Client successfully linked, Welcome!

on your server and it will stop printing the authorization link.

Press CTRL + C to terminate the dropbox deamon process.

The next step is to create a script to start and stop the dropbox daemon:

sudo touch /etc/init.d/dropbox
sudo nano /etc/init.d/dropbox

This script is lifted from here:

# dropbox service
# Replace with linux users you want to run Dropbox clients for
start() {
 echo "Starting dropbox..."
 for dbuser in $DROPBOX_USERS; do
 HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
 if [ -x $HOMEDIR/$DAEMON ]; then
 HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON
stop() {
 echo "Stopping dropbox..."
 for dbuser in $DROPBOX_USERS; do
 HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
 if [ -x $HOMEDIR/$DAEMON ]; then
 start-stop-daemon -o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON
status() {
 for dbuser in $DROPBOX_USERS; do
 dbpid=`pgrep -u $dbuser dropbox`
 if [ -z $dbpid ] ; then
 echo "dropboxd for USER $dbuser: not running."
 echo "dropboxd for USER $dbuser: running (pid $dbpid)"
case "$1" in
 echo "Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}"
 exit 1
exit 0

Note: Replace the user “arbab” with the user whom you want to run Dropbox client.

Make this script executable:

sudo chmod +x /etc/init.d/dropbox

Add it to default system startup run levels:

sudo update-rc.d dropbox defaults

Start the dropbox and check it’s status:

sudo service dropbox start
sudo service dropbox status

Download the script to check the Dropbox  real-time status:

wget -O ~/.dropbox/ ""

Change the permissions:

chmod 755 ~/.dropbox/

Check the status by executing this command:

.dropbox/ status

By default, dropbox daemon create a  folder named “Dropbox” in the home directory of the user that we mentioned in the script (in my case that user was “arbab“):

cd Dropbox

Copy some data in this folder (Dropbox) and again check the status with python script:

.dropbox/ status

Yes, it is working 🙂

Hope this will help you!

Please Remember me in your prayers!

How to set Windows to boot as the default in the boot loader

Many people like to boot Windows as standard/default OS in dual-boot setup instead of Ubuntu, so in this tutorial, I will show you that how you can do this:

In a terminal, type this command to display all your grub entries:

fgrep menuentry /boot/grub/grub.cfg

Copy the underline entry – for example Windows 7 in this screenshot.

Edit the /etc/default/grub file:

sudo nano /etc/default/grub

Change the entry:



GRUB_DEFAULT="Windows 7 (loader) (on /dev/sda2)"

Note:paste the entry you want (including the quotes)

Then type:

sudo update-grub

That’s it, now Windows 7 will boot as default OS:

Hope this will help you!

Please Remember me in your prayers!

Enjoy 🙂

Install Windows 7 alongside a pre-existing Ubuntu

I purchased a Dell Laptop last week for work related tasks and it was shipped with pre-installed Ubuntu 11.10. After receiving the laptop, I want to install the Windows 7 on another partition (To use it as my Primary OS). I start searching the internet and every guide I found suggest to install Windows and, after that, Ubuntu but I want to keep all these setting that it shipped with. In this tutorial, I will try to show you the procedure that I followed to achieve this goal:

First, back up your data and boot the system from Ubuntu desktop CD and select “Try Ubuntu” :

Press “Ctrl+Alt+T” for terminal and write this command:

sudo gparted

Select your desired parition to free up the disk space for winodws 7, Right click on it and select “Resize/Move“:

Mention the Size that you want to free:

Right-click on the free space and select “New“:

Select file system as “NTFS” and click on Add:

After that click on the tick mark sign and hit “Apply“:

Then reboot the system and install Windows into the NTFS partitions:

Then boot the Ubuntu CD again and re-install grub, first add the boot repair repository:

sudo add-apt-repository ppa:yannubuntu/boot-repair

Update the local package index with the latest changes made in repositories:

sudo apt-get update

Install and launch the boot repair by using this command:

sudo apt-get install -y boot-repair && boot-repair

Click on the recommended option:

It will take about 15 to 20 mins and if everything goes well, it will show you the success message:

After reboot, your system will present you with the grub menu:

Hope this will help you!

Please Remember me in your prayers!

Enjoy 🙂

How to Disable SELinux on CentOS

I have a lot of programs that crash by Selinux Policy and don’t have that much time to make rules for each program so that it perform properly, above all I want to disable the SELinux without rebooting the server.

Note: But one thing keep in mind that by disabling SELinux you will be removing a security mechanism on your system.

First verify the status of SELinux:

cat /etc/selinux/config

Disable SELinux without rebooting:

Run this command with root privileges:

sudo setenforce 0

Verify the status of SELinux after executing the above command:

Disable SELinux permanently:

Edit this file with root privileges:

sudo nano /etc/selinux/config

Replace the line from:




Reboot the System!!!

Hope this will help you!

Please Remember me in your prayers!

Enjoy 🙂

Installing RPMforge Repository on CentOS 6

 If you’re looking for a package on CentOS and can’t find in the main repos then there’s a good chance that you can find it, in the RPMforge repository.

RPMforge is a collaboration of packagers and is not part of Red Hat or CentOS but is designed to work with those distributions.

Download the rpmforge-release package:

I am using x86_64 server, so I will download the x86_64 package:


Install DAG’s GPG key:

sudo rpm --import

Verify the package you have downloaded:

sudo rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm

Install the package:

sudo rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm

Try to install some package, that failed before installing rpmforge repository:

Hope this will help you!

Please Remember me in your prayers!

Enjoy 🙂

%d bloggers like this: