Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Oracle Directory Management in UNIX Administration

Oracle UNIX/Linux Tips by Burleson Consulting

Directory management in UNIX

Here we cover the UNIX commands that are used to create, manage and navigate between UNIX directories. 

The UNIX pwd command

The pwd command is short for Print Working Directory, and it tells you where you are located in the UNIX tree structure.  For example, below we issue the pwd command to see our current directory:

root>pwd
/export/home/oracle

The pwd command is very important, and many Oracle professionals place the pwd command in their command prompt so they always know their current directory.  This is done by setting the UNIX PS1 system variable:

PS1="
`hostname`*\${ORACLE_SID}-\${PWD}
>"
export PS1

Now the UNIX prompt will change to always show us our hostname, the $ORACLE_SID and the current working directory:

cheops*testsid-/u01/app/oracle/admin/testsid/pfile
>pwd
/u01/app/oracle/admin/testsid/pfile

The UNIX ls command

The UNIX ls command is one of the most frequently used UNIX commands.  Without any arguments, the ls command will show us a list of all files in our current directory:

root> ls

Mailbox                   invalid.sql               run_rpt.ksh               
ad.sql                    kill_oracle_sessions.ksh  run_trunc.lst            
adamf_techeops            l.ksh                     run_trunc.sql            
admin                     list.lst                  schools.dmp              
afiedt.buf                list2.lst                 scripts                  
arsd.dmp                  lockee.txt                sql                       bksel.lst                 lst.lst                   sqlnet.log               

When we add the ?a and ?l arguments, we can see all of the details for each file in out current working directory:

root> ls -al
total 928188
drwxr-xr-x  21 oracle   dba         2048 Aug 22 20:47 .
drwxr-xr-x  10 root     root         512 Jul 26 08:49 ..
-rw-------   1 oracle   qmail        437 Aug 12 20:43 .bash_history
drwxr-xr-x  11 oracle   qmail        512 Sep  3  2000 .dt
-rwxr-xr-x   1 oracle   qmail       4381 Jul 16 13:20 .profile
-rwxr-xr-x   1 oracle   qmail       3648 Sep  1  2000 .profile_old
-rw-------   1 oracle   dba         2264 Sep  3 08:06 .sh_history
drwxr-xr-x   2 oracle   dba          512 May 10 11:10 .ssh
-rw-------   1 oracle   dba         3861 May 29 06:03 Mailbox
-rw-r--r--   1 oracle   dba        12632 Apr 11 16:09 ad.sql
drwxr-xr-x   2 oracle   dba          512 Jan 26  2001 adamf_techeops
drwxr-xr-x   5 oracle   dba          512 Sep  4  2000 admin
-rwxr-xr-x   1 oracle   dba           55 Aug 22 11:56 afiedt.buf

Let?s take a look at each of the columns in the ls ?al command so we understand their meaning.

Column

Data

1

file permissions

3

file owner

4

file group

5

file size

6

last modified date

7

file name

Table 8: The columns in the ls ?al UNIX command

The first column is the ls ?al command shows the file permissions.  The permissions are a set of letters arranged in a group of three, one for the file owner, one for the file group and another for the world (Figure 1-3).

Figure 3: UNIX file permissions

Let?s illustrate how this works with a series of examples.

Permission

Meaning

-rw-------

This file has read-write permissions for the file owner

-rw-r--r--

This file has read-write for the owner  

drwxr-xr-x

Directory ? Read-write-execute for owner, read-execute for group, read-execute for world

-r-xr-----

Read-execute for owner, read for group

-r--------

Read for owner

-rw-rw-r--

Read-write for owner and group, read for world  

Table 9: UNIX file permission examples

The third and fourth columns of the ls ?al command lists the owner and group of the file.  The file owner is noted in UNIX at the time that the file is initially created. Note that if you have super-user authority (root) you can change the owner and group of any file with the chown command.

The fifth column is the file size in bytes, and the last column is the name of the file.

Displaying ?Dot? files in UNIX

The ?a option of the ls command is used to display the ?dot? files, which are not normally seen with the ls command.  There are several ?dot? files that are of special interest to the Oracle DBA:

* Command history files ? These file keep a complete audit of each and every UNIX command issued by the UNIX user. These include .sh_history, .bash_history and .ksh_history

