Wednesday, August 27, 2008

Unix commands for DBAs - Part 2


#----------------------------------------------------------------------------------
# VI edior shortcuts
#----------------------------------------------------------------------------------
Opening files:
#---------------
vi filename To open a file 'filename' with vi editor
vi + filename To open a file 'filename' with vi editor - In last line to append

Saving files:
#---------------
ESC :wq To save and exit the current open file
ESC :wq! To save and exit the current open file - forcefully (for read only files)

Modes:
#---------------
a To append after cursor
A To append at the end of line
i To insert before cursor
I To insert in beginning of line
o To add new line below cursor
O To add new line above cursor

Misc options:
#---------------
ESC :se nu To display line numbers in current open file
ESC :se nonu To turn off displaying line numbers in current open file






Tuesday, August 26, 2008

Unix commands for DBAs - Part 1


#----------------------------------------------------------------------------------
# LISTING FILES & DIRECTORIES
#----------------------------------------------------------------------------------
ls To list the contennts (files/directories) in current working directory
ls -l Long listing display (displays owner, group, type of file, modification date/time etc.)
ls -la Long list + hidden files and directories (starts with .)
ls -lar Long list + hidden files + sort by reverse modification date/time
ls -lR Recursive long list

#----------------------------------------------------------------------------------
# CHANGING DIRECTORIES
#----------------------------------------------------------------------------------
cd Move to home directory
cd .. Move to one dirctory back
cd ../.. Move two levels of back directory
cd /export/home/oracle Move to Oracle's home directory
cd ~oracle Move to Oracle's home directort (in KSH shell)
pwd Shows present working directory

#----------------------------------------------------------------------------------
# FINDING FILES (variuos examples)
#----------------------------------------------------------------------------------
find / -name filename
find / -name *.log
find / -name filename -type f
find / -name filename -size +10000c
find / -name filename -mtime +10
find / -name filename -xdev
find / -name filename -exec ls -l '{}' \;
find / -name filename -exec rm '{}' \;

#----------------------------------------------------------------------------------
# MISCELLENEOUS COMMANDS
#----------------------------------------------------------------------------------
mkdir abc Make directory 'abc' in current directory
mkdir -p /tmp/d1/d2/d3 Make recursive directories d1->d2->d3
cp source destination Make copy of 'source' file to 'destination' file
cp -r dir1 dir1 Make a directory copy (recursive copy)
cp -pr dir1 dir2 Make a directory copy with retaining date/time (recursive copy)
mv file1 file2 Rename 'file1' to 'file2'
mv dir1 dir2 Rename directory name from 'dir1' to 'dir2'

#----------------------------------------------------------------------------------
# FILES/DIRECTORY DELETION
#----------------------------------------------------------------------------------
rm file1 Delete 'file1'
rm -i file1 Delete 'file1' - interactively
rm -f file1 Delete 'file1' - forcefully
rm -r dir1 Delete 'dir1' directory - recursively
rmdir dir1 Delete an empty directory 'dir1'

Friday, August 15, 2008

Welcome

Hi,

I am the new DBA in making :-)

I am trying to put together some important tips and tricks related to Oracle Database administration. You may use this blog but ON YOUR OWN RESPONSIBILITY. (I am still learning :-))

Thanks,
The New Oracle DBA