Setting Oracle environment variables in UNIX
My
OracleGuide

Setting Oracle environment variables in UNIX

About    Feedback Products

The following are a few of the basic ORACLE environment variables that can be set by the DBA.
To check the value of these environment variables enter:

env | grep -e ORA -e TNSOracle Environment Variables

LD_LIBRARY_PATHPath to library files. (Eg: /usr/lib:/usr/openwin/lib:$ORACLE_HOME/lib:/usr/games/lib)

ORACLE_BASEFull path name to the base directory for all versions of Oracle products.
ORACLE_HOMEFull path name to the version of ORACLE you are currently using. ORACLE_HOME is normally found beneath ORACLE_BASE in the directory tree. This variable is used to find executable programs and message files.
ORACLE_SIDORACLE Server system identifier (SID) or instance name. The database name is used as ORACLE_SID. This is required for all ORACLE products and is set by the coraenv or oraenv script.
ORACLE_PATHDefines the path names to locate files. If ORACLE_PATH is set, the application searches the directories specified by $ORACLE_PATH first, then the current directory. If ORACLE_PATH is not set, then the application uses the current directory. This variable is used by SQL*Plus, Forms and Menu.
ORACLE_TERMDefines a terminal definition. If not set, it defaults to the value of your TERM environment variable. Used by all character mode products.
ORAENV_ASKThis will not ask for ORACLE_SID, it will take it as it is specified. This variable is normally set to "NO" before oraenv is invoked from a script.
TNS_ADMINDefines the path name to the TNS (Transparent Network Substrate) files like TNSNAMES.ORA, SQLNET.ORA etc.
ORACLE_TRACLETrace Oracle's Unix shell scripts as they execute (using set -x).
TWO_TASKThe TWO_TASK environment variable specifies a SQL*Net connect string for connecting to a remote machine in a client/server configuration. SQL*Net will check the value of TWO_TASK and automatically add it to your connect string.

For example the following are equivalent:

sqlplus scott/tiger@db1

and

export TWO_TASK=db1; sqlplus scott/tiger

Useful UNIX Commands

man
 manual pages
man ls
passwd
 changing passwords

date
 system date

who
 lists all users logged in

 who am i - lists who you are (ucb)

cal
 displays the calendar

 examples: cal 1990

 cal 6 1990

pwd
 present working directory

cd
 change directory

 examples: cd (go to home directory)

 cd .. (move to the parent directory)

 cd . (stay in the current directory)

 cd /usr/bin (changing to a different directory)

ls
 list contents

 options: ls -l (long listing)

 ls -lg (long listing including group)

 ls -ld (long listing of directory)

 ls -a (list dot files)

 ls -lt (sort files by timestamp -
 useful for oracle trace files)

 ls -L (listing soft links)

more
 list a file a screenful at a time

 example: more tempfile

 Note: On many att machines you may have to use pg instead

cat
 continuous listing

 options: cat -b (ucb - lists line numbers)

 cat -vt (lists hidden tabs as ^I and formfeeds as ^L)

mkdir
 make a new directory

 options: mkdir -p (create intermediate directories also)

mv
move a file

 options: mv -i (prompt in case you are overwriting a file)

 mv -f (override prompt)

cp
 copy a file

 options: cp -i (prompt in case you are overwriting a file)

 cp -f (override prompt)

 cp -r (recursive copy for directories)

rm
 remove a file

 options: rm -i (prompt before deletion)

 rm -f (override prompt)

 rm -r (remove files recursively -
 useful to remove non-empty directories)

rmdir
 remove an empty directory

chmod
 change the permissions mode of a file.

 examples: chmod +x tempfile (add execute permission)

 chmod u+x tempfile (add execute for user only)

 chmod 400 tempfile (change permissions explicitly)

 chmod 4755 oracle (set the setuid bit on)

 Note: By setting the setuid bit, other processes can run with
 an effective uid to be that of the owner of the file.

