Author Archive

Ntpdate Not syncing time correctly – Xen Host

I came across a situation where ntpdate would not sync the time correctly in a Xen Virtual machine. The time was 10 minutes ahead of what it was supposed to be. Apparently , you need to force it to not use the dom0’s clock.

vi /etc/sysctl.conf
xen.independent_wallclock = 1
sysctl -p

Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.

You may come across this error in newer version of apache which is because the newer configurations use an event based Multi Processing Module by default. If the PHP is not compiled with threadsafe, you will need to switch to the prefork MPM, which does not use threads.

Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.
 AH00013: Pre-configuration failed
httpd.service: control process exited, code=exited status=1

Look for the following in the Load Modules sections of your apache configuration file :

LoadModule mpm_event_module modules/

And replace it with the following module :

LoadModule mpm_prefork_module modules/

NFS Version 4 Export

Install the required Packages:

yum install nfs-utils nfs4-acl-tools portmap

Export the folder to share:

echo "/folder/to/share  IpAddressToShareWith(rw,no_root_squash,async,fsid=0)" >> /etc/exports

Map NFS User for ownership:

vi /etc/idmapd.conf



Nobody-User=apache Nobody-Group=apache

Iptables Rule :

iptables -A INPUT -p tcp -m tcp --dport 2049 -j ACCEPT

Start / Restart Services :

service nfs start
service rpcidmapd restart
service portmap start

SSL Root Certificate update in Linux for curl

When you use curl in Linux machines to make remote calls to SSL sites, you need to have latest root certificates installed. Recently I came across a situation where the newer root certificate were not available and so the remote call suddenly started failing.

First, you will have to find the location of your certificate files :

curl-config --ca

Now, you download the latest bundle to the path found from above , which usually is /etc/pki/tls folder

curl -o /etc/pki/tls/certs/ca-bundle.crt


You can check whether the curl call works by sample command given below :

curl --verbose --cacert ./certs/verisign-intermediate-ca.crt --head

Processes in Linux

D : This means the process is in uninterruptible sleep mode. Usually Input and output are in this mode.

R : Currently Running Process or is in the running queue.

S :  Is in sleep state waiting for an event to complete.

T :  Means the process is stopped by a signal.
X :  X means a dead process.

Z :  Zombie or dysfunctional process which has terminated.
< : High priority process

N : Low priority process

L : This represents a process which has pages locked into the memory for real time processing or input output.
s : Means that this process is leading the session.

l : Multithreaded process.

+ : Running in the foreground.

Sending Signal to Processes :

Send Continue Signal to a Process :

kill -19 pid

GIT Common Commands and How Tos

To Discard Changes which have not yet been indexed to server , run this command :

git stash save --keep-index

git stash drop

To Clone Git Repo on the local filesystem

  git clone file:////path/to/repo/project.git/ .

PHP function to remove whitespaces from a string

Usage :

$spaceRemovedString = removeWhiteSpaces($stringWithSpace);


Function :

function removeWhiteSpaces($spaceStr)
	$newStr = preg_replace('/\s+/', '', $spaceStr);
	return $newStr;

Repairing Accidental Damage to file system permissions and ownership

There are cases when you might accidently change the system permissions and you want to revert it back to default permissions. You can revert ownership and permissions on installed packages by using rpm or you can copy permissions from a clone machine if you have one.

Copying permissions and resetting from a clone machine :

Export the permissions from a good machine :

find / /usr /home -xdev | xargs getfacl -P > /tmp/goodPermissions

Now copy that file and  Import on the damaged machine

setfacl --restore=/tmp/goodPermissions


Reset Permissions using RPM

rpm --setperms –a

Or To reset for a single package :

rpm --setperms <packagename>


To reset the ownership :

rpm --setugids –a 

or to reset ownership on single package :

rpm --setugids <packagename>

Handling Multiple SSH Keys and Ports for Multiple Machines

You might have to deal with a lot of machines with different keys and ports. Here is a simple way to make that easier.

Edit / Create ssh config file.

vi ~yourUserName/.ssh/config

Put the information about your hosts into the config file:



IdentityFile ~/.ssh/server1_rsa
User userName
Port xxxx
ServerAliveInterval 30
ServerAliveCountMax 120

PROMPT_COMMAND='echo -ne "33]0;${USER}@${HOSTNAME}: ${PWD}07"'

Now whenever you try to connect to that host, it will use the key, username and port defined in this config file.

Setting up Git on Centos

In this tutorial, I am showing how to setup GIT on Centos with SSH .

Packages to be installed :

yum install git-core gitosis

Create user and group which will own the repositories :

useradd -d /path/to/repositories gituser

Generate or copy a ssh key for use with git :

su gituser

ssh-keygen -t rsa

Now initialize the gitosis :

gitosis-init < /path/to/ur/sshPrivateKey

Be safe by changing permissions on the post update :

sudo chmod 755 /path/to/repositories/gitosis-admin.git/hooks/post-update

Clone the gitosis-admin repo into your local machine :

git clone gituser@yourServer:gitosis-admin.git

Now you should have gitosis.conf and keydir/ in your gitosis-admin directory.

Creating New Repositories :

Now is the time to create a new Repository (eg. testrepo)

Open up the gitosis.conf and see the default configuration :

vi gitosis.conf

[gitosis] [group gitosis-admin] writable = gitosis-admin members = gitUser

Now to Create a new repo, we just authorize writing to the repo and push the changes . Add the following to the gitosis.conf file :

[group mydevel]
members = user1@hostname user2@hostname 
writable = repoName

Save the changes commit and push it to the server :

git commit -a -m "New users to the repo repoName"
git push

Now create the repository and initialize it :

mkdir repoName

cd repoName git init git remote add origin gitUser@serverName:repoName.git

Now create some files , save changes, add to repo. If you want to add existing files then you can use * to represent all files:

git add fileName


git add *

Now commit & push to the origin

git commit –a –m “Initializing new Repo”

git push origin master:refs/heads/master

Adding Users to the Repo :

In order to add users, first get their key file and put them in the key dir folder. Please note that all keys must have .pub extension and the username is anything before .pub

Example :

cd gitosis-admin
cp ~/ keydir/
cp ~/ keydir/
git add keydir/ keydir/

Now add the members to the list and commit changes :

git commit -a -m "Created New users newUser1 and newUser2"
git push

Now they can clone and start working on the project :

git clone newUser1@gitServer:testRepo.git

Configure Public access to the repo :

git-daemon --base-path=/path/to/repo/to/grantaccess/ --export-all

Note : In windows, you can use tortoise Git, you can save the session in putty and use the session name in stead of hostname in the commit and clone operations.

In unix , you can use non standard port by creating ssh config file :