UNIX & Linux For Oracle Developers & DBAs Version 11.

1 General
Command Syntax Whatis

command [option] [source file(s)] [target file] whatis <command> whatis grep man man ls

Manual

man -k ls man -k ls | grep list

Directory Structure
Root /bin Commands that can be accessed by all users /boot Static boot loader files

/

/dev Device files /etc Host-specific configuration files /home User home directories /lib Shared libraries and kernel modules /mnt Mount point for temporary file systems /opt Add on application software /root Home directory for root user /sbin System binaries /tmp Temporary files /usr Shareable, read-only /var Variable data files User su <user_name>
Change User

su root su oracle exit exit

Become root

su su -

.. cd cd / File Handling Make Directory mkdir <directory_name> mkdir morgan rmdir <directory_name> rmdir morgan rm -i <directory_name> cd $HOME ls -al mkdir morgan ls -al cd morgan mkdir subdir Remove Directory Remove Directory & Subdirectories ... down one level Change Directory .. up one level Change To Root Directory cd <directory_name> cd etc cd cd .exit whoami Current user account whoami su whoami exit whoami Navigation Change Directory .

ora / cp -ir <old_name> <new_name> cp -ir psoug. rm -ir morgan Create File touch <file_name> touch psoug.ora rm <file_name> rm psoug.ora cp <old_name> <new_name> cp psoug.ora / scp <user_name>@<server_name>:<source_path_and_file_name > <target_path_and_file_name> scp oracle@bigdog:/home/oracle/*. rm <file_spec> touch delfile Remove A File Copy Copy with Confirmation Recursive Copy Secure CoPy Delete ls -l rm delfile ls <switches> <file_spec> ls ls *ora List ls -l *ora ls -larn ls -larn *ora ls -lt mv <starting_file> <resulting_file> Move touch myfile .ls -al cd ..gz .ora / cp -i <old_name> <new_name> cp psoug.

aaa file1.aaa Rename ls -l mv file1.GROUP .bbb ls -l * mv cp del ? mv Wildcards: Multiple Characters Wildcard: Single Character cp del chown <owner_name> <directory_or_file_name> touch chngdemo Change Owner ls -l chown oracle chngdemo ls -l chgrp <group_name> <directory_or_file_name> touch chngdemo Change Group ls -l chgrp dba chngdemo ls -l Change Mode ROOT .USER .ls -l mv myfile /home/myfile ls -l mv <starting_file> <resulting_file> touch file1.

navigate to home directory cd home -.make a some directories mkdir morgan cd morgan pwd mkdir dest mkdir src .verify location pwd ls -l -.navigate to root directory cd / -.Triplets drwxrwxrwx chmod <code> <file_name> touch chngdemo Change Mode ls -l chmod 755 chngdemo ls -l Code UMASK Result CHMOD and UMASK Codes and Results 111 222 333 444 555 666 777 124 644 755 666 555 444 333 222 111 000 653 133 022 ---x--x--x --w--w--w--wx-wx-wx -r--r--r--r-xr-xr-x -rw-rw-rw-rwxrwxrwx ---x-w-r----wr--r--rwxr-xr-x Demo Navigation Exercise -.

ls -l cd src pwd touch psoug ls -l mv psoug psoug.change the host name entry uname List hardware/operating system environment uname -a List environment variables for the current session Same as set. See export demo Sets environment variables set env export export ORACLE_SID=orabase set set List environment variables for the current session Same as env. See export demo $HISTSIZE $HISTSIZE command history !10 !-4 $HISTSIZE=100 .src mv psoug Environment Manipulation Rename a Linux server's name su rename host server cd /etc/sysconfig -.

tar tar <switches> <file_spec> <tarball_name> tar -cxvf * beta1RAC.gz tar <switches> <file_spec> <tarball_name> tar -xvf beta1RAC.tar.jar cpio -ivf <file_name> cpio -idv < as_linux_x86_101300_disk1.gz jar <switches> <file_spec> <jar_name> jar -xf patch.$HISTSIZE $HOME echo $HOME command history cd $HOME cd / cd ~ File Backup & Restore Tape Archive (tar) tar <switches> <file_spec> <tarball_name> tar -cvf * beta1RAC.cpio Compressed TAR UNTAR UNTAR Compressed UNJAR A Java File CPIO Cron Commands crontab cronfile Submits jobs to be scheduled ? Makes changes to an existing chron schedule ? Submits jobs to be scheduled ? crontab -e crontab cronfile Applications Concatenate (CAT) cat <file_name> cat ? .tar tar <switches> <file_spec> <tarball_name> tar -zxvf beta1RAC.tar.

dat.*" -mtime + 14 -exec rm {} \. -name "<file_name>" -print find $ORACLE_BASE/admin/$ORACLE_SID -name "*.trc" mtime +7 -exec rm -f {} \. -name "grep" -print find find .arc -type f -ctime +3 -exec rm {} \. find $WORKDIR -name "*. grep [-options] pattern [filename] grep iostat iostat more cd /etc more protocols View environment variable's value Find Files Find archive logs older than 3 days and delete them Delete files over 14 days old Find and delete trace files more than 7 days old Global regular expression print (GREP). find . find $WORKDIR -name "<filemask>" -mtime+<days> -exec rm {}\. -name *. -name "<file_name>" -print find . Prints all lines matching a certain pattern Disk i/o Memory Statistics More Processor related statistics mpstat mpstat ps <switches> grep <filter> ps -ef ps -ef | grep ora Processes System Activity sar .An obscure word meaning "to connect in a series" df <switches> Disk Free Space df -k df -m df -h (Linux only) echo <environment variable> echo $ORACLE_SID find .

sending it to a file and to the terminal. ls -larn ls -larn | tee zzyzx ls -larn more zzyzx top Top CPU processes top q Virtual Memory Statistics vmstat vmstat which <shell command name> which grep View the full path of shell commands which id which which System Management Wireless Configuration Shared Library Dependencies Display Loaded Kernel Modules Display Open Files Display Formatted Process Tree iwconfig <switches> iwconfig wifi0 power off ldd <program_name> ldd ? lsmod lsmod lsof lsof pstree <switches> pstree -ca User Management Change Password chage .Statistics (Paging) sar -B tee <file_name> cd $HOME Tee Splits the output of another command.

ora :q! :q! :wq :wq Esc i i Esc A A Esc o o Esc r r Esc R R Esc x x Esc dd dd Esc dw save and quit insert append open a new line replace a single character replace a multiple character s delete a single character delete line delete word .and Expiration Information Force Password Change At Next Logon Create Group Display All Resource Limits for the Current User Display data about one or more users chage ? chage chage -d0 groupadd <group_name> groupadd ulimit <switches> ulimit -a finger <switches> users finger -l oracle vi create a new file or open a file for editing quit without saving vi vi initSID.

0. 2005.1. Oracle.0 .0 .2. Real Application Clusters.verify location is Oracle's home directory [oracle@gamma2 ~]$ pwd /home/oracle .1.1.verify the UNIX user [oracle@gamma2 home]$ whoami oracle -.log onto Linux as the user oracle bash demo -.log into Oracle as scott/tiger [oracle@gamma2 ~]$ sqlplus scott/tiger@orcl SQL*Plus: Release 10.Production With the Partitioning. All rights Connected to: Oracle Database 10g Enterprise Edition Release 10.0 Production With the Partitioning Option.create a test table SCOTT@orcl > create table test ( 2 testcol VARCHAR2(30)). reserved.2. OLAP and Data Mining options -. Table created. -.0. [oracle@gamma2 ~]$Disconnected from Oracle Database 10g Enterprise Edition Release 10. OLAP and Data Mining options -.dw undo Esc u u SQL*Plus Shell Script Demo -.exit SQL*Plus SCOTT@orcl >exit. Real Application Clusters.2.0.Production on Mon Nov 20 17:18:37 2006 Copyright (c) 1982.

/morgan -. EXIT EOF -.1 oracle oinstall 0 Nov 20 15:56 morgan -. COMMIT..verify the cline file was created [oracle@gamma2 ~]$ ls -al cline -rw-r--r-.1 oracle oinstall 0 Nov 20 16:04 cline -.-.open the file using vi [oracle@gamma2 ~]$ vi morgan -.delete the "cline" file [oracle@gamma2 ~]$ rm cline -.verify the file's contents [oracle@gamma2 ~]$ more morgan touch cline -.insert the following w/o quotes: "touch cline" -./morgan .open morgan with vi. remove the TOUCH command -.verify it is executable [oracle@gamma2 ~]$ ls -al morgan -rwxr-xr-x 1 oracle oinstall 0 Nov 20 15:56 morgan -.. everything else is what scrolls on screen [oracle@gamma2 ~]$ .execute it .make it executable [oracle@gamma2 ~]$ chmod 755 morgan -.create a file named "morgan" [oracle@gamma2 ~]$ touch morgan -.and put in what you see after "more morgan" below [oracle@gamma2 ~]$ vi morgan [oracle@gamma2 ~]$ more morgan sqlplus scott/tiger@orcl <<EOF INSERT INTO test (testcol) VALUES ('Cline').look at the file's permissions [oracle@gamma2 ~]$ ls -al morgan -rw-r--r-.execute it [oracle@gamma2 ~]$ .

SQL*Plus: Release 10.2. Disconnected from Oracle Database 10g Enterprise Edition Release 10.Production With the Partitioning.0.Production With the Partitioning.0. SCOTT@orcl > exit.1.0 .bash_profile alias alias alias alias ob='cd $ORACLE_BASE' oh='cd $ORACLE_HOME' cm='cd $ORACLE_HOME/oracm/log' sql='sqlplus "/ as sysdba"' # Comment/Uncomment those entries for . Real Application Clusters.1.0. Oracle. reserved. OLAP and Data Mining options SCOTT@orcl > 1 row created.0 .Production on Mon Nov 20 17:20:16 2006 Copyright (c) 1982. OLAP and Data Mining options [oracle@gamma2 ~]$ Rescue boot: linux rescue In the event of failure boot from the Linux CD or DVD # chroot /mnt/sysimage # cd /boot/grub use vi to edit/configure files Example Configuration Files export DISPLAY=localhost:0:0 Export Display echo $DISPLAY . All rights Connected to: Oracle Database 10g Enterprise Edition Release 10.0 .2.1. SCOTT@orcl > Commit complete.2. 2005. Real Application Clusters.

alpha1 oracle alpha2 oracle #beta1 oracle #beta2 oracle #gamma1 oracle #gamma2 oracle delta1 oracle delta2 oracle alpha-node1 oracle alpha-node2 oracle #beta-node1 oracle #beta-node2 oracle #gamma-node1 oracle #gamma-node2 oracle #delta-node1 oracle #delta-node2 oracle # DO NOT Comment out this entry! topdog oracle .equiv your cluster below.hosts.