Friday, May 30, 2008

Some Linux commando's Redhat

Tar and zip file:
tar zcf oblog.tar.gz *

Get RedHat release:
cat /etc/redhat-release

Get the processor information:
cat /proc/cpuinfo

Get memory information:
cat /proc/meminfo

Determine if an machine is 32bit or 64bit:
uname -a
64 bit:
Linux hostname 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:58:43 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux

32 bit:
uname -a
Linux hostname 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:12 EDT 2008 i686 i686 i386 GNU/Linux

What is LISTING on a specific port:
netstat -a | grep {PORT_NUMBER}

or

lsof -i tcp:{PORT_NUMBER}

ssh to another host without a password:
#Generate a key pair
cd $HOME/.ssh/
ssh-keygen -t rsa

#copy the key pair to the server from which you want to log in:
cat id_rsa.pub | ssh host 'cat>>.ssh/authorized_keys'


What is the biggest file in a directory:
du --max-depth=1 /home/ | sort -n -r


Size of multiple directories
du -sH *

Friday, May 23, 2008

bash one liners

Kill all processes form a user:
pkill -u [USER_NAME]

Automatic start by linux startup check
chkconfig -l [APP_NAME]

Automatic start by linux startup add application, in runlevel 3,5
chkconfig -add [APP_NAME] -level 3,5


Which linux OS:
cat /etc/issue

To remove the ^M characters at the end of all lines in vi, use:
:1,$s/^V^M//g

Want to know which file contains specific words in a directory tree:
find ./ -type f -name '*' -print0  ¦ xargs -0 grep -li -e "word1" -e "word2" -e "word3"

When you want an user typing a password in a shell script you do not want to see this password on the screen. You can use read -s to do this:
echo "Please type the administrator password:
read -s PASSWORD

Get the file name from an string with a whole path this can be done with the basename function.
For example, the path /oracle/product/10.2.0/bin/emca and you only want emca you can do this
EMCA=`basename /oracle/product/10.2.0/bin/emca`

And if you want the directory this is also simple:
ORACLE_BIN=`dirname /oracle/product/10.2.0/bin/emca`

If you want to query some value from an Oracle database and put this value in a variable in the shell script. Make a function which does the login on sqlplus and the query. This function can be called and put in an variable:
execsql_silent()
{
$ORACLE_HOME/bin/sqlplus -s $ORACLE_CREDENTIALS <<SQL
whenever sqlerror exit
set heading off
set feedback off
$*;
exit
SQL
}

STATUS_DB=$(execsql_silent "SELECT status FROM v\$instance")

Waiting cursor function

When you want to animate a sleep in a shell script you can use the following function:
waiting_cursor()
{
echo "In 5 seconds ..., cancel with CTRL-C"
sleep 5
pid=$!
printf "Waiting: |"
rotate='|/-\'
while kill -n 0 $pid 2>/dev/null;
do
rotate="${rotate#?}${rotate%???}"
printf '\b%.1s' "$rotate"
sleep 1
done
echo " "
wait $pid
echo " "
}

Thursday, May 22, 2008

Drop database

Removing a 10g database is really simple with the commando drop database. All files are removed from the OS.
shutdown abort;
startup mount exclusive restrict;
drop database;

Begin Blog

This is my first post on my blog. I want to use this blog as an notepad for all my knowledge about Oracle software.

I hope this blog will help you solving your problems.