grep
 search a file for a string or expression.

 options: grep -n (print line numbers)

 grep -v (print lines that don't contain pattern)

 grep -i (ignore case sensitivity)

find
 find files by name or by other characteristics

 example: find . -name sqlplus -print

 (find the full pathname of sqlplus starting from the
 current directory)

wc
 word count

 options: wc -l (line count)

 wc -w (word count)

 wc -c (character count)

id
 print name, ID, group and group ID


ps
 display process status

 options: ps -aux (ucb)

 ps -ef (att)

kill
 send a signal to terminate a process.

 options: kill -9 (signal will always be caught)

 Note: /usr/include/signal.h contains list of legal signals.

df
 disk space on file systems.

du
 disk usage in blocks

 options: du -s (prints total usage in blocks of directory)

 du -a (prints usage for each file recursively)

 Note: a directory itself occupies one block.

lpr
 send a job to the printer

 options: -Pprintername (printername is the name of the printer)

 -h (suppress banner page)

 -# (number of copies)

uname
 prints release information

 options: uname -a

nm
 print name list

 Note: T = text
 U = undefined

 example: nm libpls.a | grep pcidcl

 (this is a symbol in libpls.a on some ports)

tar
 create library archives, add or extract files

 options: ar d (delete archive)

 ar x (extract archive)

 ar t (list contents of archive)

 ar l (divert temp files to current directory instead
 of /tmp)

 example: ar x libpls.a plsima.o (extracts plsima.o from
 libpls.a and places it in the current directory -
 the .o file is still in the archive. To delete it, use
 the d option)


ipcs
 interprocess communication facilities status

 options: ipcs -s (print semaphore information)

 ipcs -m (print shared memory information)

 ipcs -q (print message queue information)

 ipcs -b (print size information)

 Note: SEGSZ - max shared memory size
 NSEMS - number of semaphores in set.

ipcrm
 delete ipc facilities

 options: ipcrm -s 

 ipcrm -m 

logname
 lists login id from env variable LOGNAME

hostname
 lists host name (ucb)

chown
 change ownership

 examples: chown joe myfile

 Note: In ucb, only root can run this command
 In att, either root or owner of file can run it

 Suns have chown -R (for recursive chown of directories)

chgrp
 change group

 examples: chgrp hisgroup myfile

newgrp
 new group

 Notes: Switch group to that specified. Password may be required.
 Creates a new shell.

file
 lists type of file

 example: file sqlplus (run on a sun)

 sqlplus: sparc demand paged executable not stripped

 Note: the type of file may be misleading.

ln
 links

 options: ln -s (create a softlink - saves space)

su
 super-user or switch user

dd
 file conversion and copy utility

 example: dd if=myfile of=newfile conv=ucase

 This converts all lower case letters in myfile to uppercase
 and puts the results into newfile.

 Note: Useful with raw devices.

diff
 file differences.

umask
 sets default permissions for new files and directories

stty
 terminal settings

 options: stty -a (att)

 stty all (ucb)

 example: stty erase h (resets erase character to 'h')

tty
 lists terminal

cpio
 copy file archives

 options: cpio -icBdvmu

 (i = input,
 c = file header information
 B = blocking
 d = create recursive directories
 v = verbose
 m = retain modification time
 u = unconditional)

tar
 tape archives

 options: tar xvt

 (x = extract
 t = list contents
 v = verbose)

telnet
 use TELNET protocol to access another machine

rlogin
 remote login

 options: rlogin hostname -l accountname

echo
 echo command

ulimit
 (att) - defines the max size of files on some systems.

vmstat
 report virtual memory statistics.

pstat
 do determine resource such as swap etc ..

 options: pstat -t

make
 this is a command generator. All executables used in
 oracle are generated from makefiles. Although an understanding
 of make is not required, it would help to pick up some simple
 information about makefiles.

env
 list environment variables (printenv on some machines.)
 The following list discusses some of the important ones.