1 MADHAV K
2 MADHAV K UNIX COMMANDS
1. $ LOGNAME
: It displays the current user information
2. $PWD
: present working directory
3. $DATE
: It displays the system date & time
4. $clear
: To clear the screen
. $cal
: it current month and year
!. $cal 2000
: "isplays the 2### year calendar
. $cal 8 2006
: displays the %th month of 2##!
%. $exit or logout
: eit from current user account
'. $ who
: displays the all user in who w ho are currently working on ser(er
1#. $i!ger more information
: displays the all user who are currently working on ser(er with
11. Who a" #
: displays current user information
12. Which or where
: displays the location of the gi(en command
)y *ommands:
Du %& ile!a"e ' to find the si+e of one file "u ,sk test.tt
Du %& ile!a"e( ile!a"e2 ). ' to find si+e of multiple files "u ,sk test.tt test2.tt
Du a
*Director+ !a"e, : -i(e the si+e of all files in that directory.
"u ,sk also can /e used to find si+e of all the files.
Du a *#! -ou!, ' #t Li%t %i/e o all ile%1oler %i/e i! re%e!t irector+ Du 34a&hr%tx5' "u for folder can /e used with any of these characters 0ut I am getting same result for "u ,tr
Du h *#! -ou!, ' co!%ier %i/e o irector+ while calcualati!g
3 MADHAV K
E:files in dsdu 5h 120 .6In 0ound6testing789I 14.#;0 .6In 0ound 13.#;0 .6
ow to i! all the ile% i! all the irectorie% i! that oler7 uo%e 1ile% i! D% i% the oler which ha% %o "a!+ ile% a! al%o 2 1oler% #! -ou! a! Out -ou!. We wa!t the ile% re%e!t i! #! -ou! a! al%o Out 9ou!: #! that ca%e what !ee% to 9e u%e7 L% ;
=yn: $which pwd 13.
: is use to create new files or to open eiting files or to append
d
;eirect' cat file1 file2 file3 file455555555reirect outut Ae!: cat filename55555555 %i!gle ile files
$cat file1 file2 file3 ?)@555555"ulti
55555555555 55555555555cntl>d
Oe! ile' cat =ile!a"e33333 "ulti files
oe! %i!gle file
$cat file1A file2A file35555555555to oe!
4 MADHAV K
*at .filename555555555for hie! files 14. Touch
: It is used to create an empty file i.e. # /yte file
=B9: $ touch filename $ touch file1 file2 file3555555555 create multiple files 1. r"
: deleting files or directories ? rm filename5555555555555555deleting single file rm 5i filename55555555555555deleting files with confirmation rm file1 file25555555555555555deleting multiple files rmdir dirname55555555555555deleting the directory /ut the directory must /e empty rm 5r dirname5555555555555deleting directory recursi(ely Ci.e. with tree strD rm ,ri dirname5555555555555remo(e directory with confirmation rm
555555555555555555555 it delets all files
rm 5I 55555555555555555555delets all files with confirmation rm t 555555555555555555555it delets whose file name starts with EtF Gow to delete the directory which is not emptyH ?: m ,r Testing78ni. 1!. "&ir
: creating directories
=yn: $mkdir dirname =ys: $)kdir .dirname555555555555hidden directory 1. <
: change directory =ys: $cd a/c $pwd5555556home6madha(6a/c using a/o(e cmd we can come out from a/c now we at 66home6madha( cd..555555555555555555555555555to come out from current directory cd..6..555555555555555555555555parent directory cd6555555555555555555555555555it changes to root directory
5 MADHAV K
cd J5555555555555555555555555it changes to home directory
1%. c
:copy source file to target file
? *p emp1 emp25555555555555555555555emp1 tp 2 coping *p ,I m1 m25555555555555555555555555o(erwrite confirmationH B *p , source directory to target directory5555555cp , a/c y+ 1'. ">
: it is used to rename or mo(e file
?: m( eiting filename new filename )( emp .emp5555555555555555555555to hide )( .emp emp55555555555555555555to unhide 2#.l%
: displayA list of all files & directories in a current directory
21.l%?"ore
: displayA list of all files & directories page /y page
22. l% a : displayA list of all files & directories including hidden files and dirctories also in current directory 23. l% r
: display list of all files & directories re(ers order in a current directory
24. L% ;
: display list of all files & directories recursi(ely in a current directory
2. L% t current directory
: display list of all files & directories according to date of cr eation in a
2!. L% 1 directory
: display all list of files & directoriesA link filesA .ee files in a current
2. L%3x current directory
: display all list of files & directories according to width wise in a
2%. L%3L i.e. ' fields
: display all list of files & directories in a current directory in a long list
(@ 1ile t+e%
6 MADHAV K
1D 55 Kor regular file iiD dLfor dir file IIID MLfor link file IN @ /Lfor /lock of filesND cL for char files here INA N is e>ice ile%5 2D Kile permissions 3D no. of links 4D owner name D group name !D file si+e in /ytes D "ate %D time 'D filename
3#. c"
: it compares two files char /y char
=ys: cmp file1 file2 ?:files in dsIn 0oundcmp type1.tt type2.tt type1.tt type2.tt differ
r: char 2A line 2
?: a1: Gello -ood )orning a2: Gello -ood ?(ening If two lines are same then return nothing If two files are are different then it displays line num/er with character position 31. co"".
: It display common lines /6w 2 files
=yn: *omm Kile1 file2 32. i 33. g
: it display different lines /6w 2 files : it display the file contents page /y page =yn: $@g filename
34. "ore
: it also display the file contents page /y page =yn: $more filename
34. hea
:it display the 1st n lines from the file =ys: $ head ,n filename
3. tail
: it display the last n lines fr om file =yn: tail ,n filename
Tail >n filename5555it indicates nth line to end of the line ?: tail >3# file Cin this file total no of records is 1##D it displays the records from 3# th to 1## 3!. wc
: it counts the no of linesA wordsA chars in a gi(en file.
7 MADHAV K
=yn: $wc filename iD wc ,l filename555555555555555555it gi(es the no of lines in a gi(en file iiD wc ,w filename555555555555555it gi(es the no of words in a gi(en file IIID wc ,c filename555555555555555 it gi(es no. of char in file i(D wc 5lw filename55555555555555 it gi(es the no of lines and character in a gi(en file
3. OIM" *P" *GP*T?= or )?TP *GP*T?= iD
EF55555555it matches E#F or more chars
iiD EHF 5555555it matches any single chars iiiD
555it matches any single chars in the gi(en list
i(D E,E555555it matches any single char in the gi(en range 1D ls t555555555555555it list the files starts with EtF 2D ls s 5555555555555it list the files that ends with E=F
3D ls /k55555555555555it list the files starts with E/F and ends with EkF 4D ls aH55555555555555it list the 2 characters filename 1 st later fallowed /y EaF and second letter is any one character
D ls/knt55555555555it list the files starts with E/F or EkF or EnF or EtF !D ls a/cdefgh or lsa5h55list the filesA first char /6w EaF to EhF
D ls /5kp5td5n555555555 it list the files the 1 st character E/F to EkF 2 nd char EpF to EtF 3rd char EdF to EnF after that a ny no of characters ls doesnFt care a/out *ase sensiti(e e: ls aeiou.tt and lsP?I<8.tt /oth will gi(e the same result 3%. gre
: glo/ally search a regular epression and print it
Is used for to search a string or regular epression in a gi(en fileCsD ID ?g: $ grep madha( sample <6p: 2nd line th line
8 MADHAV K
th line iiD ?g: $grep madha( a1A a2A a3:
a1:555555
a2:555555 a3:555555 iiiD $ grep techno 555555it searches for techno in current dir files Call filesD i(D $grep techno soft sample55555it searches for more than one wor d Oe kept it in Q
Q
(D $grep Qtechno softR sample
gre c" otio!% $ grep ,i techno sample55555555555555555555555ignore case sensiti(e $ grep ,c techno sample55555555555555555555555count no of lines $grep ,n techno sample55555555555555555555555print along with the line num/ers $grep ,l techno 555555555555555555555555555555list only file names $grep ,( Qtechno softR sample555555555555555not matches print the lines $grep ,ci techno sample5555555555555555555555Ignore case sensiti(e found no of lines $grep Qtechno R sample555555555555555555555pattern
;egular exre%%io!' any string contains wildcard charctor knows as regular epression or pattern These patterns are of t+e%:
Wor atter! :6S
6
6S 5555555start of the word 6555555end of the word
9 MADHAV K
-rep Q6Stechno6R sample 555555555555o6p: techno -rep Q6StechnoR sample5555555555555555o6p: techno soft
55555555555555555o6p: techno 123
-rep Qtechno6R sample
5555o6p: hellotechnoA a/ctechno
-rep Q6S #5'#5'#5'#5'6R sample55555555555555it display 4 digits Ci.e.1234A 4!D
Li!e atter!' B3333333333 starts of the file $5555555555ends of the file ?: grep QdR sample555555555555555it display the line starts withEdF -rep QtheR sample55555555555555555it list the lines start with EtheF -rep Q6Sthe6R simple 5555555555sample the line eactly start with EtheF -rep Qt$R simple5555555555555555555list the line ends withEtF or last char isEt2#1' -rep Q#5' $R sample555555555555 display the line ends with # to ' digit -rep Q /ktR sample555555555555list the line starting with E/F or Ek EorF tF -rep Q /ktR sample5555555555list the line which is not start with E/F or EkF orEtF -rep QR89I$R sample 555555555display the line ha(ing only word E8niF -rep QU. $R5555555555555555555555list the line which contains E4F characters C.D5555555555555555555555555555555555represent single charctor -rep Q.R555555555555555555555555=ample it list all lines -rep Q6.R =ample: 55555555555555it lists the line start with C.D Oe use to search A $A as a charctor5555555 i.e.AVA$ -rep Q$R sample55555555555555 it list empty lines -rep ,c Q$R sample5555555555counts no of empty lines in a file -rep ,( Q$R sample5555555555print not matches Ci.e. not emptyD lines -rep ,( Q$Rsample temp
10 MADHAV K
)( temp sample5555555555555555555here /oth are delete empty files This command is used to show the Pfter 3 lines when the string is found -rep ,P 3 ,i Q*handraR emp.tt This command is used to show the 0efore 3 lines when the string is found -rep ,0 3 ,I QseR emp.tt If the no.of lines found are not eactly same as the lines found then it will result the lines that it found.
3'. gre epression
: it is used for search multiple strings /ut it doesnFt allow to search regular
$grep Qhello
techno 89IRsample5555555555it searches for hello or techno str 89I
4#. egre
: it is com/ination of grep and fgrep
$egrep Qhello hello 89IRsample 41. e
$egrep Q$R sample
: to replace a string
$ sed Qs6eisting string6new string6gR filename55sed is used to find and replace and grep is for find print Gere g is to state that replace eisting string with new string -lo/ally. If we want to replace only second instance then =ed Qs6 eisting string6new string62R Oe can use any delimiter to replace the command =ed QsV eisting stringV new string VgR Oe can replace the string in only one particular line =ed Q3 sV eisting stringV new string VgR
11 MADHAV K
Oe can replace range of lines /y using /elow command =ed Q1A3 sV eisting stringV new string VgR
Oe can find any no.of lines 2 times /y using sed command =ed EpF emp.tt 5 This will print all lines 2 times Oe can print only particular lines of a file =ed ,n E1pW$pF emp.tt Oe can delete lines /y usin sed =ed E2 dF emp.tt
"elete
=ed E1dW $d E emp.tt =ed E1A dF emp.tt
2 line
"elete
"elete
1 and last line
the line range from 1 to .
iD $sed Qs68ni6Minu6gi Qmadha(: 5555555555555 Ei Efor case sensiti(e iiD $sed Qs68ni6Minu6giR5555555555555555555555 whate(er lines starting with 89I are replaced /y Minu iiiD $sed Qs6$6I like 8ni6g IR sample55555555empty string are filled with EI like 89IFF i(D $=ed Qs68ni66g IR sample55555555555555555it search 89I if found replace w ith EnothingF CemptyD 42. tr
: to translate a charctor iD tr QaR QpR Ss55555555555555555555 it read data from sample and EaF is replaced /y EpF iiD tr QaeiouR QP?I<8RSsample5555replace char /y char iiiD tr QAR QltR Semp5555555555555555whene(er QAR is there replace with ta/ space i(D tr Qa5+R QP5X S=i(a55555555 con(erts hole file into uppercase
43D
: it is used for to retrie(e reYuired fields and characters from a gi(en file
12 MADHAV K
?: madha( is good /oy55 1% chars *ut ,f 25 madha(555 o6p: adha *ut ,c 151# madha( *ut ,c 51#A 152# madha(5555555 for e(ery line 51#A 152# characters *ut ,c 1A2A3 emp.tt
@rints
*ut ,c 153A45! emp.tt *ut ,c1#5 emp.tt
1A2 and 3rd char of each line
prints
@rint
1 to 3 and 4 to ! character of each line
the lines from 1# th to end position /y using cut
command Oe can print the lines /y using delimiter *ut ,dFAF ,f2 emp.tt
This
will print the 2nd word of each line /y taking EAF as
delimiter. *ut ,dFAF ,f2A3A emp.tt
This
will print the 2nd and 3rd words of each line /y
taking comma as delimiter.
Gow to get the last field of a file. *at emp.ttV re(V cut ,dFAF ,f2 Vre(
44D Pa%te
: is used for to Zoin two or more files hori+ontally /y using delimiter
*at states filename
cat cities
paste ,d Q:Rstates citiestr
P@
Gydera/ad
P@: Gydera/ad
Tamilnadu
madras
Tamilnadu: madras
;arnataka
0angalore
;arnataka: 0angalore
;erala
Tri(andrum
)aharashtra
0om/ay
4D ort : it is used for to sort the file content. 0y default it sorts file contents /ased on P=*II (alues5default is ascending =ort sample iD sort ,r sample555555displays descending order
13 MADHAV K
iiD sort ,u sample55555it displays uniYue lines in the gi(en file iiiD sort ,n file5555F9R numeric comparisons i(D sort ,nur file (D sort sample temp $m( temp sample
orti!g the ata iel 9+ iel >pos55starting field 5@os55ending field CoptionalD iD =ort ,f >pas1 ,pas2 filename iiD =ort ,f >1 53 filename55555starting from end /efore 3 iiiD =ort ,fn >2 53 file 555555it gi(es only num/ers 4!D C!i order
: it displays uniYue lines in the gi(en file /ut the file contents should /e in sort
?:file1
iD $ uniY file
iiD $uniY ,u filename55 it eliminates duplicates
Paaaaa Paaaaa
Paaaaa
ccccc
Paaaaa
cccccccc
ddddd
*cccccc
dddddd
@pppp
"dddd
hhhhhh
ttttttt
Ghhhh
pppppp
Ghhhh
ttttttttt
@pppp Ttttttt iiiD $ 8niY ,d filename5555displays only duplicated lines
IND uniY ,c filename55555it counts
how many times lines duplicated
Paaaaa555552 *ccccccc55551
14 MADHAV K
ND $ uniY ,u file temp $ m( temp filename "elete duplicated lines from file
"dddd555551 Ghhhhh5552 @pppp555551 Ttttttt555551
4Dii!g?@ : it is used for to com/ine 2 or more cmds Vtake left side o6p to right side cmd as i6p iD $who Vwc ,l555555555count total no of lines CfilesD in c urrent directory iiD $ lsVwc ,l555555555555displays total no of su/directories in the current directory iiiD ls ,l Vgrep QdR5555displays total no of su/directories who stats with line noEdF iND $head 53# sampleVtail >2# sample555555display the the lines from 2# to 3# from gi(en file (D $ grep 89I stud V cut ,f 2A 3Vsort filename 55555 display 89I students names & ph no in ascending order 4%@ $tee
: it is used to for to write data to the file as well as to the screen $grep 89I stud V cut ,f 2A 3 Vsort Vtee file1
F@ hell %criti!g' It is group of 89I commands and shell keywords The main concept of shell scripting is to handle tet files ID -ou!e %hell 5555stea(e 0ourne 55555$55555555sh555 Csh as i!terreter@ ii@ -a%h %hell C/orne again shellD 555same as a/o(e55ad(anced (ersion of 0ourne is 0P=G CMinu default shellD iii@ Hor! %hell555555"a(id korn5555$5555555555ksh CinterpreterD 5555used as PI default shell )ostly used shell is korn shell it supports re usa/ilityA all shell designed on /ourn shell #@ $&%h
I(D $echo $0 I2@ $alia%
: shift to korn shell : it displays current child shell name : it lists all alias names
15 MADHAV K
I@ C!alia% alia% !a"e%' to delete alias names : it displays the pre(iously eecuted commands
IF@ $ hi%tor+
: it display the string on scree n CmonitorD
II@ Echo
1ile er"i%%io!%'xxxxxxxxx@ C%erow!er333er"i%%io!%
ir%t art@
Grou er"i%%io!%
%eco! art@
Other er"i%%io!%
thir art@
J333 a er"i%%io!% to ugo 9ut it oe% !ot elete exiti!g er"i%%io!@ 333 e!+ er"i%%io!%@ K3333 a%%ig! er"i%%io!% a er"i%%io!% to ugo 9ut it elete exiti!g er"i%%io!@@ rw56rw56r55 555555555"efault permissions for regular files rw6rw6r5555555555default permission for directories !D ch"o
: it is used for to change file permissions
=yn: $chmod who6 >656[6 iD ls ,l filename5555555rw5 rw5
rL
iiD chmod g> filename55555rw5 rw rL iiiD chmod u>A g5w filename555555rw r5 rL iND chmod g[w filename55555rw ,w5 rL
Octal coe ;ea333333F Write333332 Execute( $chmod ! filename5555555rw r5 rw5 $chmod !42 filename5555 rw5 r55 5w5 D chow!
: to change owner name of the file
\chown owner name filename
16 MADHAV K
%@ chgre
: to change group name of the file
\ chgrp group name filename %@ $write ser(er
: it is user for to with the users /ut the user should /e logged into the
$write techno2 Gello
iiD $mesg n55deny the msg iiiD mesg y5to allow msges
*mtl>d 'D aw&!aw& file
: scan for patterns in a file and process the results
!#@ cat
: concatenate ClistD or file
!1D ch%h Cpaawd ,e65sD userlogin7shell: change the user login shell !2D
: report the summary of disk /locks and nodes free and in use iD df ,k555it displays the disk space in /ytes iiD df ,h555it displays disk space in kilo /ytes iiiD df ,g555it displays the disk space in giga /ytes
!3Du :it displays the directory wise disk usage in form of /locks each /lock si+e is 12 /ytes !4Dg /i
:to create a +ip file
? $g+ip filename5555 o6p: filename.g+ To *reate multiple Xip files to a single Xip file we use /elow command Xip my+ip.+ip emp.tt The a/o(e command will +ip all the files to )y+ip.+ip and we c an get all files starting with emp. !D gu!/i
: to un+ip the files
?: gun+ip filename.g+ !!. co"re%%
: it also used for to +ip the file555 it used to sa(e with .+ format
!D C!co"re%%
: same as a/o(e
-+ip sa(es more memory than compress !%D /cat
: it used to displays +ip file contents in reada/le format
17 MADHAV K
$+cat sample.g+
c $ sleep 1##& #D % or $ % : it displays current user account running process list Cshow status of acti(e processD 1D $% a: it displays all user accounts running process list 2D Hill
: it kill /ackground process
?: kill @I" 3D tel!et
: to connect to remote ser(er
4D t: file transfer protocol 55555transfer files from one ser(er to another $ ftp ipaddress Mogin: 5555555 @assword: 555555 Ktpls Cser(erD KtpVlsCclientD Ktpget filename Cto download a fileD Ktpmget file1 file255555 Cto download multi filesD Ktpput filename Cto upload a fileD Ktpmput file1 file255555 Cto upload multi filesD D1t: to transfer files from one ser(er user account to another ser(er user account $su root 55to switch to admin !D Wall : it is used for to sent /roadcast message to all users who are currently working on ser(er
18 MADHAV K
$wall Gappy new5year *ntl>d D"ail mail
:it is used for to send the mailA if user is not logged in then also we can send
iD $ mail techno1 *ntl>d e(ery user contains mail/o at a time we can send msg to multiple users 2D $mail techno1 techno2 techno 3 =u/: from techno *ntl>d iiiD $ mail technoSstud stud send content as a mail to techno3 mail is the cmd to read mails in the mail/o $mail 1first mail 2second mail reading &2 it Yuickly opens second mail &Y55Yuit from mail /o &w to sa(e mail contents to a file &pprint mail contents &r55replays &d5delete mails %@$"ail :to read mails send to secondary mail/o 'D e"ac%
:full screen editor
%#@ echo
: echo the tet string to on monitor
%1D ile
: classify the file type
19 MADHAV K
%2D exr
: e(aluates the argumentsA used to do arithmeticAetc in the shell
%3D i!
: find filesA matching a type or pattern
%4D o%t!a"e
: display or set the name of the current machine
%Dl!
: link the source to target
%!Dl Al%tat
:show the status of the print Zo/s
%Dlr:l
:print to defind printer
%%D lr": ca!cel
: remo(e a print Zo/ from the print Yuee
%'D "a!
:display manual of gi(en cmd
0@o
:octal dump a /inary fileAin octalAP=*IIAheAdecimal or char
'1Da%%w
:to set or change password
'2D r
: filter the file and print it on the terminal
'3D rc ho%t!a"e
: remotely copy files from this machine to another machine
'4D rlogi!e ho%t!a"e: login remotely to another machine 'D r%h ho%t!a"e
: remote shell to run on another machine
'!D %crit ile eecuted
: sa(es e(erything that appears on the screen to file until eit is
'D %ource ile
: read cmds from the file and eecute them in the current shell
'%D %tri!g ile
: used to search /inary files for P=*II strings
''D t+
: set or display terminal control options
1##D uuecoe ile
: decode a uuencoded fileA recreating the original file
1#1D uue!coe !ew !a"e : encode the /inary file to 5/it P=*IIAusefull when sending (ia emailA to /e "ecode as new name at destination 1#2D >i
: (isual Afull screen editor
1#3D o9%
: display /ackground and suspended processes
1#4@ &ill (
: remo(e suspended process \1
1#D to
: display the currentA most computer5intensi(e commands
1#!D o%>iew
: display the operating system statistics
1#D %ete!>
: list en(ironmental (aria/les
20 MADHAV K
CN#
What i% "ea!t 9+ a%%w ile7 This file maintains each and e(ery user information with fields. The fields are 8sername: passwd: uid: gid: fullname: home: shell.
What i% hell7 =hell is a command line interpreter. =hell acts as an interface /etween user and the kernel.
What i% Her!el7 ;ernel is core part of 89I o6s. It is a group of hundreds of system calls.
What are iere!t la>or% o C!ix o%7 Pny operating system designed /ased on uni kernel called as fla(our of uni. The following are some fla(ours of uni Minu 5555 ed Gat =un solaris 555 =un )icrosystem I0)5PI 55555 I0) Gp5u 55555 G@ =co5uni 55555 santa crus operations II555555 =ilicon -raphics.
What are the iere!t %ecurit+ eature% i! C!ix7
1. @assword protection. 2. Kile permissions. 3. ?ncryption.
What,% the co""a! to i! out toa+,% ate7 date
What,% the co""a! to i! out u%er% o! the %+%te"7
21 MADHAV K
who
ow o +ou i! out the curre!t irector+ +ou,re i!7 pwd
What i% the co""a! to %ee the locatio! o co""a!7 Ohere is Scommand name
ow o +ou i! out +our ow! u%er!a"e7 Ohoami
CorD log name
ow to clo%e the curre!t u%er accou!t7 ?it
ow to create e"t+ ile7 Touch Sfilename
ow o +ou re"o>e a ile7 m Sfilename
ow to oi! "ultiile ile% >erticall+7 *at
file1 file2 file3 UU
The ile or which we o !ot ha>e write er"i%%io! ca! 9e elete u%i!g the co""a!7 rm 5f Sfilename
ow o +ou re"o>e a irector+ a! it% %u9irectorie%7 rm ,rf Sdirectoryname
ow to re!a"e a ile7 )( Sfilename
ow to co+ "ultile ile% a! irectorie% i!to %o"e other irector+7 cp 5r source7directory destination7directory ow to %ee hoe! ile%7 Ms ,a
ow to %ee ile% a! %u9irectorie% ile% recur%i>el+7 Ms ,
ow to %ee ile% i! lo!g li%t or"at age wi%e7 Ms ,l V more
ow to ie!ti+ whether a ile i% !or"al ile or irector+7
22 MADHAV K
$ls 5l filename6directoryname if the first digit is 5 then it is fileA if it is d then it is directory file
What i% the iere!ce 9etwee! l% 3r a! l% 3;7
ls 5r lists the files in re(erse alpha/etical order... whereas ls 5 lists the files and directories recursi(ely
The iere!ce 9etwee! a %ot li!& a! a har li!&7 P sym/olic CsoftD linked file and the targeted file can /e located on the same or different file system while for a hard link they must /e located on the same file system.
what are the iere!t co""a!% u%e to create ile%7 1.touch 5 to create empty files Ce.gD 5 touch Sfilename 2.(i Sfilename 3. catfilename
Li%t %o"e wil car character%7 H 5 Iit matches any single character 5 It matches +ero or more characters 5 It matches any single character in gi(en list
.3
It matches any single character ecept enter key character
what i% the outut o the ollwi!g co""a! ' l% 4a3"!o3r5Q
list all the files in the current directory starting alpha/et is /etween a to m or n or /etween o to r
ow o +ou cou!t wor%: li!e% a! character% i! a ile7 Oc Sfilename
which co""a! i% u%e to ie!ti+ the t+e o the ile7 file
23 MADHAV K
gre "ea!% -lo/ally search a regular epression and print it
ow o +ou %earch or a %tri!g i!%ie a gi>e! ile7 grep string filename
ow o +ou %earch or a %tri!g i!%ie a curre!t irector+7 grep string
ow o +ou %earch or a %tri!g i! a irector+ with the %u9irectorie% recur%e7 grep 5r string
Diere!ce 9etwee! gre: egre a! gre
grep : does not accept more then one epression
egrep : accepts more than one pattern for search. Plso accepts patterns from a file.
fgrep : accepts multiple patterns /oth from command line and file /ut does not accept regular epressions only strings. It is faster than the other two and should /e used when using fied strings.
What are li!e atter!%7 5 start of the line $ 5 ?nd of the line
ow to %earch e"t+ li!e% i! a gi>e! ile7 -rep Q$R Sfilename
ow to cou!t !o o 9la!& li!e% i! a ile7 -rep ,c Q$R Sfilename
ow to re"o>e E"t+ li!e% or" a gi>e! ile7
24 MADHAV K
-rep ,( Q$R filename temfilename )( tempfilename filename
What i% atter! to %earch F igit wor i! a ile7 -rep QS#5' #5' #5' #5'R filename
What i% atter! to %earch the li!e ha>i!g o!l+ three character%7 -rep Q)$R filename
What i% atter! to i%la+ li!e% e!i!g with S$R character i! a gi>e! ile7 -rep Q$$R filename
ow to i%la+ 2 a! F th ile% ro" a gi>e! ile i the eli"etr i% S'R7 *ut ,dR:R ,f 2A4 filename
ow to i%la+ u!iue li!e% ro" a gi>e! ile7 =ort ,u filename
ow to eli"i!ate co"letel+ ulicate li!e% ro" a gi>e! ile7 8niY ,u filename
ow to re"o>e all ulicate li!e% ro" a ile7 8niY ,u filename tempfilename )( tempfilename filename
ow to elete ShelloR wor ro" a gi>e! ile7 =ed Qs6hello66R filename awk
is awk is
a powful 8ni command. It allows the user to manipulate files that are s tructured as columns of data and
Exa"le' ^
_pattern awk _pattern
`action_ input5file output5file
meaning: take each line of the input fileW if the line contains the pattern apply the action to the line and write the resulting line to the output5file.
25 MADHAV K
If the pattern is omittedA the action is applied to all lines:
ow to co"are two ile% are %a"e or !ot7 *mp
ow to i%la+ the ir%t (0 li!e% ro" a ile7 Gead 51# filename
Write a o!e li!e co""a! to co!>ert all the caital letter% o a ile te%t i!to lower ca%e7 cat filename V tr ]P5X] ]a5+]
The ieli!e to li%t the i>e large%t ile% i! the curre!t irector+ i%
ls 5l V tr 5s _ _ V sort 5t _ _ 5fnr >4 5 V head ,
The ieli!e to i! out the !u"9er o ti"e% the character 7 occur% i! the ile i% tr 5dc _H_ S file V wc 5c
C "elete all the characters ecept ecept H and then make a word count.D
ow to cou!t total !o. o u%er% wor&i!g i! the %+%te"7 Oho V wc ,l
ow to i%la+ the li!e% ro" I to (0 ro" a gi>e! ile7 Gead 51# filename V tail >
what will 9e outut o ollowi!g co""a!7 echo STec!o%otR ? wc c '
What i% the eault u"a%&7 #22
26 MADHAV K
What i% the eault er"i%%io! or 1ile Director+ 7 The "efault pri(ileges for file : !44 The default pri(ileges for directory :
What CN# co""a! will co!trol the eault ile er"i%%io!% whe! ile% are create7 8mask Exlai! the rea: write: a! execute er"i%%io!% o! a CN# irector+. ead allows you to see and list the directory contents. Orite allows you to createA edit and delete files and su/directories in the directory. ?ecute gi(es you the pre(ious read6write permissions plus allows you to change into the directory and eecute programs or shells from the directory.
What i% ch"o: chow! a! chgr7 *hmod : It is used for to change permissions on files *hown : It is used for to change ownership of a file *hgrp : It is used for to change group of the file
# the ow!er oe%!,t ha>e write er"i%%io! o! a ile: 9ut hi%her grou ha%: ca! he%he eit it7 9o. Ge6she can_tA/ecause the owner_s permission o(errides the group_s. To %ee li%t o ile% a! irectorie% :what er"i%%io! reuire7 ead permission
What are P#D%7 They are process I"s gi(en to processes . P @I" can (ary from # to !3.
ow o +ou li%t curre!tl+ ru!!i!g roce%%7 ps
ow o +ou %to a 9ac&grou! roce%%7 kill pid ow o +ou i! out a9out all ru!!i!g roce%%e%7
% 3ag ow o +ou %to all the roce%%e%: excet the %hell wi!ow7 kill # ow o +ou ire a roce%% i! the 9ac&grou!7
27 MADHAV K
.roce%%3!a"e What oe% the co""a! &ill 3 $U o7 kills the last /ackground process
i there i% a roce%% u wa!t to ru! e>e! ater exiti!g the %hell what i% the co""a! u%e7 9ohup
which co""a! will get execute e>e! ater +ou log out7 9ohup
which %ig!al ca!!ot 9e trae7 kill ,'
ow to reirect %ta!ar error to a ile7 A!%wer 2 filename What oe% the to co""a! i%la+7 top command displays the current ammount of memory occupied /y the currently eecuting processes and the details. In addition to memory usage top command displays cpu usage and process details
What i% the co""a! to %e! "e%%age to all u%er% who are logge i!7 Oall
What i% the co""a! to %e! "ail to other u%er7 )ail username
ow to oe! %eco!ar+ "ail 9ox7 )ail 5f
What o +ou o i +ou o!Vt wa!t to 9e i!terrute 9+ other u%er%V "e%%age%7
28 MADHAV K
Pns. mesg n
hell criti!g #!ter>iew ue%tio!%
Diere!ce 9etwee! the outut o echo QQ a! echo Q Q echo lists all the filenames in the current directory.. echo lists all the filenames in the current directory twice.
The other wa+ o ru!!i!g %hell %crit aart ro" u%i!g %h co""a! a! ch"o7 ans:5 using b we can run a shell script
1'. Gow do you refer to the arguments passed to a shell scriptH 5 $(: $2 a! %o o!. $0 i% +our %crit !a"e. 2#. OhatFs the conditional statement in shell scriptingH 5 i co!itio!X the! ) i 21. Gow do you do num/er comparison in shell scriptsH 5 5 e: 3!e: 3lt: 3le: 3gt: 3ge 22. Gow do you test for file properties in s hell scriptsH 5 5 % ile!a"e tell% +ou i the ile i% !ot e"t+: 3 ile!a"e tell% +ou whether the argu"e!t i% a ile: a! !ot a irector+: 3 ile!a"e te%t% i the argu"e!t i% a irector+: a! !ot a ile: 3w ile!a"e te%t% or writea9ilit+: 3r ile!a"e te%t% or reaa9ilit+: 3x ile!a"e te%t% or executa9ilit+ 23. Gow do you do 0oolean logic operators in shell scriptingH 5 U te%t% or logical !ot: 3a te%t% or logical a!: a! 3o te%t% or logical or. 24. Gow do you find out the num/er of arguments passed to the s hell scriptH 5 $Y 2. OhatFs a way to do multile(el if5elseFs in shell scriptingH 5 i co!itio!X the! %tate"e!tX eli co!itio!X %tate"e!tX i 2!. Gow do you write a for loop in shellH 5 or >aria9le !a"eX i! li%tX o %tate"e!tX o!e 2. Gow do you write a while loop in shellH 5 while co!itio!X o %tate"e!tX o!e 2%. Gow does a case statement look in shell scriptsH 5 ca%e >aria9leX i! o%%i9le3 >alue3(X@ %tate"e!tXZZ o%%i9le3>alue32X@ %tate"e!tXZZ e%ac 2'. Gow do you read key/oard input in shell scriptsH 5 rea >aria9le3!a"eX 3#. Gow do you define a function in a shell scriptH 5 u!ctio!3!a"e@ Y%o"e coe here retur! X 31. Gow does getopts command workH 5 The parameters to your script can /e passed as 5n 1 5 2#. Inside the scriptA you can iterate through the getopts array as w hile getopts n: optionA and the (aria/le $option contains the (alue of the entered option.
0atch file:
29 MADHAV K
0atch files allow )=5"<= and )icrosoft Oindows users to create a lists of commands to run in seYuence once the /atch file has /een eecuted. Kor eampleA a /atch file could /e used to run freYuently run commandsA deleting a series of filesA mo(ing filesA etc. P simple /atch file does not reYuire any special programming skills and ca n /e done /y users who ha(e a /asic understanding of )=5"<= commands.
O;A
1.
OGPT I= "PTP < I9K<)PTI<9H
Pns: The )atter that we feed into the *omputer is called "ata or Information.
2.
OGPT I= "PTP0P=?H
Pns: The *ollection of Interrelated "ata is called "ata 0ase.
3.
OGPT I= P "PTP0P=? )P9P-?)?9T =B=T?) C"0)=D @P*;P-?H
Pns: The *ollection of Interrelated "ata and some @rograms to access the "ata is *alled "ata 0ase )anagement =ystem C"0)=D.
4.
OG?9 *P9 O? =PB P "0)= @P*;P-? P= "0)=H
Pns: Kor a system to ualify as ?MPTI<9PM "PTP0P=? )P9P-?)?9T systemA it must use its ?MPTI<9PM facilities to )P9P-? the "PTP0P=?.
.
OGPT I= <"0)=H
Pns:
!.
9P)? =<)? *<""_= 8M?=.
30 MADHAV K
Pns: "r. ?.K. *odd presented 12 rules that a data/ase must o/ey if it is to /e considered truly relational.
Information ule: Ta/ular epresentation of Information.
cD
-uaranteed Pccess ule: 8niYueness of tuples for guaranteed accessi/ility.
dD )issing Information ule: =ystematic representation of missing information as 98MM Nalues. eD
*omprehensi(e "ata =u/5Manguage ule: M to support "ata definitionA
Niew definitionA "ata manipulationA IntegrityA Puthori+ation and =ecurity.
.
OGPT P? GI?P*GI*PMA 9?TO<;A P9" ?MPTI<9PM "PTP0P=? )<"?M=H
Pns: aD ierarchical Moel' The Gierarchical )odel was introduced in the Information )anagement =ystem CI)=D de(eloped /y I0) in 1'!%. In this data is organi+ed as a tree structure. ?ach tr ee is made of nodes and /ranches. The nodes of the tree represent the record types and it is a collection of data attri/utes entity at that point. The topmost node in the structure is called the root. 9odes succeeding lower le(els are called children.
/D Networ& Moel' The 9etwork )odelA also called as the *<"=BM data/ase structureA is an impro(ement o(er the Gierarchical modeA in this model concept of parent and child is epanded to ha(e multiple parent5child relationshipsA i.e. any child can /e su/ordinate to many different parents Cor nodesD. "ata is represented /y collection of recordsA and relationships among data are represented /y links. P link is an association /etween precisely two records. )any5to5many relationships can eists /etween the parent and child.
cD ;elatio!al Moel' The elational "ata/ase )odel eliminates the need
31 MADHAV K
for eplicit parent5child relationships. In "0)=A data is or gani+ed in two5dimensional ta/les consisting of relationalA i.e. no pointers are maintained /etween ta/les.
%.
OGPT I= "PTP )<"?MI9-H
Pns: "ata )odeling descri/es relationship /etween the data o/Zects. The relationships /etween the collections of data in a system may /e graphically represented using data modeling.
'.
"?KI9? ?9TITBA PTTI08T? P9" ?MPTI<9=GI@.
Pns: ?ntity: Pn ?ntity is a thingA which can /e easily identified. Pn entity is any o/ZectA placeA personA concept or acti(ity a/out which an enterprise records data. Pttri/ute: Pn attri/ute is the property of a gi(en entity. elationship: elationship is an association among entities.
1#.
OGPT I= ?5)<"?MI9-H
Pns: The ?5 modeling techniYue is the Top "own Ppproach. ?ntity relationship is techniYue for analysis and logical modeling of a systemFs data reYuirements. It is the most widely used and has gained acceptance as the ideal data/ase design. It uses three /asic units: entitiesA their attri/utes and the relationship that eists /etween the entities. It uses a graphical notation for representing these.
11.
OGPT I= 9<)PMIXPTI<9H
Pns: 9ormali+ation is a step5/y5step decomposition of comple records into simple records.
12.
OGPT P? NPI<8= 9<)PM K<)=
Pns: The Kirst 9ormal Korm 19KA The =econd 9ormal Korm
29KA
32 MADHAV K
The Third 9ormal Korm
39KA
The 0oyce and *odd 9ormal Korm 0* 9K.
13.
OGPT I= "?9<)PMIXPTI<9H
Pns: The intentional introduction of redundancy to a ta/le to impro(e performance is called "?9<)PMIXPTI<9.
14.
OGPT P? 15TI?A 25TI?A 35TI? < 95TI? "PTP0P=? P*GIT?*T8?=H
Pns: 15Tier "ata/ase Prchitecture is /ased on single systemA which acts as /oth ser(er and client. 25Tier Prchitecture is /ased on one ser(er and client. 35Tier Prchitecture is /ased on one ser(er and client out that on client act as a remote system. 95Tier Prchitecture is /ased on 9 no.
1.
OGPT P? P TP0M?A *
Pns: Ta/le: P Ta/le is a data/ase o/Zect that holds your data. It is made up of many columns. ?ach of these columns has a data type associated with it. *olumn: P columnA referred to as an attri/uteA is similar to a field in the file system. ecord: P rowA usually referred to as tupleA is similar to record in the file system.
1!.
OGPT I= "IKK??9*? 0?TO??9 P @<*?"8PM MP9-8P-? P9" P
9<95@<*?"8PM MP9-8P-?H Pns: @rocedural Manguage 9<95@rocedural Manguage
33 MADHAV K
P program in this implements a step5/y5step algorithm to sol(e the pro/lem. It contains what to do /ut not how to do .
1.OGPT TB@?
1%.
*MP==IKI*PTI<9
Pns: ""M C"ata "efinition ManguageD
"M "ata uerying Mnaguage
")M C"ata )anipulating ManguageD "*M C"ata *ontrol ManguageD T*MC"ata Transaction ManguageD
*reate Plter "rop Truncate enameA =elect A Insert 8pdate "elete )erge A -rant e(oke A oll/ack *ommit sa(epoint
1'.
OGPT I= "IKK??9*? 0?TO??9 ""M P9" ")M *<))P9"=H
Pns: Kor ""M commands autocommit is <9 implicitly whereas Kor ")M commands autocommit is to /e turned <9 eplicitly.
2#.
OGPT I= "IKK??9*? 0?TO??9 P TP9=P*TI<9 P9" P 8?BH
Pns: P Transaction is unit of some commands where as uery is a single line reYuest for the information from the data/ase.
21.
OGPT I= "IKK??9*? 0?TO??9 T89*PT? P9" "?M?T? *<))P9"=H
34 MADHAV K
Pns: Truncate *ommand will delete all the rec ords where as "elete *ommand will delete specified or all the re cords depending only on the condition gi(en.
22.
OGPT I= "IKK??9*? 0?TO??9 8@"PT? P9" PMT? *<))P9"=H
Pns: Plter command is used to modify the data/ase o/Zects where as the 8pdate command is used to modify the (alues of a data /ase o/Zects.
23.
OGPT P? *<))P9"=
Pns: -rant and e(oke are the two commands /elong to the "*M *ategory.
24.
OGI*G I= P9 ?KKI*I?9T *<))P9" 5 T89*PT? < "?M?T?H OGBH
Pns: "elete is the efficient command /ecause using this command we can delete only those records that are not rea lly reYuired.
2.
OGPT P? 8M?= K< 9P)I9- P TP0M? < *
Pns: 1D 9ames must /e from 1 to 3# /ytes long. 2D 9ames cannot contain Yuotation marks. 3D 9ames are not case sensiti(e. 4D P name must /egin with an alpha/etic character from your data/ase character set and the characters $ and \. 0ut these characters are discouraged. D P name cannot /e <P*M? res er(ed word. !D P name must /e uniYue across its namespace.
2!.
G
35 MADHAV K
Pns: P Ta/le can ha(e 1### columns.
2.
OGPT P? "IKK??9T "PTPTB@?= =8@@<T?" 0B =MH
Pns: *har Csi+eDA 9char Csi+eDA Narchar2 Csi+eDA 9(archar2 Csi+eD data types for character (aluesA 9um/er CprecisionA scaleDA 9um/erA 9um/er CnDA KloatA Kloat C/inary precisionD data types for numerical (aluesA "ate data type for date (aluesA MongA aw Csi+eDA Mong awA *lo/A 0lo/A 9clo/A 0file for large o/Zects.
2%.
OGPT I= "IKK??9*? 0?TO??9 M<9- P9" M<0 "PTPTB@?=H
Pns: M<0
M<9-
1D The maimum si+e is 4-0. 2D M<0s Cecept 9*M<0D can /e attri/utes of an o/Zect type. 3D M<0s support random access to data. 4D )ultiple M<0 columns per ta/le or M<0 attri/utes in an o/Zect type. 1D The maimum si+e is 2-0. 2D M<9-s cannot.
3D M<9-s support only
seYuential access. 4D
2'.
OGPT I= "IKK??9*? 0?TO??9 *GP P9" NP*GP2 "PTPTB@?=H
Pns: Narchar2 is similar to *har /ut can store (aria/le no.
36 MADHAV K
3#. G
Pns: Kor "ate data type oracle allocates /ytes )emory. "efault "ate Kormat is: ""5)<95BB.
31.
OGPT I= P9-? K< ?P*G "PTPTB@?
Pns: "atatype *har
ange
Narchar2 9um/er
Kloat
M<9-A POA M<9-PO Marge
CM<0FsD 2### /ytes 4### /ytes @recision 1 to 3% =cale 5%4 to 12 @recision 3% decimals
32.
2 -0 4-0
G
Pns: Oe canFt rename a *olumn of a ta/le directly. =o we follow the following steps. To ename a *olumn: aD
Plter the ta/le specifying new column name to /e gi(en and data type.
/D
Then copy the (alues in the column to /e renamed into new column.
cD
drop the old column.
33.
G
Pns: To "ecrease the si+e of a "ata type of a column i.
Truncate the ta/le first.
ii.
Plter the ta/le column whose si+e is to /e decreased using the same
37 MADHAV K
name and data type /ut new si+e.
34.
OGPT I= P *<9=TPI9TH OGPT P? IT= NPI<8= M?N?M=H
Pns: *onstraint: *onstraints are representators of the column to enforce data entity and consistency.There r two le(els 1D*olumn5le(el constraints 2DTa/le5le(el constraints.
3.
MI=T <8T PMM TG? *<9=TPI9T= =8@@<T?" 0B =M.
Pns: 9ot 9ullA 8niYueA *heckA @rimary ;ey and Koreign ;ey or eferential Integrity.
3!.
OGPT I= "IKK??9*? 0?TO??9 89I8?>9
Pns: 8niYue and 9ot 9ull is a com/ination of two *onstraints that can /e present any num/er of times in a ta/le and canFt /e a referential key to any column of an another ta/le where as @rimary ;ey is single *onstraint that can /e only once for ta/le and can /e a referential key to a column of another ta/le /ecoming a referential integrity.
3.
OGPT I= P *<)@<=IT? @I)PB ;?BH
Pns: P @rimary key created on com/ination of columns is called *omposite @rimary ;ey.
3%.
OGPT I= P *P9"I"PT? *
@<==I0M? @? *<)@<=IT? @I)PB ;?BH Pns: It is a part of composite primary key. )aimum 32 candidate key can /e there in composite primary key.
3'.
G
Pns: P 98MM (alue is something which is una(aila/leA it is neither +ero nor a space and any mathematical calculation with 98MM is always 98MM.
38 MADHAV K
4#. OGPT I= 98MMH P *<9=TPI9T < "?KP8MT NPM8?H Pns: It is a default (alue.
41. OGPT I= "?KP8MT NPM8? K< ?N?B *
42. OGPT I= *?PT?" I)@MI*ITMB K< ?N?B 89I8? P9" @ I)PB ;?B *
43. OGPT P? MI)ITPTI<9=
44. OGPT I= "IKK??9*? 0?TO??9 ?K??9*?= P9" K<?I-9 ;?B *<9=TPI9TH Pns: eferences is used as column le(el key word where as foreign key is used as ta/le le(el constraint.
4. OGPT I= ]<9 "?M?T? *P=*P"?]H Pns: when this key word is included in the definition of a child ta/le then whene(er the records from the parent ta/le is deleted automatically the respecti(e (alues in the child ta/le will /e deleted.
4!. OGPT I= @P?9T5*GIM" < )P=T?5"?TPIM ?MPTI<9=GI@H Pns: P ta/le which references a column of another ta/leCusing eferencesDis called as a child ta/leCdetail ta/leD and a ta/le which is /eing referred is called @arent C)asterD Ta/le .
39 MADHAV K
4. G
4%. I= <P*M? *P=? =?9=ITIN?H Pns: 9<
4'. G
#. OGPT I= P @=?8"<5*
1. OGPT K< ]<"? 0B] *MP8=? K< P 8?BH Pns: To arrange the Yuery result in a specified
2. OGPT I= ]-<8@ 0B] 8?I?=H Pns: To group the Yuery results /ased on condition.
3. 9P)? =<)? P--?-PT? K89*TI<9=
4. OGPT I= "IKK??9*? 0?TO??9 *<89T CDA *<89T CD K89*TI<9=H Pns: *ount CD will count the s pecified column whereas count CD will
40 MADHAV K
count total no. of rows in a ta/le.
. OGPT K<
!. OGPT I= P =8058?BH Pns: P Yuery within a Yuery is called a su/ Yuery where the result of inner Yuery will /e used /y the outer Yuery.
. OGPT P? =M <@?PT<=H Pns: Nalue CDA ef CD is =M operator. C 8sed with
%. ?@MPI9 ]P9B]A]=<)?]A]PMM]A]?I=T=] <@?PT<=H Pns: A!+: The Pny Cor itFs synonym =<)?D operator computes the lowest (alue from the set and compares a (alue to each returned /y a su/ Yuery.
All' PMM compares a (alue to e(ery (alue returned /y =M. Exi%t%' This operator produces a 0<
'. OGPT I= P *<?MPT?" =80 8?BA GD on either of the sidesCleft or rightD /ased on the reYuirement.
!3. OGPT I= "IKK??9*? 0?TO??9 ?8I P9" =?MK
!4. OGPT P? ]=?T] <@?PT<=H Pns: 89I<9 PMMA89I<9A I9T?=?*T A)I98= are =?T <@?PT<=.
42 MADHAV K
!. OGPT I= "IKK??9*? 0?TO??9 ]89I<9] P9" ]89I<9 PMM] <@?PT<=H Pns: 89I<9 will return the (alues distinctly whereas 89I<9 PMM will return e(en duplicate (alues.
!!. 9P)? =<)? 98)0?A *GPP*T?A "PT?A *<9N?=I<9A
Date 1u!ctio!%: =ysdateA )onths /etween Cd1A d2DA To7char CdA formatD Mast day CdDA 9et7day CdA dayD.add7monthsCdAnDA ?tract
er%io! 1u!ctio!%'
To7charA To7dateA To7num/er
!. OGPT I= "IKK??9*? 0?TO??9 )P CD P9" -?PT?=T CD K89*TI<9=H Pns: )P is an aggregate function which takes only one column name of a ta/le as parameter whereas -reatest is a general function which can take any num/er of (alues and column names from dual and ta/le respecti(ely.
43 MADHAV K
!%. OGPT K< 9NM CD K89*TI<9 I=H Pns: 9NM Kunction helps in su/stituting a (alue in place of a 98MM.
!'. OGPT K< "?*<"? CD K89*TI<9 I=H Pns: It is su/stitutes (alue /asis and it actually does an _if5then5else_ test.
#. OGPT I= "IKK??9*? 0?TO??9 TP9=MPT? CD P9" ?@MP*? CD K89*TI<9=H Pns: TranslateCD
is a superset of functionality pro(ided /y eplaceCD.
1. OGPT I= "IKK??9*? 0?TO??9 =80=T CD P9" I9=T CD K89*TI<9=H Pns: =u/strCD will return the specified part of a string whereas
InstrCD return the position of the specified part of the string.
2. OGPT I= P 8MIP9 "PB 98)0?H Pns: It will return count of the no.
3. G
4. G
. OGPT I= "IKK??9*? 0?TO??9 T<7"PT? CD P9" T<7*GP CD *<9N?=I<9 K89*TI<9=H
44 MADHAV K
Pns: To7date con(erts character date to date format whereas To7char function con(erts date or numerical (alues to characters.
!. OGPT I= P NI?OH G
%. OGPT I= P9 I9MI9? NI?OH Pns: Inline (iew is /asically a su/Yuery with an alias that u can use like a (iew inside a =M statement. It is not a schema o/Zect like =M5o/Zect.
'. G
%#. OGPT K< ]OITG *G?*; <@TI<9] K< P NI?OH Pns: ]OITG *G?*; <@TI<9] clause specifies that inserts and updates r performed through the (iew r not allowed to create rows which the (iew cannot select and therefore allows integrity constraints and data (alidation checks to /e enforced on data /eing inserted or updated.
%1. OGPT I= P9 I9"?H P"NP9TP-?
45 MADHAV K
access to rows in a ta/le. Pn Inde increases the performance of the data/ase.
%2. OGPT I= P =?8?9*?H @=?8"<5*
%3. OGPT I= P *M8=T?H OG?9 T< 8=? P *M8=T?H G
%4. OGPT I= P =9P@=G
%. OGPT I= P =B9<9B)H Pns: P =ynonym is a data/ase o/Zect that allows you to create alternate names for
%!. OGPT I= "IKK??9*? 0?TO??9 @INPT? P9" @80MI* =B9<9B)H Pns:
46 MADHAV K
%. OGPT I= "IKK??9*? 0?TO??9 ]=M] P9" ]=M@M8=] *<))P9"=H Pns: =M commands are stored in the /uffer whereas =M@M8= are not.
%%. 9P)? =<)? =M@M8= *<))P9"=H Pns:
"?=* *I0?A =TPTA -?TA =PN?A 6 are =M@M8= *<))P9"=.
%'. OGPT P? ]=M@M8= ?@<TI9-] *<))P9"=H Pns: =@<
'#. OGPT P? =B=T?) P9" <0?*T @INIM?-?=H Pns: *onnect and esource etc are =ystem @ri(ileges. *reate So/ZectA =electA InsertA Plter etc are
'1. OGPT K< "*M *<))P9"= P?H Pns: *ommitA oll/ack are "*M commands.
'2. OGPT K< -P9T *<))P9" OITG ]OITG -P9T <@TI<9]H Pns: QOith -rant
'3. G
47 MADHAV K
'4. OGPT I= P =*G?)P P9" =*G?)P <0?*T=H Pns: P schema is a collection of logical structures of dataA or schema
o/Zects. P schema is owned /y the data/ase user and has the same name as that of user. ?ach user owns a single schema. =chema o/Zects include following type of o/Zects *lustersA "ata/ase MinksA KunctionsA IndeesA @ackagesA @roceduresA =eYuencesA =ynonymsA Ta/lesA "ata/ase TriggersA Niews.
'. G
'!. OGPT I= P =?==I<9H Pns: The period /etween Mogin and Mogoff on schema.
'. OGPT I= P *MI?9T @<*?==H OGPT I= P =?N? @<*?==H Pns: ref: 12 & P.
'%. G
''. G
1##. G
48 MADHAV K
=?T =M@<)@T Snew prompt.
1#1. G
1#4. OGPT P? "IKK??9T TB@?=
A!o!+"ou% Na"e -loc&%
49 MADHAV K
1#. OGPT P? *<)@<=IT? "PTP TB@?=H Pns: ecordsA Ta/les are two *omposite data types.
1#!. OGPT I= =*<@?
1#. OGPT I= P 9?=T?" 0M<*;H Pns: P /lock within a /lock is called 9ested 0lock.
1#%. OGPT I= P @M6=M ?9-I9?H Pns: The @M6=M engine accepts any (alid @M6=M /lock as inputA eecutes the procedural part of the statements and sends the =M statements to the =M statement eecutor in the
1#'. OGPT I= "?KP8MT NPM8? K< P 98)?I* @M6=M NPIP0M?H Pns: 98MM
11#. OGPT I= "IKK??9*? 0?TO??9 =I)@M? M<<@ P9" P K< M<<@H Pns: =imple reYuires declaration of (aria/les used in it and eit condition /ut Kor Moop doesnFt reYuire this.
111. OGPT I= P *8=<H =T?@= T< 8=? P *8=<H Pns: *ursor is @ri(ate =M area in @M6=M. "eclare the *ursorA
50 MADHAV K
*lose the *ursor.
112. G
113. OGPT I= P *8=< K< M<<@H Pns: *ursor Kor Moop is shortcut process for ?plicit *ursors /ecause the *ursor is
114. OGPT P? *8=< PTTI08T?=H Pns: ^Kound
^9otKound
^Is
11. OGPT I= 8=?
11!. OGPT I= P9 ?*?@TI<9H G
Nalue7?rror etc.
Xero7"i(ideA
9ot7Mogged7
51 MADHAV K
11%. G
"?*MP? Seception name ?*?@TI<9W 555555555W 5 5 5 5 5 5 5 5 5W 0?-I9 5 5 5 5 5 5 5 5 5W 5 5 5 5 5 5 5 5 5W PI=? Seception nameW ?*?@TI<9 OG?9 Seception name TG?9 5 5 5 5 5 5 5 5 5W 5 5 5 5 5 5 5 5 5W ?9"W
11'. OGPT I= ]
12#. OGPT I= =*<@?
121. OGPT I= P =805@<-P)H
52 MADHAV K
Pns: P =80@<-P) I= P @M6=M 0M<*;A OGI*G OIMM 0? I9N<;?" 0B TP;I9@PP)PT?=.
122. OGPT P? "IKK??9T TB@?=
123. G
12. OGPT I= ]I9 <8T] @PP)?T?H Pns: P parameterA which gets (alue into the @rocedure or Kunction and takes the (alue out of the @rocedure or Kunction areaA is called I9 <8T parameter.
12!. "= <P*M? =8@@<T= @<*?"8?
12. OGPT I= P @P*;P-? P9" @P*;P-? 0<"BH Pns: @ackage is declarati(e part of the functions and proc edures stored in that package and package /ody is the definition part of the functions and procedures of that pac kage.
53 MADHAV K
12%. OGPT I= P"NP9TP-?
12'. I= IT @<==I0M? T< GPN? P @<*?"8? P9" P K89*TI<9 OITG TG? =P)? 9P)?H Pns: 9< if it is out side a @ackageA B?= if it is within a @ackage.
13#. "= <P*M? =8@@<T= ?*8=IN? K89*TI<9 *PMM=H Pns: B?=.
131. OGPT I= P TI--?H G
132. OGPT I= "IKK??9*? 0?TO??9 P TI--? P9" P *<9=TPI9TH Pns: *onstraints are always T8? whereas Triggers are 9
133. OGPT P? "IKK??9T ?N?9T= K< P TI--? P9" TG?I =*<@?=H Pns: InsertA 8pdate or "elete.
54 MADHAV K
134. OGPT I= "IKK??9*? 0?TO??9 TP0M? M?N?M P9"
13. OGPT P? P8T<9<)<8= TI--?=H Pns: =upports to pro(ide *ommit statement in Triggers. Triggers a declared as independent
Transactions.
13!. OGPT I= P9 ]I9=T?P"
13. G
13%. OGPT I= ]TP0M? )8TPTI9-] ?<H G
Ta/le name is mutatingA trigger6function may not see it
*ause : P trigger or a user5defined @M6=M function that is referenced in the statement attempted to Yuery or modify a ta/le that was in the middle of /eing modified /y the statement that fired the trigger. Pction : ewrite the trigger or function so it does not read the ta/le.
13'. OG?9 T< 8=? ]:9?O] P9" ]:
55 MADHAV K
141. G
142. G
143. G
144. G
14. OGPT I= P TP9=I?9T P9" @?=I=T?9T <0?*TH Pns: The
14!. OGPT I= P *
14. G
14%. OGPT I= P *
56 MADHAV K
14'. OGPT I= "IKK??9*? 0?TO??9 NPPB P9" 9?=T?" TP0M?H Pns: Narray has a fied si+e. 9ested ta/les can carry any num/er of (alues.
1#. G
11. OGPT I= 8=?
12. OGI*G @P*;P-? I= 8=?" K< KIM? I9@8T6<8T@8T I9 <P*M?H Pns: 8TM7KIM? @ackage is used for Kile input6output in
13. 9P)? =<)? )?TG<"= P9" @<*?"8?=
14. OGPT I= =MH G
1. OGPT I= P9 IT?PT<H 9ame some TB@?=
57 MADHAV K
Pns: =M Iterators are /asically record groups generated during transactionA which reYuires manipulation of more than one records from one or more ta/les. There are two types Iterators namely 9amed Iterator and @ositional Iterator.
1!. OGPT P? "IKK??9T =T?@= T< OIT? P "B9P)I* =M @<-P)H Pns: ?g: char c7sYlstring[`Q"?M?T? K<) sailors OG?? ratingRW ??* =M @?@P? readytogo K<) :c7sYlstringW ??* =M ??*8T? readytogoW
1. OGPT I= TP0M? @PTITI<9I9- P9" I9"? @PTITI<9I9-H Pns:
1'. OGPT I= @GB=I*PM )?)<B =T8*T8?
1!#. OGPT I= M<-I*PM )?)<B =T8*T8?
1!1. OGPT I= GAH Pns: P =ystem -lo/al Prea is a group of shared memory allocated /y
58 MADHAV K
1!2. OGPT I= PGAH Pns: The @rogram -lo/al Prea is a memory /uffer that contains data and control information for a ser(er process. P @-P is created /y
1!3. OGPT I= P9 <P*M? I9=TP9*?H Pns: ?(ery time a data/ase is startedA an =-P is allocated and
1!4. OGPT P? "IKK??9T <P*M? @<*?==?=H Pns: P process is a Qthread of controlR or a mechanism in an operating system that can /e eecute a series of steps. =ome operating systems use terms Zo/s or
task. P process normally has its own pri(ate memory area in which it runs. Pn
1!. OGPT I= "IKK??9*? 0?TO??9 @)<9 P9" =)<9H Pns: =)<9 C=ystem )onitorD performs instance reco(ery at instance of startup. In a multiple instance system Cone that uses the parallel ser(erDA =)<9 of one instance can also perform instance reco(ery other instance that ha(e failed whereas The @)<9 C@rocess )onitorD performs process reco(ery when a user process fails.
1!!. OGPT I= "IKK??9*? 0?TO??9 "PTP0P=? P9" TP0M?=@P*?H Pns: "ata/ase is a physical *omponent Ta/lespace is a Mogical component
1!. OGPT I= <0
59 MADHAV K
Pns: The "ata 0ase Oriter writes modified /locks from the data/ase /uffer cache to the data files.
1!%. OGPT I= <0
1!'. OGPT I= ?*
1#. OGPT I= P*GIN?H Pns: The Prchi(er CP*GD copies the online redo log files to archi(al storage when they are full. AP*G is acti(e only when a data/aseFs redo log is used P*GIM<- mode.
11. OGPT I= P =T<?" 8?BH Pns: NI?O
12. OGPT I= 8=? @<*?== P9" =?N? @<*?==H Pns: P 8ser process is created and maintained to eecute the software code of an application program Csuch as @< @rogramD or an <P*M? tool Csuch as =M "0PD. The 8ser process also manages the communication with ser(er processes. 8ser processes communication with the ser(er @rocesses through the program interface.
60 MADHAV K
ser(er configuration allows many user processes to share a small num/er of ser(er processesA minimi+ing the utili+ation of a(aila/le system resources.
13. OGPT I= P =?MK ?K??9TIPM I9T?-ITBH Pns: Ta/le related to itself .Koreign key of the ta/le links to primary key of the same ta/le.
14. OGPT I= P ]PI=?] =TPT?)?9TH Pns: It is used to aise ?ceptions.
1. OGPT I=
62 MADHAV K
=ystimestamp : -i(es date and time including fractional seconds in =?N? time +one current7timestamp: -i(es date and time including fractional seconds in *MI?9T time +one sysdate: -i(es only date in ser(er time +one current7date: -i(es only date in client time +one ?tract : 8sed to retrie(e a particular (alue from the gi(en month 6 year D.
date
C day 6
to7timestampCdD : *on(erts gi(en date into date & time information with am 6 pm . d/time+one : -i(es ser(er time +one (alue Timestamp : "ata type Putomatically stores date and time information with am 6 pm .
select systimestamp A current7timestamp from dualW select sysdateAcurrent7date from dualW select d/time+one from dualW select to7timestampCsysdateD from dualW 2#5Zan5#' !:4%:23 pm select etractCday from sysdateD A etractCmonth from sysdateDA etractCyear from sysdateD from dualW
create ta/le temp Cc1 timestampDW insert into temp (aluesCsysdateDW select from tempW 2#5Zan5#' !:2:23 pm 5555555555555555555555555555555555555555555555555555555555555555555555555555 9ew -eneral Kunctions: *oalesceCepr1Aepr2Aepr3A.......D 555 @icks the first not null epression result .
63 MADHAV K
nullif C epr1Aepr2 D 555 If epr1 and epr2 results are same it returns 98MM (alue otherwise it return epr1 result. 9(l2Cepr1Aepr2Aepr3D 555 If epr1 is null it manipulates epr3 Aif epr1 is not null it manipulates epr2.
select coalesceC1## > nullA 12% 5 null > 1###A 12 nullA 22A 234A'%%'D from dualW 55 22
select enameA Zo/A coalesce Ccomm 2A sal 1.D /onus from empW
select nullifC1##A# 2DA nullifC3##A3# 1##DA nullif C!##A3## > 3##D from dualW 55 null 3## null
select rollA nameA nullifCfeeA2##D from student where course [ _
select enameA Zo/A n(l2CcommAsal > commAsalD net from empW 555555555555555555555555555555555555555555555555555555555555555555555555555 )utiple Inserts: =upports to insert into more than 1 ta/le at a time. 0ut input must /e retrie(ed from eisting ta/le.
?: )ake 3 empty ta/les same as "ept ta/le. *reate ta/le "1 as select from dept where rownum is nullW *reate ta/le "2 as select from dept where rownum is nullW
64 MADHAV K
*reate ta/le "3 as select from dept where rownum is nullW
insert into "1 select from deptW insert into "2 select from deptW insert into "3 select from deptW
insert all into "1 (aluesCdeptnoAdnameAlocD into "2 (aluesCdeptnoAdnameAlocD into "3 (aluesCdeptnoAdnameAlocD select from deptW
*onditional Insert: insert all when Cdeptno S[ 4#D then into "1 (aluesCdeptnoAdnameAlocD when Cdeptno S[ '#D then into "2 (aluesCdeptnoAdnameAlocD else into "3CdnameAlocD (aluesCdnameAlocD select from deptW
insert all when course [ _
65 MADHAV K
into stu7d!i (aluesCrollAnameAfeeD when course [ _uni_ then into stu7uni (aluesCrollAnameAfeeD select from studentW
=tudent
stu7oracle
555555555
555555555555
oll
oll
name
name
course
fee
fee 5555555555555555555555555555555555555555555555555555555555555555555555555555 )erge : 8sed to compare the 2 ta/le contents and makes them eYual. It supports only 8pdate and Insert operations .
merge
*lauses:
into Temp T
into 55 Target
using emp ?
8sing 55 =ource
on C T.empno [ ?.empno D
when matched then update set t.sal [ e.salA t.comm [ e.commA t.deptno [ e.deptnoA t.Zo/ [ e.Zo/A t.mgr [ e.mgr when not matched then