Monday, 24 December 2012

Configuration of LINUX Gateway Machine


Check two network devices attach properly or not.

Follow the steps to configure the Linux machine(CentOS, Fedora) gateway.


i )  Check the Device eth0, eth1 are available on the machine by running command.

   [root@Xhost ]# ifconfig 

It will display eth0 and eth1 two network card details (ip, mac and etc).



ii)  Configure eth0 as the Public Network ip address. (/etc/sysconfig/networking-scripts/ifconfig-eth0)


# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
IPADDR=xx.xx.xx.xx  # IP ADDRESS of Public Network
NETMASK=255.255.255.0 # Provided by the ISP
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
GATEWAY=xx.xx.xx.1 # Provided by the ISP





iii)  Configure  eth1 as the Private Network ip address (/etc/sysconfig/networking-scripts/ifconfig-eth1)


# cat ifcfg-eth1

BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth1
NETMASK=255.255.0.0 # Specify based on your requirement
IPADDR=192.168.0.1 # Gateway of the LAN
NETWORK=192.168.0.0 # Optional
USERCTL=no
IPV6INIT=no
PEERDNS=yes
ONBOOT=yes




iv) Check each eth0 and eth1 separte like.


 [root@Xhost ]# service network restart
:
:
 [root@Xhost ]# ifconfig eth1 down
 [root@Xhost ]# ping  xx.xx.xx.xx  # Ping any public ip
:
:
if it works fine. other wise check the configuration of eth1

simmillarly for eth1


 [root@Xhost ]# service network restart
:
:
 [root@Xhost ]# ifconfig eth0 down
 [root@Xhost ]# ping  192.168.0.xx  # Ping any private ip
:
:


if both working means continue this fifth step




V)  Host Configuration (Optional)

# cat /etc/hosts
127.0.0.1 nat localhost.localdomain localhost




vi)  Gateway Configuration

# cat /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=nat
GATEWAY=xx.xx.xx.1 # Internet Gateway, provided by the ISP




Vii)  DNS Configuration

# cat /etc/resolv.conf

nameserver xx.xx.xx.xx # Primary DNS Server provided by ISP
nameserver xx.xx.xx.xx # Secondary DNS Server provided by ISP



viii) NAT with iptables:

[root@Xhost ]# iptables -F  # Flush iptables 
[root@Xhost ]# iptables -t nat -F # Flush nat table
[root@Xhost ]# iptables -t mangle -F # Flush mangle table

setup forwarding rule in the iptables

[root@Xhost ]# iptables -t nat -A PREROUTING -o eth0 -j MASQUERADE
[root@Xhost ]# iptables -A FORWARDING -i eth1 -j ACCEPT


iX) Enabling the Kernel ip forwarding

Check kernel ip forwading enable or not

[root@Xhost ]# sysctl -a | grep  net.ipv4.ip_forward
net.ipv4.ip_forward = 0

if 0 is there set it to 1 by

[root@Xhost ]# echo 1 > /proc/sys/net/ipv4/ip_forward

and edit to make the change permanent

[root@Xhost ]#vi /etc/sysctl.conf

net.ipv4.ip_forward=1 # modify this 0 to 1



X) Apply configurations

[root@Xhost ]# service iptables save
[root@Xhost ]# service iptables restart
[root@Xhost ]#  chkconfig --list iptables  # on 3,5 runlevel






Finally Gateway is setuped ..

Now we need to test this gateway from any client system(private network).
login into client system.

ping 192.168.0.1;
ping  xx.xx.xx.xx # Any public IP

Read More

Friday, 21 December 2012

Guide to Install VServer in Fedora and Install MYPLC in VServer

This Guide will explain how to install Vserver in Fedora and then How to Install MyPLC in Vserver

Step 1 : Install Fedora 12 without GUI (do not Install Any X11 packages Because in GUI mode vserver not Installing Properly)

