Search This Blog

Tuesday, July 31, 2012

Synchronize time of two or more PCs with NTP

1) At first check whether NTP is installed or not. Install if its not installed.

#apt-get install ntp

2) Start or restart ntp using

#/etc/init.d/ntp restart/start

3) On server machine do following things.
Open /etc/ntp.conf and add following things

server iburst
fudge stratum 10

restrict mask nomodify notrap

Here first two lines are external ntp servers which will be used to synchronize to time. 3rd and 4th line is used if machine has infrequent internet connection. Last line is used so that any machine from network can use this machine as a server to synchronize time. So result would be that you would see same time on all machines in that network and current machine(server).

Restart ntp using

#/etc/init.d/ntp restart

4) On client machine
Open /etc/ntp.conf and add ip address of the server machine. We assume that ip address of server machine was

so in ntp.conf enter

server iburst

Restart ntp
# /etc/init.d/ntp restart

Check using following command

#ntpq -c lpeer
And you should see ip address or hostname of server machine.

Thats it. Now onwards all the client machines in the network and server machine( will always show same time and will remain synchronized.

Clear cache memory used by linux kernel and processor cache

You just give one command to do this:
# free && sync && echo 3 > /proc/sys/vm/drop_caches && free
This would clear only disk cache.

In order to clear processor cache memory, there is no perfect method. I can only suggest one method.
At first write a c program to allocate large amount of memory using malloc. That memory should be almost equal to the amount free memory available which you can see using top command. Now fill that allocated memory by writing it with random data or may be even 0. That would clear your processor cached.

Login without password using ssh

At first install openssh client and server using following commands.
#sudo apt-get install openssh-client
#sudo apt-get install openssh-server

Lets assume that there are two machines A and B. You want to login from B to A without using password..

1) So from machine B give following commands.
# ssh-keygen

After that press enter for the file (i.e. let it use default file), then press enter when asked for entering password.

Example from my machine:

root@hpc-13:~/.ssh# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): (PRESS ENTER)
Enter same passphrase again:  (PRESS ENTER)
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
ac:d6:6a:b2:98:f6:8a:0f:df:76:af:a6:82:7c:4f:c1 root@hpc-13
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|    .  .         |
|     E  S        |
|      .o         |
|o.   .o .        |
|.=o=+.+.         |
|.oB=*Ooo.        |

2) Now use ssh-copy-id command to do rest of the things.

 # ssh-copy-id -i ~/.ssh/ username@hostname_of_remote_machine(machine A in our case)

Example from my machine:

root@hpc-13:~/.ssh# ssh-copy-id -i ~/.ssh/ user@hpc-12
The authenticity of host 'hpc-12 (' can't be established.
RSA key fingerprint is 3f:9b:b2:b2:8e:36:09:4b:92:4c:df:bd:d6:14:b7:9f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'hpc-12,' (RSA) to the list of known hosts.
user@hpc-12's password:
Now try logging into the machine, with "ssh 'user@hpc-12'", and check in:


to make sure we haven't added extra keys that you weren't expecting.

3) Now try ssh to machine A

#ssh user@hostname_of_remote_machine(machine A in our case)

And you should be able to login without password.

Tuesday, July 10, 2012

How to find cached copy of any webpage url

Google stores all the pages in cache for few days and they can be found out by using this url

Now just append the url who's cache copy you want to see. For example if you want to see cache copy of then your url will be

You can offcourse try with those url which are not active currently for example facebook photos which are deleted later on.

Tuesday, June 26, 2012

error: Failed dependencies: is needed

I actually got this error while trying to install rpm of driver of a network card on RHEL 6.2 64 bit. That error looked something like this:

# rpm -i  myri_dbl-2.  1.0.51076-3636.x86_64.rpm
error: Failed dependencies: is needed by myri_dbl- is needed by myri_dbl- is needed by myri_dbl- is needed by myri_dbl- is needed by myri_dbl- is needed by myri_dbl- is needed by myri_dbl- is needed by myri_dbl- is needed by myri_dbl-

This error occurs because of some 32 dependencies which are required. The solution is to install 32 version of glibc.

# yum install libstdc++-4.4.6-4.el6.i686

This will mostly solve your problem.

Friday, June 22, 2012

To check which application is using a particular port

You give following command to check which application is using a particular port.

# netstat -ltnp | grep portno


# lsof -i :portno

Check whether hyperthreading is enabled or not ?

We can check whether hyper threading is enabled or not without checking in bios by giving following command
# cat /proc/cpuinfo
If the number of siblings and number of cores you see is same then hyper threading is not enabled. If they are not same then its enabled.
If its enabled, then "siblings" give logical cores present and "cpu core" gives actual physical cores.

Total number of cpu's is equal to maximum number of cpu id available in the result + 1.

If you want to find out how many cores are present in a particular cpu and what there numbers are then you can give following command.

#  cat /sys/devices/system/cpu/cpu2/topology/core_siblings_list