Monday, December 2, 2013

How to change sub-netmask

/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=static IPADDR=192.168.0.254 NETMASK=255.255.255.0 ONBOOT=yes

Monday, August 12, 2013

Remote login to Linux machine without password

How it works

The ssh-keygen tool stores the private key in $HOME/.ssh/id_rsa and the public key in $HOME/.ssh/id_rsa.pub in the user’s home directory. The user should then copy the contents of id_rsa.pub to the $HOME/.ssh/authorized_keys file in his or her home directory on the remote machine. It also asks for a passphrase. The passphrase may be empty to indicate no passphrase (host keys must have an empty passphrase), or it may be a string of arbitrary length. Instead of RSA, DSA can also be used. The steps to create authorization keys by using the ssh-keygen tool are as follows:

Some of the important options of ssh-keygen command are as follows:

ssh-keygen command options
description
-b bits
Specifies the number of bits in the key to create. The minimum bit length is 768 bits and the default length is 2048 bits.
-C comment
Provides new comment.
-p
Requests changing the passphrase of a private key file instead of creating a new private key.
-t
Specifies the type of key to create.
-q
quiets ssh-keygen. It is used by the /etc/rc file while creating a new key.
-N
Provides a new Passphrase.
-F
For ssh-keygen2, dumps the key's fingerprint in Bubble Babble format


Enter following command to generate public/private rsa key pair.

ssh-keygen -t rsa
Generating public/private rsa key pair.

Enter the path to store the keys.
By default keys will be stored at “/home/user/.ssh/” folder.

Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory '/home/user/.ssh'.

Enter the passphrase to encrypt the private key.
                                                                                                                                   
The passphrase you will enter will be used for encrypting your private key. A good passphrase should be alphanumeric having 10-30 character length. Press enter if you don’t want to enter passphrase.

Enter passphrase (empty for no passphrase):

Re-enter the passphrase to confirm

Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
7e:64:77:08:42:ab:bb:6b:c6:82:cb:fc:9b:3e:95:f6 user@localhost

The private key was saved in .ssh/id_rsa file which is a read-only file.
The public key is saved in .ssh/id_rsa.pub file.

Copy the Public Key onto remote systems' ~/.ssh/authorized_keys file:

Now, you have to copy the public key onto a remote systems' ~/.ssh/authorized_keys file. Create /home/user1/.ssh folder at remote machine if it does not exist.

scp /home/user/.ssh/id_rsa.pub  215.72.60.264:/home/user1/.ssh/authorized_keys

ssh user1@215.72.60.264
Last login: Mon Aug 12 15:31:52 2013 from user.
[user1@localhost ~]$


Done.

Monday, August 5, 2013

MySql Database back-up from Linux OS to Linux OS

Backup of whole DB
Source Machine:
mysqldump --quick database_name | gzip > db_name.gz

Destination Machine :
mysqladmin create db_name (if not exists)
gunzip < db_name.gz | mysql db_name

Backup of 1 table
Source Machine:
mysqldump --quick database_name table_name  | gzip > db_name.gz

Destination Machine :
mysqladmin create db_name (if not exists)
gunzip < db_name.gz | mysql db_name

Thursday, August 1, 2013

SVN Configuration using svnserve on Fedora 17

SVN Server Configuration

1. Create repository

Login as a root user

svnadmin create repo
This will create repo dir
ll repo/

total 24
drwxr-xr-x. 2 root root 4096 Aug  1 16:32 conf
drwxr-sr-x. 6 root root 4096 Aug  1 15:07 db
-r--r--r--. 1 root root    2 Aug  1 14:34 format
drwxr-xr-x. 2 root root 4096 Aug  1 14:34 hooks
drwxr-xr-x. 2 root root 4096 Aug  1 14:34 locks
-rw-r--r--. 1 root root  229 Aug  1 14:34 README.txt

cd repo

2. Edit repo/conf/passwd file

vi repo/conf/passwd
Add below lines:

[users]
user1 = user1

left to the assignment is a username & right is a password

3. Edit repo/conf/authz file

vi repo/conf/authz
Add below lines:

[/]
User1 = rw

It will give user1 read & write permissions.

4. Edit repo/conf/svnserve.conf file

vi repo/conf/svnserve.conf
Add following lines:

anon-access = none
auth-access = write
password-db = passwd
authz-db = authz

5. Check the status of svnserve daemon
/etc/init.d/svnserve status
If it is inactive use:
/etc/init.d/svnserve start
Again check the status, if it is running it will show

/etc/init.d/svnserve status
svnserve.service - LSB: start and stop the svnserve daemon
          Loaded: loaded (/etc/rc.d/init.d/svnserve)
          Active: active (running) since Thu, 01 Aug 2013 12:14:27 +0530; 2h 19min ago
         Process: 1655 ExecStart=/etc/rc.d/init.d/svnserve start (code=exited, status=0/SUCCESS)
        Main PID: 1658 (svnserve)
          CGroup: name=systemd:/system/svnserve.service
                  รข 1658 /usr/bin/svnserve --daemon --pid-file=/var/run/svnserve.pid

Now, your SVN server is ready. J

Client Configuration

1. SVN checkout
Login as a normal user
svn co svn://203.124.15.24/root/repo/ {REPOSITORY_FOLDER_NAME / PATH}


This will create the repo dir & sub_dirs.

You are ready to use SVN. J

Moose Overview

Moose is an extension of the Perl 5 object system. It brings modern object-oriented language features to Perl 5, making object- oriented programming more consistent and less tedious.

Classes
Moose allows a programmer to create classes.
  •  A class has zero or more attributes.
  •  A class has zero or more methods.
  • A class has zero or more superclasses.
  • A class inherits from its superclass(es). Moose supports multiple inheritance.
  • A class has zero or more method modifiers. These modifiers can apply to its own methods, methods that are inherited from its ancestors or methods that are provided by roles.
  • A class does zero or more roles (also known as traits in other programming languages).
  • A class has a constructor and a destructor.
  •  
Attributes
  •  An attribute is a property of the class that defines it.
  • An attribute always has a name, and it may have a number of other defining characteristics.
  • An attribute's characteristics may include a read/write flag, a type, accessor methods, names, delegations, a default value and lazy initialization.

Roles
Roles in Moose are based on traits. They perform a similar task as mixins, but are composed horizontally rather than inherited. They are also somewhat like interfaces, but unlike interfaces they can provide a default implementation. Roles can be applied to individual instances as well as Classes.
  • A role has zero or more attributes.
  • A role has zero or more methods.
  • A role has zero or more method modifiers.
  • A role has zero or more required methods.

Method Modifiers
A method modifier is a hook that is called when a named method is called. For example, you could say "before calling login(), call this modifier first". Modifiers come in different flavors like "before", "after", "around", and "augment", and you can apply more than one modifier to a single method.
Method modifiers are often used as an alternative to overriding a method in a parent class. They are also used in roles as a way of modifying methods in the consuming class.
Under the hood, a method modifier is just a plain old Perl subroutine that gets called before or after (or around, etc.) some named method.