Option 1 :
Download Fedora Net Install ISO and Install while Installing Choose Minimal as Installation Option  Because It is Not Going to Install Any GUI Component.
Download Link for Fedora 12 Net Install ISO 

Option 2:
Download Fedora 12 DVD and while Installing Choose Minimal as Installation Option Because It is Not Going to Install Any GUI Component, And Coustamize packages and remove all GUI packages and Multimedia Packages and all Applications which contain GUI.
Download Link for Fedora 12 DVD

Goto Step 2 If you Installed Fedora With Out GUI

Step 2:
Stop SELINUX
Check this http://linux-problem-solver.blogspot.in/2012/09/disabling-selinux-in-fedora.html 

Step 3:
Stop IPTable ( Firewall )
Check this http://linux-problem-solver.blogspot.in/2012/09/disable-or-turnoff-iptables-firewall-in.html 

Step 4:
If you did not restart system after step2, step3 then restart your System now.

Step 5:
Add Vserver repo
[root@xyz~]# cd /etc/yum.repos.d/
[root@xyz yum.repos.d]# vim vserver.repo

#Add Only One based on 32 bit or 64 bit

#for 32 bit Fedora
#Add Following Lines to vserever.repo 
[vserver]
name=Linux-VServer related packages for Fedora $releasever - $basearch
baseurl=http://build.onelab.eu/vserver/f12/i686
gpgcheck=0
#gpgkey=http://build.onelab.eu/conf/keys/RPM-ONELAB-GPG-KEY




#for 64 bit Fedora
#Add Following Lines to vserever.repo 
[vserver]
name=Linux-VServer related packages for Fedora $releasever - $basearch
baseurl=http://build.onelab.eu/vserver/f12/x86_64/
gpgcheck=0
#gpgkey=http://build.onelab.eu/conf/keys/RPM-ONELAB-GPG-KEY

Step 6:
Add this Line : exclude=kernel* util-vserver* yum in fedora.repo the location is before 
[fedora-debuginfo] line Like below
[root@xyz~]# cd /etc/yum.repos.d/
[root@xyz yum.repos.d]# vim fedora.repo
[fedora]
...
...
...
exclude=kernel* util-vserver* yum

[fedora-debuginfo]
...
...

Step 7:
Add this Line : exclude=kernel* util-vserver* yum in fedora-update.repo the location is before 
[fedora-debuginfo] line Like below
[root@xyz~]# cd /etc/yum.repos.d/
[root@xyz yum.repos.d]# vim fedora.repo
[fedora]
...
...
...
exclude=kernel* util-vserver* yum

[fedora-debuginfo]
...
...

Step 8:
yum install kernel 
It will Install Kernel like kernel-2.6.32.11-162.vs2.3.0.36.29.4.fc12.i686 [this kernel will support Vserver with out any Problem)

step 9:
Open Grub file and set timeout to 10 seconds or any value And Default to 0 because it 
will select latest installed kernal as default kernel
[root@xyz~]# vi /etc/grub.conf
.....
.....
default=0
timeout=10
....
....

Restart So System will boot into Newly Installed Kernel
Check which kernel is selected by typing uname -a in terminal
[root@xyz~]# uname -a
Linux center.cmmacs.ernet.in 2.6.32.11-162.vs2.3.0.36.29.4.fc12.i686 #1 SMP Thu Dec 2 19:34:22 CET 2010 i686 i686 i386 GNU/Linux

Step 10:
Install kernel-firmware version which is related to our installed kernel
For 32 bit
[root@xyz~]# rpm -U --force http://build.onelab.eu/vserver/f12/i686/kernel-firmware-2.6.32.11-162.vs2.3.0.36.29.4.fc12.i686.rpm
for 64 bit
[root@xyz~]# rpm -U --force http://build.onelab.eu/vserver/f12/x86_64/kernel-firmware-2.6.32.11-162.vs2.3.0.36.29.4.fc12.x86_64.rpm