* Login files ? These files contain login scripts that are executed every time the user signs on to UNIX.  These include .profile, .cshrc, .kshrc and .bshrc

The UNIX cd command

The UNIX change directory (cd) command is very useful for navigating in your Oracle directory structure. The cd command without any arguments takes you to the location of your UNIX home directory.  The UNIX home directory is specified in the /etc/passwd file and defines where you will be immediately after a UNIX logon.

sting*testc1-/u01/app/oracle/admin/testc1/pfile
>cd

sting*testc1-/export/home/oracle

When you give cd a directory location, you are transferred to that location.  In this example, we transfer to the $ORACLE_HOME/rdbms/admin directory:

sting*testc1-/export/home/oracle
>cd $ORACLE_HOME/rdbms/admin

sting*testc1-/u01/app/oracle/product/8.1.7_64/rdbms/admin

UNIX also has a very handy cd argument for switching back-and-forth between two directories.  In this example, we use the cd ? command to bounce back-and-forth from the pfile directory and the /etc directory:

sting*testc1-/u01/app/oracle/admin/testc1/pfile
>cd /etc

sting*testc1-/etc
>cd -
/u01/app/oracle/admin/testc1/pfile

sting*testc1-/u01/app/oracle/admin/testc1/pfile
>cd -
/etc

sting*testc1-/etc

You can also use the cd .. command to go up one level in your directory tree.  In this example, we navigate from the pfile directory where the init.ora file is located to the bdump directory where the Oracle alert log is located (Figure 1-4).

Figure 4: The OFA Tree and cd navigation

sting*testc1-/u01/app/oracle/admin/testc1/pfile
>cd ../bdump

sting*testc1-/u01/app/oracle/admin/testc1/bdump
>
 

Removing UNIX files and directories

UNIX provides the rm command for removing data files.  Of course, the rm command can be very dangerous and most Oracle DBA?s make an alias for rm, invoking the rm ?i option.  The rm ?i option prompts you if you are certain that you want to remove the file:

root> alias rm='rm -i'   
root> rm temp.lst
rm: remove temp.lst (yes/no)? y

While UNIX provides an rmdir command for removing directories, UNIX also provides the ability to remove entire directories by using the rm ?Rf command.  The ?R option tells rm to recursively cascade through subdirectories and the ?f option says to force deletion, even if the permissions do not allow write access. In the example below, we see that the rm ?I alias warns us if we want to examine the files in the directory before removing them:

root> rm -Rf temp
rm: examine files in directory temp (yes/no)? no

Warning ? Don?t ever try this

To demonstrate the horrible power of the rm command, the following command (when executed as root) will permanently remove all files on your entire server!

root> cd /
root> rm ?Rf *

Now that we have covered the basic UNIX commands, let?s take a closer look at how Oracle DBA?s use UNIX commands in the Oracle environment.

The Oracle environment in UNIX

When you logon to UNIX, a special login file is executed to establish your UNIX environment.  These login commands perform the following functions

* Basic UNIX environment commands

* Set the UNIX command line editor

* Set Oracle aliases

* Set a standard UNIX command prompt

* Changing your Oracle UNIX environment

Basic UNIX environment commands

There are several things that need to be done when you log on to UNIX.  These login commands define your whole environment and are critical to your success in UNIX.  Let?s start with the basic environment command.

Set your shell environment

Your first choice is which shell you want as your default. Your choices are c-Shell (csh), Bourne shell (sh), Korn shell (ksh), or the Bourne Again shell (bsh).  In the example below, we set our default shell to the Korn shell.

#***********************************************************
#  Set environment to Korn shell.
#***********************************************************

ENV=.kshrc; export ENV

Set your umask parameter

The umask parameters set the default file permissions for every file you create in UNIX. In the following example, we set the umask to 022.

#***************************************************************
#  Set the umask to have 755 for executables and 644 for text
#***************************************************************
umask 022
(3)Set your UNIX terminal type
The following command set the terminal type for your session.
#***************************************************************
#  Set the terminal to vt100
#***************************************************************
DBABRV=ora; export DBABRV
ORACLE_TERM=vt100; export ORACLE_TERM
TERM=vt100; export TERM

If you like Oracle tuning, see the book "Oracle Tuning: The Definitive Reference", with 950 pages of tuning tips and scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.


 

 
��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational