Thursday, December 20, 2007

Oracle DBA & Unix Skills : Two Sides Of The Same Coin (Part-I)

Following Unix snippet will remove ^M character from all the files in the current directory.
This will come handy when the OS does not have dos2unix command.

for file in *
do
tr -s "\r" "\n" < $file > temp_file
mv temp_file $file
done
----------------------------------------------------------------------------------------------------------------
Following command will show which process(PID) is using port 1521

$ lsof -i tcp:1521|grep -i Listen
tnslsnr 8757722 oracle 8u IPv4 0xf10006000b072b98 0t0 TCP server125_vip.mylab.com:ncube-lm (LISTEN)
tnslsnr 8757722 oracle 10u IPv4 0xf100060008425398 0t0 TCP server125.mylab.com:ncube-lm (LISTEN)

----------------------------------------------------------------------------------------------------------------
Following command will print the routing table on the host. Useful for troubleshooting network issues, especially "Destination Host Unreachable" when the routes are incorrectly defined.
$ netstat -nr
Routing tables
Destination Gateway Flags Refs Use If Exp Groups

Route tree for Protocol Family 2 (Internet):
default 172.22.1.65 UGA 73 93805232 en4 - -
10.207.0.0 10.207.1.35 UHSb 0 0 en2 - - =>
10.207/20 10.207.1.35 U 3 2662434 en2 - -
10.207.1.35 127.0.0.1 UGHS 0 9480 lo0 - -
10.207.15.255 10.207.1.35 UHSb 2 76697 en2 - -
127/8 127.0.0.1 U 6 265726 lo0 - -
172.22.1.64 172.22.1.83 UHSb 0 0 en4 - - =>
172.22.1.64/26 172.22.1.83 U 59 85149714 en4 - -
172.22.1.83 127.0.0.1 UGHS 79 321272333 lo0 - -
172.22.1.127 172.22.1.83 UHSb 0 1 en4 - -
192.168.61.13 172.22.1.80 UGH 0 33543933 en4 - - =>
192.168.61.13/32 172.22.1.80 UG 0 0 en4 - -
192.168.61.14 172.22.1.82 UGH 0 575 en4 - -
194.10.159.9/32 10.207.0.12 UG 0 63056789 en2 - -

Route tree for Protocol Family 24 (Internet v6):
::1 ::1 UH 0 0 lo0 - -

----------------------------------------------------------------------------------------------------------------
SSH Login : Playing Dirty

When you login with ssh (port 22) or using putty to a unix server, the server allocates a pseudo-tty.
Then we provide the username and password (login credentials). Once after successful login test this
who (this will show you who all are logged in)
$ who
slodam pts/0 Dec 20 15:35 (167.210.219.37)
applmgr pts/1 Nov 21 09:22
oracle pts/2 Nov 16 10:53

Note that who command shows your IP address and the login name.

Now, try to sneak in to the unix server using ssh -T username@password
$ ssh -T slodam@...
slodam@...'s password:
who
applmgr pts/1 Nov 21 09:22
oracle pts/2 Nov 16 10:53

hostname command shows server126
Press Ctl+C to terminate the ssh session.

Now, nobody knows that you are logged in. Nobody knows what is your IP.

ssh -T disables pseudo-tty allocation. Since no terminal exists for you sneaked
login no information can be found about your session.


Thanks for reading
Satish Lodam

1 comment:

Unknown said...

Hi Satish,

Thanks for this posting. ASM videos are really amazing. Expecting more videos on RAC.. Willing to get touch with you to gather more knowledge. Please share your mail address.
Mine is: mail2nganesh@gmail.com

Thanks,
Ganesh