Step 11:
Install yum which support chroot
[root@xyz~]# rpm -qa | grep yum
yum-utils-1.1.26-1.fc12.noarch
yum-3.2.28-5.fc12.noarch
yum-metadata-parser-1.1.2-14.fc12.i686
#Remove yum
[root@xyz~]# rpm -e --nodeps yum-3.2.28-5.fc12.noarch
Success, Now

For 32 bit
[root@xyz~]# rpm -ivh http://build.onelab.eu/vserver/f12/i686/yum-3.2.25-2chroot.noarch.rpm
For 64 bit
[root@xyz~]# rpm -ivh http://build.onelab.eu/vserver/f12/x86_64/yum-3.2.25-2chroot.noarch.rpm

Step 11:
Install Necessary Packages
[root@xyz~]# yum install util-vserver util-vserver-build
[root@xyz~]# yum install subversion
[root@xyz~]# yum install httpd
[root@xyz~]# yum install createrepo
[root@xyz~]# yum install qemu
[root@xyz~]# yum install bridge-utils
[root@xyz~]# yum install emacs
[root@xyz~]# yum install ntp

Step 12:
Download Necessary Files to Setup Vserver Properly
[root@xyz~]# cd
[root@xyz~]# svn co http://svn.planet-lab.org/svn/build/trunk svn-build
If SVN showning unknown host error set proxy for SVN like below
[root@xyz~]# vi /etc/subversion/servers
Edit the file Like below
[Global]
http-proxy-host=my.proxy.com
http-proxy-port=3128

Step 13:
Copy Distribution files to /etc/vservers/.distributions
[root@xyz~]#  cd 
[root@xyz~]# cd svn-build
[root@xyz  svn-build]#  cd mirroring
[root@xyz  mirroring]# cp -r * /etc/vservers/.distributions

Step 14:
Initializing Vserver Distributions 
[root@xyz  mirroring]# sh mirror.sh -a
[root@xyz  mirroring]# sh mirror.sh init

Step 15: Verifying the setup
Going to install Fedora 12 in Vserver
Go to /etc/vservers/.distributions
[root@xyz~]# cd /etc/vservers/.distributions
[root@xyz .distributions]# ls
centos5  f10  f12  f13  f7  f8  fc1  fc2  fc3  fc4  fc5  fc6  rh9  suse91
[root@xyz .distributions]# cd f12
[root@xyz f12]# cd yum.repos.d/
[root@xyz yum.repos.d]# ls
building.repo  building.repo.in
IF building.repo not there then
[root@xyz yum.repos.d]# cp building.repo.in building.repo

Step 16: Adding MYPLC repository to Vserver repository
Going to install MyPLC in Vserver of Fedora 12
[root@xyz~]# cd /etc/vservers/.distributions/f12/yum.repos.d
#Note to create vserver Successfully we need to change gpgcheck=1 to gpgcheck=0 in .repo file
[root@xyz yum.repos.d]# vim building.repo
[fedora]
name=Fedora 12 - $basearch
baseurl=http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/releases/12/Everything/$basearch/os/
enabled=1
metadata_expire=7d
gpgcheck=0
gpgkey=http://mirror.onelab.eu/keys/RPM-GPG-KEY-fedora-12-primary

[updates]
name=Fedora 12 - $basearch - Updates
baseurl=http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/updates/12/$basearch/
enabled=1
metadata_expire=7d
gpgcheck=0
gpgkey=http://mirror.onelab.eu/keys/RPM-GPG-KEY-fedora-12-primary

Add MYPLC Repository location in building.repo file

[root@xyz yum.repos.d]# vim building.repo
[fedora]
...
...
...
#For 32 bit
[myplc]
name= MyPLC
baseurl=http://build.onelab.eu/5.0/rc32/onelab--5.0-rc32-f12-32/RPMS/
enabled=1
gpgcheck=0

