Upload
papusaha
View
49
Download
1
Embed Size (px)
DESCRIPTION
linux
Citation preview
Revision no.: PPT/2K403/02
Essential Unix (and Linux) for the Oracle DBA
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
2
Architecture of UNIX Systems
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
3
UNIX System Structure
Operating system interacts directly with Hardware
Provides common services to programs
Insulating from Hardware
Kernel is treated as an operating system
Programs are independent of the Hardware
Easy to move on different processing environment
Programs should be independent of Hardware
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
4
UNIX System Structure (contd.)
Programs in the upper layer communicate with Kernel using
defined set of system calls
System calls instruct the Kernel to do various operations
System calls also exchange the data between Kernel and
program
Some Standard programs also fall in this layer i.e. executable
files by C compiler
Top most layer is used for other application programs eg. C
compiler (CC)
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
5
SHELL
It is a program that interprets the commands.
If the command is valid then the shell directs the kernel to
carry out the request
If invalid then an error message is displayed.
Shell starts when an user logs in, and terminates when the
user logs out.
Presence of shell is indicated by a special symbol known as
the shell prompt ( $ or # ).
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
6
SHELL (contd.)
Several shells are available to handle the same hardware in
different ways.
Redirection of data : the shell facilitates chaining or
"pipelining" of commands, i.e. the output of one program flows
down the pipe and becomes an input to the next program.
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
7
SHELL (contd.)
Interpretiveprogramming
language
Program execution
Pipeline hookup
SHELLSHELL
Environmentcontrol
I/O Redirectio
n
File name substitutio
n
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
8
Different shells
Bourne shell or Standard shell (sh) :
Introduced in 1978 and is widely used in AT&T Unix.
Gives "$" as the prompt to the user and " # " to the superuser
(root).
One disadvantage is that it does not provide command history.
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
9
Different shells (contd.)
C shell (csh) :
Gives "%" as the prompt to user.
It is different from the sh.
Syntax is similar to the C language programming.
It is quite popular among the programmers.
Provides aliasing of the command i.e. the ability to customize the
command names.
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
10
Different shells (contd.)
Restricted shell (rsh) :
Basically designed to restrict the rights of normal users
It cannot execute
cd command
path variable
command containing "/
redirect outputs
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
11
Different shells (contd.)
The Korn Shell
The Korn shell is a product of AT&T Bell labs & was developed
by David Korn.
It has many novel features like the facility to edit the command
line,the history mechanism, aliases & job control.
Moreover the Korn shell also lets you handle computations
awk-like formatted printing & simplified menu routines.
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
12
Accessing the Unix System
Directly from the server hosting the database itself
Via a UNIX workstation
Through a Windows NT Server front end.
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
13
Basic Unix Commands
Display the machines symbolic nameuname
Display present working directorypwdTo change users passwordpasswd
Gives you the commands entered previously by users.$ history 3
historyIs a pattern-recognition command.grepDisplay text on your screenecho
Display time & datedateChange directoriescd
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
14
Basic Unix Commands
As the name of this command indicates, whereis will give you the exact location of the executable file for the utility inquestion.$ whereis who: /usr/bin/who /usr/share/man1.z/who.1$
whereis
Indicates who you are logged in as.whoami
Display list of all the users currently logged into the system.
who
Enables you to find out which version of a command the shell is using.$ /bin/cat$$ which cat
which
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
15
Linux Environment
/etc/profile file owned and managed by the system administrator.
It is used to automatically set the environment variables for users at login time.
The shell looks in users home directory as an alternative location for environment information in the .profile file.
env command is used to display the entire set of environment variables.
Use export command to set any environment variable. Eg export ORACLE_SID=prod2
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
16
Input & output in Unix
$ date > file1.txt$ file1 < file2.txt$ date | file2
Eg.
Redirects standard error2>
Appends standard input to a file>
Redirects standard output>
Redirects standard input /dev/rmt/0m
Will copy the contents of the entire directory to the tape name
/dev/rmt/0m
cpio i < /dev/rmt/0m
The cpio command with the i option restores all the contents
of the tape named /dev/rmt/0m to the current directory
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
46
The Crontab and Automation of Scripts
DBAs will have to schedule their shell programs and other data loading programs for regular execution by the Unix administrator
Unix provides the cron table to schedule database tasks. One can invoke the crontab by crontab 1. To add programs to the schedule or make scheduling
changes, the command is crontab e. #-----------------------------------------------------------------------
minute hour date month day of week command30 18 * * 1-6 analyze.ksh#--------------------------------------------------------------------------------------
The preceding code indicates that the program analyze.ksh will be run Monday through Saturday at 6:30 P.M.
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
47
The Crontab and Automation of Scripts
Revision no.: PPT/2K403/02
CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
48
Design & Published by: CMS Institute, Design & Development Centre, CMS House, Plot No. 91, Street No.7,
MIDC, Marol, Andheri (E), Mumbai 400093, Tel: 91-22-28216511, 28329198
Email: [email protected]
www.cmsinstitute.co.in