Thursday, October 18, 2007

Unix Login Without Password (Setting login keys)

Client : Machine from where you want to log-on
Server : Destination machine where you want to log-on from

1. On the client machine

Create the key(id_rsa) file with appropriate permissions

ssinghal@client$cd ~ssinghal/.ssh
ssinghal@client$touch id_rsa
ssinghal@client$chmod 600 id_rsa

Generate is_rsa file

ssinghal@client$ssh-keygen -t rsa

Press enter when you are prompted for a passphrase or for entering a file name ( accept the default)

Id is stored in ~ssinghal/.ssh/id_rsa

Your identification has been saved in /home/ssinghal/.ssh/id_rsa.
Your public key has been saved in /home/ssinghal/.ssh/id_rsa.pub.
The key fingerprint is:
2c:ce:0d:e4:53:83:d3:41:95:82:5f:cc:e5:8f:a1:6b ssinghal@MACHINENAME


2. copy the id_rsa.pub to server

Using any scp or ftp mechanism

3. On the server machine

SSH to the server machine and create keys file with appropriate permissions

ssinghal@server$cd ~ssinghal/.ssh/
ssinghal@server$touch authorized_keys2
ssinghal@server$chmod 600 authorized_keys2
ssinghal@server$cat id_rsa.pub >> authorized_keys2
( id_rsa.pub is client's public key)


Note: The username on client and server needs to be same ( If I am not mistaken)

Logout and from the client machine try to ssh again, you should be able to log-on with just your username

ssinghal@client$ ssh ssinghal@server

Friday, October 12, 2007

Formatting XML in vim

":silent 1,$!xmllint --format --recover - 2>/dev/null"

http://www.vim.org/tips/tip.php?tip_id=349

Updated vim tips URL : 

http://vim.wikia.com/wiki/Format_your_xml_document_using_xmllint

Eclipse Tools I Use

This list keeps on growing and changing when I discover new plug-ins. Here is my current configuration of eclipse. Along with eclipse update sites.

Base Eclipse Version : 3.3.0 Europa, http://download.eclipse.org/releases/europa

Web Tools Platform : http://download.eclipse.org/webtools/updates
It Includes many cool features, best of which is JSP Debugging options and unbelievable support for editing WSDL files for web-services

JSEclipse: Javascript plug-in from Adobe(now), http://download.macromedia.com/pub/labs/jseclipse/autoinstall/

Subclipse, SVN plugin for eclipse : http://subclipse.tigris.org/update_1.2.x

Perl Editor : http://e-p-i-c.sourceforge.net/updates
I prefer VI to work with perl files, but fancy it for its auto-complete features.

ShellEd for browsing through shell scripts - No better way than VI to actually code and test them :)

Monday, October 1, 2007

Oracle - Common Datafile Operations

Adding a table space

ALTER TABLESPACE users
ADD DATAFILE ‘/home/ssinghal/oradata/users01.dbf' SIZE 10M
AUTOEXTEND ON
NEXT 512K
MAXSIZE 250M

Adding a table space with minimal options

ALTER TABLESPACE name ADD DATAFILE ‘filespec’ SIZE 200M;


Altering a tablespace by adding a new datafile

ALTER TABLESPACE VPN2_LRG_TBLS
ADD DATAFILE '/home/ssinghal/oradata/users02.dbf' SIZE 100M
AUTOEXTEND ON
NEXT 1024K
MAXSIZE 250M


Resizing a data-file

alter database datafile '/home/ssinghal/oradata/users02.dbf' resize 500M


Dropping a datafile

alter database datafile 20 offline drop

Note : ID of datafile can be obtained from dba_data_file

Monday, August 27, 2007

Oracle Procedure Source code from Dictionary

SELECT to_char(text)
FROM user_source
WHERE type IN ('PACKAGE' ,'PROCEDURE','TRIGGER')

Sunday, August 19, 2007

Wednesday, August 15, 2007

Getopts with bash


#!/bin/sh

usage()
{
echo "Usage: $0 -a all -b ball -c -d -e";
exit 1;
}

if [ $# -lt 1 ] ; then
usage;
fi

# ":" decides which options require an argument
# In the example below options "a" and "b" will require a value to be passed along
while getopts a:b:cde opt
do
case "$opt" in
a) echo "hello $OPTARG";;
b) echo "hello $OPTARG";;
c) echo "c is selected";;
d) echo "d is selected";;
e) echo "e is selected";;
\?) usage;;
esac
done

Wednesday, July 11, 2007

UNIX - find cheet sheet

Find all files named "foo" in directory "/" recursively
find / -name foo

Find all files named "foo" in directory "/"
find / -maxdepth 1 -name foo

Find all files name "foo" in current directory descending recursively
find . -name foo

Find all files starting with "foo" and ending with "bar" in the current directory
find . -name foo*bar
find . -name "foo*bar"

Find all files modified in the last seven days and tar them
find / -type f -mtime -7 | xargs tar -rf weekly_incremental.tar

Find all files named core and delete them
find / -name core | xargs /bin/rm -f
find / -name core -exec '/bin/rm -f {} ;'

Locate files modified less than 10 minutes ago
find / -mmin -10

locate files that are writeable by "others"
find . -perm +o=w

Locate files owned by a user
find . -name core -user ssinghal

Find mtime and mmin options
When specifying time with find options such as -mmin (minutes) or -mtime (24 hour periods, starting from now), you can specify a number "n" to mean exactly n, "-n" to mean less than n, and "+n" to mean more than n.
find . -mtime 0 # find files modified within the past 24 hours
find . -mtime -1 # find files modified within the past 24 hours
find . -mtime 1 # find files modified between 24 and 48 hours ago
find . -mtime +1 # find files modified more than 48 hours ago
find . -mmin +5 -mmin -10 # find files modifed between 6 and 9 minutes ago

Tuesday, July 10, 2007

moving around in bash

when you are in bash , do as emacs does.

The default orientation of bash command line is emacs. And though I am a big vim fan, I have gotten used to emacs mode for command line. And as they say, old habits die hard!

Here are some shortcuts to help you move around on the command line .


  • ctrl + e : takes you to the end of a command

  • ctrl + a : takes you to the beginning of a command

  • esc + f : takes you one word forward

  • esc + b : takes you one word backward

  • esc + d : deletes a word and puts it in a buffer

  • crtl + k : deletes the line from current word and puts it in a buffer

  • ctrl + y : paste contents of buffer

Vim and Sqlplus

open the following file :
$ORACLE_HOME/sqlplus/admin/glogin.sql
Add following line :
DEFINE _EDITOR='gvim -c "set filetype=sql"'

Typing edit will now open your favorite editor