#For 64 bit
[myplc]
name= MyPLC
baseurl=http://build.onelab.eu/5.0/rc32/onelab--5.0-rc32-f12-64/RPMS/  
enabled=1
gpgcheck=0
         
Step 17:
Some times while creating Vserver we get error /proc/uptime can not be accessed
to Avoid this before creating Vserver Start vprocunhide script
[root@xyz~]# cd /etc/init.d/
[root@xyz init.d]# ./vprocunhide start

Step 18:
Create Vserver
[root@xyz svn-build]# cd ~/svn-build

For 32 bit System

[root@xyz svn-build]# ./vtest-init-vserver.sh -f f12 -d onelab -p linux32 vtest32 http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/releases/12/Everything/i386/os/Packages/ -- --interface eth0:138.96.255.221 --hostname vnode01.inria.fr &> vtest32.log&


For 64 bit System

[root@xyz svn-build]# ./vtest-init-vserver.sh -f f12 -d onelab -p linux64 vtest64 http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/releases/12/Everything/x86_64/os/Packages/ -- --interface eth0:138.96.255.221 --hostname vnode01.inria.fr &> vtest64.log&

Check RPM packages location connecting or not other wise change location, currently 
http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/fedora/linux/releases/12/Everything/i386/os/Packages/ link is working properly

Step 19:
Start Vserver and Install MYPLC
[root@xyz~]# vserver vtest32 start
[root@xyz~]# vserver vtest32 enter
[vtest32 ] /# yum install plc
Install myplc
[vtest32 ] /# yum install myplc
make myplc start at system startup 
[vtest32 ] /# chkconfig plc on
Start MYPLC if you done all steps correctly then you will see text like below
[vtest32 ] /# service plc start
PLC: Generating network files:                             [  OK  ]
PLC: Generating SSL certificates for: PLC: WWW: PLC: API: P[  OK  ]:
PLC: Generating GPG keys:                                  [  OK  ]
PLC: Generating SSH keys:                                  [  OK  ]
PLC: Starting web server: PLC: Setting PHP timezone to GMT:[  OK  ]
PLC: Starting PostgreSQL server:                           [  OK  ]
PLC: Configuring the API:                                  [  OK  ]
PLC: Bootstrapping the database: PLC:  - 101-up-leases.sql (dbdumped): PLC:  - 102-up-isvalid.sql (dbdumped): PLC:  - 103-up-extensions.sql (dbdumped): PLC:  - 104-up-noderole.sql (dbdumped): PLC:  - 105-up-timespent.sq[  OK  ]ped):
PLC: Starting DNS server: PLC: Configuring resolv.conf:    [  OK  ]
PLC: Creating BootCD variants:                             [  OK  ]
PLC: Rebuilding Boot CD:                                   [  OK  ]
                                                           [  OK  ]
PLC: Signing and indexing node packages:                   [  OK  ]


MyPLC Installation Completed



























Read More

Tuesday, 18 December 2012

Uninstall or Remove Any Application or Package in Fedora


Hi I already installed yum-3.2.28-5.fc12.noarch package now i want to remove that package and
Install lower version yum-3.2.25-2chroot.noarch


[root@server1]#rpm -Uvh yum-3.2.25-2chroot.noarch.rpm 
Preparing...                ########################################### [100%]
package yum-3.2.28-5.fc12.noarch (which is newer than yum-3.2.25-2chroot.noarch) is already installed


1 st time Fail
[root@server1]#yum remove yum

Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package yum.noarch 0:3.2.28-5.fc12 set to be erased
--> Processing Dependency: yum >= 3.2.24 for package: yum-utils-1.1.26-1.fc12.noarch
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.26-1.fc12 set to be erased
--> Finished Dependency Resolution
Error: Trying to remove "yum", which is protected
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

2 nd time Success
[root@server1]#rpm -qa | grep yum

