Document ID:        1868_1
Subject:            COMMON UNIX COMMANDS WITH ORACLE
Last Modified:      03 October 1994
Author:             Raghu Viswanathan


        The purpose of this bulletin is to acquaint Unix users to
some of the commands 'often' used in conjunction with Oracle. You
will probably find yourself using these commands at some point in
time, especially if you are a database administrator. If you
currently work on Unix platforms, you will recognize many of the
commands. I have tried to keep this list as comprehensive as
possible to give everyone a good start.

        The options mentioned with some of the commands are the
more common ones used when using oracle. In certain places you
will either see (ucb) or (att) to denote differences between the
Berkeley and System V universes. Please acquaint yourself with
equivalent commands on your unix box if needed.

        A list of shell variables used with oracle is also provided
at the end of this document.

Disclaimer: This bulletin is not intended to replace any
documentation of any kind but is merely a 'guide'. Whenever in doubt,
please refer to the manual pages on your operating system.

----------------------------------------------------------------------
--

1. man - manual pages

   options:   man 1 ls  (ucb)
              man 6 hangman (ucb)

              man ls (att or ucb)

2. passwd - changing passwords

3. date - system date

4. who - lists all users logged in

   who am i - lists who you are (ucb)

5. cal - displays the calendar

   examples:  cal 1990

              cal 6 1990

6. pwd - present working directory

7. 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)

8. 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)

9. more - list a file a screenful at a time

   example:  more tempfile

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

10. cat - continuous listing

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

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

11. mkdir - make a new directory

    options: mkdir -p  (create intermediate directories also)

12. mv - move a file

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

              mv -f  (override prompt)

13. 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)

14. 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)

15. rmdir - remove an empty directory

16. 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.

17. 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)

18. 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)

19. wc - word count

    options:  wc -l (line count)

              wc -w (word count)

              wc -c (character count)

20. id - print name, ID, group and group ID

21. ps - display process status

    options:  ps -aux (ucb)

              ps -ef (att)

22. 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.

23. df - disk space on file systems.

24. 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.

25. lpr - send a job to the printer

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

              -h (suppress banner page)

              -# (number of copies)

26. uname - prints release information

    options: uname -a

27. 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)

28. ar - 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)

29. ranlib - makes table of contents for an archive

30. 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.

31. ipcrm - delete ipc facilities

    options:  ipcrm -s <semaphore id>

              ipcrm -m <shared memory id>

32. logname - lists login id from env variable LOGNAME

33. hostname - lists host name (ucb)

34. 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)

35. chgrp - change group

    examples: chgrp hisgroup myfile

36. newgrp - new group

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

37. 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.

38. ln - links

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

39. su - super-user or switch user

40. 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.

41. diff - file differences.

42. umask - sets default permissions for new files and directories

43. stty - terminal settings

    options:  stty -a (att)

              stty all (ucb)

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

44. tty - lists terminal

45. 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)

46. tar - tape archives

    options: tar xvt

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

47. telnet - use TELNET protocol to access another machine

48. rlogin - remote login

    options: rlogin hostname -l accountname

49. echo - echo command

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

51. vmstat - report virtual memory statistics.

52. pstat - do determine resource such as swap etc ..

    options: pstat -t

53. 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.

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

Environment Variables
---------------------

HOME - home directory

USER - userid

TERM - terminal setting

PATH - search path for files

LOGNAME - login id

PWD - present directory

EDITOR - default editor

HOST - host name

SHELL - current shell (csh = C-shell, sh = Bourne shell, ksh = Korn sh
ell)

TZ - time zone variable

ORACLE_HOME - oracle home directory

ORACLE_SID - oracle system identifier

ORACLE_LPPROG - print command for oracle applications

ORACLE_LPARGS - options to above print command

ORAKITPATH - path for resource files.

Recall to reset an environment variable:

In C-shell:      setenv TERM vt100

In Bourne shell: TERM=vt100; export TERM