yum-utils-1.1.26-1.fc12.noarch
yum-3.2.28-5.fc12.noarch
yum-metadata-parser-1.1.2-14.fc12.i686
Note the package need to remove

[root@server1]#rpm -e yum-3.2.28-5.fc12.noarch
error: Failed dependencies:
yum >= 3.2.24 is needed by (installed) yum-utils-1.1.26-1.fc12.noarch

For me no need to remove dependence packages So

[root@server1]#rpm -e --nodeps yum-3.2.28-5.fc12.noarch
Success, Now
[root@server1]#rpm -ivh yum-3.2.25-2chroot.noarch.rpm Preparing...                ########################################### [100%]
   1:yum                    ########################################### [100%]



Read More

Thursday, 13 December 2012

Find Size of table and Size of Index in MySQL Command Prompt

To find Size of table in MySQL command prompt use below command

mysql > SELECT table_name AS "Table", round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "database_name" AND table_name = "table_name";


To find Size of  Index of a table in MySQL command prompt use below command

mysql > SELECT table_name AS "Table", round(((index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "database_name" AND table_name = "table_name";
Read More

Thursday, 6 December 2012

Add new Line while Appending two files in Linux

If two files containing following content
file1:
1
2
file2:
3
4

After append : cat file2>>file1 
output in file1:
1
23
4

to Add new Line while Appending two files
Command : sed -i -e '$a\' file2 | cat file2 >> file1

From Above
sed -i -e '$a\' file2
This adds \n at the end of the file only if it doesn't already end in a newline. So if you run it twice it will not add another newline.

Read More

Wednesday, 28 November 2012

Solution: After Exception Catch in Python What will happen?

Exception Handling :
After Exception Catch Python will execute remaining code, See below Example 



#!/usr/bin/python3
# reading sitemap xml file
#

a=5

def diverror(a):
    a = a/0
    print(a)

try:
diverror(a)
except:
print("Division Error")
a = a+10
print(a)

Output:

Division Error
15





Read More

Break out of the function in Python

In Python if Any function return any thing or return none means the function is completed ie Break out of the function 

Example:

def test(a,b):
      return "HI Closed"
      a = b+10
      print(a)

test(10,11)
output:
HI Closed

Read More

Catch all exception in Python3

to catch all exceptions in python3 simple do like bellow

try:
    code
except:
    print("Unknown Exception found")

Read More

Sunday, 25 November 2012

Python current timestamp

To get current time with date in python

from datetime import datetime
curtime = str(datetime.now())


output : '2012-11-25 14:58:30.465213'



Read More

Friday, 23 November 2012

Solution: Extract tar.bz2 files in Linux

To Extract tar.bz2 files in linux use below command

root@system1~# tar -xjvf filename.tar.bz2
Read More

Wednesday, 21 November 2012

Delete duplicate rows in mysql table

It is Possible to DELETE duplicate rows in MYSQL table based on Particular Field (Coloumn)

the SQL Query is

ALTER IGNORE TABLE table_name ADD UNIQUE INDEX(coloumn_name); 
Read More

Thursday, 15 November 2012

IPtables: Saving firewall rules to /etc/sysconfig/iptables: /etc/init.d/iptables: line 268: restorecon: command not found

Solution to : IPtables: Saving firewall rules to /etc/sysconfig/iptables: /etc/init.d/iptables: line 268: restorecon: command not found

root@server1:~# ls -l /sbin/ | grep restore
lrwxrwxrwx 1 root root     14 May 23 17:52 iptables-restore -> iptables-multi

Means policycoreutils not Installed
So Install policycoreutils to get restorecon save Iptables


root@server1:~# yum install policycoreutils
root@server1:~# ls -l /sbin/ | grep restore

lrwxrwxrwx 1 root root     14 May 23 17:52 iptables-restore -> iptables-multi
lrwxrwxrwx 1 root root      8 Nov 15 17:00 restorecon -> setfiles



Read More

Tuesday, 13 November 2012

Read Large Files Line by Line in Python - Best Way

The readlines() function loads the entire file into memory as it runs. A better approach for large files is to use the fileinput module, as follows:

import fileinput
for line in fileinput.input(['myfile']):
   print(line)
Read More

Monday, 12 November 2012

Solution: Dovecot error : Unknown database driver mysql


Dovecot error : Unknown database driver mysql because Dovecot requires the dovecot-mysql package to run mysql authentication. So Install  dovecot-mysql
yum install dovecot-mysql
Read More

Friday, 9 November 2012

Load Kernel Module in Linux Example Load IP table module

Below Instructions shows How to Load Kernel module in Linux

check whether module is Loaded or Not

if you don't know Exact Module Name then Check All Loaded Modules

root@system1:~# lsmod

Module                  Size  Used by
nf_conntrack_ipv4      18850  1 
nf_defrag_ipv4         12601  1 nf_conntrack_ipv4
xt_state               12514  1 
nf_conntrack_ftp       13039  0 
nf_conntrack           65203  3 nf_conntrack_ipv4,xt_state,nf_conntrack_ftp
xt_tcpudp              12531  1 
x_tables               20679  4 xt_state,xt_tcpudp,iptable_filter,ip_tables
sctp                  165508  2 
libcrc32c              12510  1 sctp
nls_iso8859_1          12617  0 
nls_cp437              12751  0 
vfat                   17166  0 
fat                    54411  1 vfat
snd_seq_dummy          12686  0 
usb_storage            42478  0 
uas                    17476  0 
i915                  395739  1 
drm_kms_helper         30737  1 i915
drm                   183453  3 i915,drm_kms_helper
i2c_algo_bit           12980  1 i915
video                  18434  1 i915
dm_crypt               22236  0 
snd_intel8x0           33017  2 
snd_ac97_codec        104623  1 snd_intel8x0
ac97_bus               12602  1 snd_ac97_codec
snd_pcm                72878  2 snd_intel8x0,snd_ac97_codec
snd_seq_midi           13132  0 
snd_rawmidi            24215  1 snd_seq_midi
snd_seq_midi_event     14076  1 snd_seq_midi
snd_seq                50403  3 snd_seq_dummy,snd_seq_midi,snd_seq_midi_event
snd_timer              23911  2 snd_pcm,snd_seq
snd_seq_device         13817  4 snd_seq_dummy,snd_seq_midi,snd_rawmidi,snd_seq
ppdev                  12840  0 
lp                     13321  0 
parport_pc             31867  1 
shpchp                 32187  0 
snd                    52787  11 snd_intel8x0,snd_ac97_codec,snd_pcm,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
psmouse                72465  0 
parport                34960  3 ppdev,lp,parport_pc
soundcore              12534  1 snd
mac_hid                13037  0 
serio_raw              13027  0 
snd_page_alloc         13709  2 snd_intel8x0,snd_pcm
dm_mirror              21585  0 
dm_region_hash         15035  1 dm_mirror
dm_log                 17871  2 dm_mirror,dm_region_hash
aufs                  162169  0 
usbhid                 41119  0 
hid                    79842  1 usbhid
tg3                   133921  0 
floppy                 59430  0 

if you know what module you are Looking ex:ip_tables then Check whether that module loaded or not by below command

root@system1:~# lsmod | grep ip_tables
root@system1:~#

Not Loaded then Load Module

root@system1:~# modprobe ip_tables

Now check

root@bt:~# lsmod | grep ip_tables
ip_tables              17634  1 iptable_filter
x_tables               20679  4 xt_state,xt_tcpudp,iptable_filter,ip_tables

Success





Read More

Tuesday, 6 November 2012

Solution to g++: Command not found in Fedora Problem

g++ command not found means gcc-c++ package not 

installed so install gcc-c++ package

command

root@system1:# yum install gcc-c++
Read More

Install deb packages

To install .deb packages use following command

root@system1:~# dpkg -i package.deb
Read More

SSH login without password in Linux

Hi to login into Linux System through SSH with out password Follow Below Steps
two systems (Below IP addresses are for Example)
system1 ip : 2.2.2.2
system2 ip : 3.3.3.3

Note: For Below Command don't type any thing Simply press Enter


root@system1:~# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): (Press Enter)
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/id_rsa.pub.
The key fingerprint is:
d8:b7:3b:d8:12:19:47:de:43:e9:8b:54:ba:b4:af:c4 root@system1
The key's randomart image is:
+--[ RSA 2048]----+
|           ..    |
|          ...o   |
|          .+* .  |
|       o oo* .   |
|      . S ....    |
|         + +.+.   |
|         oE.o    |
|        ..oo     |
|          o.     |
+-----------------+

root@system1:~# ssh-copy-id  3.3.3.3
root@3.3.3.3's password: 

Now try logging into the machine, with "ssh '3.3.3.3'", and check in:

  .ssh/authorized_keys

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

root@system1:~# ssh 3.3.3.3
(If Login success OK,if Login Fail and Got Below Error )

Agent admitted failure to sign using the key.
root@3.3.3.3's password: 

root@system1:~# ssh-add
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)

Now
root@system1:~# ssh 3.3.3.3
Last login: Wed Nov  7 10:27:23 2012 from 2.2.2.2
root@system2:~#

Success









Read More

Monday, 5 November 2012

convert to binary in PHP

In PHP decbin function is used to convert anything to binary

Example:
<?php
$a = "3";
$b = 4;
echo decbin($a)."<br>";
echo decbin($b);
?>

Output:
11
100
Read More

Monday, 22 October 2012

Setup domain nagix etc usefull urls

http://www.unixsurgeon.com/kb/setup-nginx-as-reverse-proxy-with-apache.html

 http://kbeezie.com/view/apache-with-nginx/

http://www.ctkn.net/2011/10/install-mod_rpaf-on-centos-5-centos-6/

http://www.unixsurgeon.com/kb/setup-nginx-as-reverse-proxy-with-apache.html

http://www.beer.org.uk/bsacdns/

http://www.webtop.com.au/blog/how-to-setup-dns-using-webmin-2009052848

http://forums.devshed.com/dns-36/setting-up-dns-using-webmin-406190.html


Read More

Change linux root password

Change linux root password

user# su
password :
root# passwd
Enter New Password:
Re type password:
 
Read More

After Copying Mysql table data files manually mysql service not running

If you got the problem After Copying Mysql table data files manually MySQL service not running then check owner of copied files, to work MySQL the owner must be MySQL

mysql data folder in linux /var/lib/mysql

root/backup# cp databasefolder /var/lib/mysql
root# chown mysql.mysql  databasefolder
root# cd  databasefolder
root/databasefolder# chown mysql.mysql *

Read More

Sunday, 21 October 2012

Solution to : XML::SAX::Base.3pm.gz conflicts between Problem

Some time if you got Problem like below while yum update

file /usr/share/man/man3/XML::SAX::Base.3pm.gz conflicts between
attempted installs of perl-XML-SAX-Base-1.04-3.el6.noarch and
perl-XML-SAX-0.96-7.el6.noarch
file /usr/share/man/man3/XML::SAX::Exception.3pm.gz conflicts between
attempted installs of perl-XML-SAX-Base-1.04-3.el6.noarch and
perl-XML-SAX-0.96-7.el6.noarch 



to Avoid these type of problem update yum by excluding those packages
Example

yum update -y --exclude=perl-XML-SAX-Base --skip-broken
 

Read More

Solution to : Error: rpmdb open failed

Error: rpmdb open failed will occur while trying to use you update to solve this problem use following commands

yum clean all
rm -f /var/lib/rpm/__db*
rpm --rebuilddb
yum update
Read More

Thursday, 18 October 2012

Shell script execute command and store in variable

This Post shows how to execute command in .sh files ie shell script files

Example:

cmd=$(ps -ef | grep tcpdump | awk '{print $3}')
echo $cmd

in .sh files need to use like this variable=$(command)
Read More

Wednesday, 17 October 2012

Set PHP execution time in Code Itself

It is possible to Set PHP execution time in code No need to changing php.ini file

Add Below line to your PHP code
ini_set('max_execution_time', 1919);
where 1919 means PHP script will execute 1919 seconds

Example:
<?php
ini_set('max_execution_time', 1919);
.................
................
..............

?>
Read More

Tuesday, 9 October 2012

Get SVN files and Folders with WGET

By Using WGET it is possible to get all files and folders of a url 

Command
wget -r -i http://svn.planet-lab.org/svn/build/trunk/
Read More

Wednesday, 3 October 2012

Add Route Between Two Systems

Type ifconfig in terminal (command Prompt) to know IP
Type route -n in terminal (command Prompt) to know GateWay

First System IP : 203.41.55.23
Second System IP : 23.41.67.89

First System Gateway : 203.41.55.1
Second System Gateway : 23.41.67.1

You can add route in any One System is Enough for example

Add route in First System
route add -host 23.41.67.89 gw 203.41.55.1

Or
Add route in Second System
route add -host 203.41.55.23 gw 23.41.67.1





Read More

Saturday, 29 September 2012

Show error message if Java run-time not installed in client mechine through JavaScript

By using Follow code, it is possible to show error message if java run-time not installed in client mechine

<!DOCTYPE html>
<html>
<body>

<script>
if (navigator.javaEnabled()) {
    //Java is enabled
}
else
{
document.write("Error:Java is Disabled or Java Not Installed<br>Download and Insatall java from <a href=\"http://www.java.com/en/download/index.jsp\">http://www.java.com/en/download/index.jsp</a>");
}
</script>

</body>
</html>


Read More

Wednesday, 26 September 2012

Solution SSH Connection Refused Problem in Linux - Backtrack

If your system unable to SSH from another System means

1. SSH server Not Running. So start SSH Server
    To start SSH server goto Applications->Backtrack->Services->SSHD->sshd start


If It is Running, and unable to SSH go to step 2

2. root@bt:~# sshd-generate
Generating public/private rsa1 key pair.
Your identification has been saved in /etc/ssh/ssh_host_key.
Your public key has been saved in /etc/ssh/ssh_host_key.pub.
The key fingerprint is:
d3:c3:ee:61:70:81:fa:06:44:18:a5:1c:49:25:70:d4 root@bt
The key's randomart image is:
+--[RSA1 2048]----+
|         .oo*B=. |
|        .  ..=  E|
|        ....o    |
|     o ..o.      |
|      = .S.o.     |
|       o o...    |.
|          ..  .   |
|                 |
|                 |
+-----------------+

..................
..................
..................

Now Check Again , I think it will work.




Read More

Monday, 24 September 2012

Solution to Endianness Problems in Linux Networking

There are two types of Endians
1.Big-Endian
2.Little-Endian

In real world Networks generally use Big-Endian

Ethernet is Big-endian

IP's byte order also is Big-endian


A common solution to the endianness problem associated with networking can be handled by below functions

htons(): Convert 16-bit unsigned value from processor order (machine order) to network order. (htons-host to network short)
htonl(): Convert 32-bit unsigned value from processor order (machine order) to network order. (htonl-host to network long)
ntohs(): Convert 16-bit unsigned value from network order to processor order (machine order). (ntohs-network to host short)
ntohl(): Convert 32-bit unsigned value from network order to processor order (machine order). (ntohl-network to host long)
Read More
Here We Write The Problems we face at different situations and Solutions to those problems.