Unix

Published on July 2020 | Categories: Documents | Downloads: 9 | Comments: 0 | Views: 106
of 67
Download PDF   Embed   Report

Comments

Content

 

UNIX

SREE NIPUNA SOFTW SOFTWARE ARE SOLUTIONS

 

Contents: 









Introduction to UNIX

UNIX Architecture UNIX Command  The vi editor UNIX Shell Scripting

 

Introduction: 

Unix is a multitasking, multi-user computer operating sstem!



Unix "as originall developed in #$%$ & a group o' AT(T emploees!



Solaris Unix, AIX, )* Unix and +S are 'e" avors o' UNIX!

 

UNIX Architecture

S/00 NI*UNA S12T3A/0 S14UTI1NS

.

 

UNIX Architectur Architecture e UNIX Architecture consists o' t"o parts: •



Shell 5ernal

Shell: A Unix shell is a command-line interpreter! Kernal: A Unix kernel is a computer program that manages input6output input6ou tput re7uests 'rom so't"are and translates into data processing processing

them

instructions 'or the central processing processing

unit and other electronic components o' a computer!

S/00 NI*UNA S12T3A/0 S14UTI1NS

8

 

UNIX Commands touch ls cat cp mv rm chmod p"d 

"c sort uni7 cut grep head tail mkdir 

S/00 NI*UNA S12T3A/0 S14UTI1NS

%

 

rmdir cd "ho am i date d'  du 

9nd man 



nohup ps kill 



sed

S/00 NI*UNA S12T3A/0 S14UTI1NS



 

ls command Sntax: ls •

<option

ls command list all the 9les and directories availa&le in current director director!!

S/00 NI*UNA S12T3A/0 S14UTI1NS

;

 

ls -l •

4ist all 9les and directories 'rom current director in long 'ormat!

S/00 NI*UNA S12T3A/0 S14UTI1NS

$

 

ls -a •

ispla all 9les including hidden 9les!

S/00 NI*UNA S12T3A/0 S14UTI1NS

#<

 

ls -la •

Using multiple options at a time!

S/00 NI*UNA S12T3A/0 S14UTI1NS

##

 

touch Sntax: •

touch <!lena"e

touch command creates =ero &te 9les!

S/00 NI*UNA S12T3A/0 S14UTI1NS

#>

 

cat Sntax: cat •

<!lena"e

cat command displas the content o' a 9le!

S/00 NI*UNA S12T3A/0 S14UTI1NS

#?

 

cat Sntax: cat •

<!lena"e# <!lena"e$

cat command displas the content o' a 9le!

S/00 NI*UNA S12T3A/0 S14UTI1NS

#.

 

cat Sntax: cat • •



  • • •

 <!lena"e

Creates a 9le "ith ne" 9le name n ame and open 'or editing! Use ctrl@d kes to exit edit mode 1pens an existing 9le in overriding overriding mode! Sntax:

cat  <!lena"e

Creates a 9le "ith ne" 9le name n ame and open 'or editing! Use ctrl@d kes to exit edit mode 1pens an existing 9le in appending mode!

S/00 NI*UNA S12T3A/0 S14UTI1NS

#8

 

cp Sntax: •

cp <!lena"e <ne% !lena"e

cp command cop data 'rom one 9le to other!

S/00 NI*UNA S12T3A/0 S14UTI1NS

#%

 

mv Sntax: "& •



<!lena"e <ne% !lena"e

mv command move data 'rom one 9le to other, old 9le exits! /ename a old 9le to ne" 9le!

S/00 NI*UNA S12T3A/0 S14UTI1NS

#

S14UTI1NS  

rm • •

Sntax: r" <option <!lena"e rm command comman d remove 9 9les les 'rom ' rom current director! director! /m command cant remove directories!

S/00 NI*UNA S12T3A/0

#

S14UTI1NS

#;

 

"c •

Sntax: %c

<option "c command displas <!lena"e num&er o' ne" lines, "ords and Num&er o' &tes 'rom 9le!

S/00 NI*UNA S12T3A/0

Cont!!

S14UTI1NS

#$

 

"c

S/00 NI*UNA S12T3A/0

Cont!!

S14UTI1NS  

"c

S/00 NI*UNA S12T3A/0

><

S14UTI1NS  

"c Bl 9lenameD

S/00 NI*UNA S12T3A/0

>#

S14UTI1NS

>>

 

sort •

Sntax: sort <!lena"e Sort command "ill sort the data in 9le &ased on 9rst column!

S/00 NI*UNA S12T3A/0

Cont!!

S14UTI1NS

>?

 

uni7 uni' <!lena"e uni7 command remove the duplicates that are se7uent   present present in a 9le! Sntax:



S/00 NI*UNA S12T3A/0

Cont!!

S14UTI1NS

>.

 

uni7

S/00 NI*UNA S12T3A/0

Cont!!

S14UTI1NS

>8

 

uni7

S/00 NI*UNA S12T3A/0

Cont!!

S14UTI1NS  

p"d Sntax: p%( •

p"d command c ommand displa current director! director!

S/00 NI*UNA S12T3A/0

>%

S14UTI1NS

>

 

chmod chmod command changes the permissions   o' a 9le! •

1rder o' permissions in Unix: O%ner per"issions: Actions the o"ner o' the 9le can per'orm on the 9le! )roup per"issions: A mem&er o' the group that a 9le &elongs to, can per   on the 9le! Other per"issions: 3hat action all other users can per'orm on the 9le! *ermission Ealues: # - 0xecute > - 3rite . - /ead

S/00 NI*UNA S12T3A/0

S14UTI1NS  

chmod   Sntax:

ch"o( <per"issions <!lena"e

S/00 NI*UNA S12T3A/0

>;

S14UTI1NS  

cut   Sntax: cut <option <!lena"e •

cut command to extract portion o' text 'rom a 9le & selecting columns!

S/00 NI*UNA S12T3A/0

>$

S14UTI1NS  

 

grep Sntax: *rep <pattern <!le na"e

grep command search 'or a pattern   in a 9le and print! •

S/00 NI*UNA S12T3A/0

?<

S14UTI1NS  

head   Sntax: hea( <option <!le na"e •

head command displas top #< lines o' 9le!

S/00 NI*UNA S12T3A/0

?#

S14UTI1NS

?>

 

tail   Sntax: tail <option <!le na"e •

tail command displas &ottom #< lines o' 9le!

S/00 NI*UNA S12T3A/0

S14UTI1NS

??

 

head ( tail   Sntax:

hea( <option <!le na"e+tail <option

S/00 NI*UNA S12T3A/0

S14UTI1NS  

mkdir   Sntax: •

",(ir <(irector- na"e

mkdir command is used to create directories! directories!

S/00 NI*UNA S12T3A/0

?.

S14UTI1NS  

rmdir   Sntax: •

r"(ir <(irector- na"e

rmdir command is used to remove directories!

S/00 NI*UNA S12T3A/0

?8

S14UTI1NS

?%

 

cd   Sntax: •

c( <(irector- na"e

cd command is used to move to other directories! directories!

S/00 NI*UNA S12T3A/0

S/00 NI*UNA S12T3A/0 S14UTI1NS  

du   Sntax: •

(u

du command gives disk usage details!

?

S/00 NI*UNA S12T3A/0 S14UTI1NS  

du -h   Sntax:

(u .h

du Bh command gives disk usage details in   human understanda&le 'ormat! •

?;

S/00 NI*UNA S12T3A/0 S14UTI1NS  

d'    Sntax: •

(/ 

d' command gives space availa&ilit on disk!

?$

S/00 NI*UNA S12T3A/0 S14UTI1NS

.<

 

d' -h   Sntax:

(/ .h

d' -h command gives space availa&ilit on disk in   human understanda&le language! •

S/00 NI*UNA S12T3A/0 S14UTI1NS  

ps   Sntax:

ps

ps command gives all a ll processes details that are   currentl runni running! ng! •

.#

S/00 NI*UNA S12T3A/0 S14UTI1NS

.>

 

ps -e'    Sntax:

ps .e/ 

ps Be' command gives all processes details that ar   currentl currentl running along "ith user name! •

S/00 NI*UNA S12T3A/0 S14UTI1NS

.?

 

kill   Sntax: •

,ill <option <process i(

kill command kills the process running "ith given i

S/00 NI*UNA S12T3A/0 S14UTI1NS  

date   Sntax: •

(ate

date command displas current current date!

..

S/00 NI*UNA S12T3A/0 S14UTI1NS

.8

 

sed   Sntax:

se( <operation !lena"e

sed stands 'or stream editor! sed command is used   to modi' data in 9les automaticall automa ticall!! •

S/00 NI*UNA S12T3A/0 S14UTI1NS  

sed   Sntax:

se( <operation !lena"e

.%

S/00 NI*UNA S12T3A/0 S14UTI1NS

.

 

sed   Sntax: •

  •

 

se( <operation !lena"e

se( 0s1In/or"atica1In/or"atica2 0s1In/or"atica1In/or"atica21$0 1$0 !le3t4t Replaces the secon( occurrence o/ the %or(3 se( 0s1In/or"atica1In/or"atica2 0s1In/or"atica1In/or"atica21*0 1*0 !le3t4t

Replace all the occurrence o/ the pattern in a l

S/00 NI*UNA S12T3A/0 S14UTI1NS

.;

 

nohup   Sntax: •

nohup <options 5

nohup stands 'or no hang up! nohup is used to run the process even a'ter logout 'rom a shell!



F nohup sh custom-script!sh (



F nohup sh custom-script!sh D custom-out!log (

S/00 NI*UNA S12T3A/0 S14UTI1NS

.$

 

"ho am i   Sntax: •

 

%ho a" i

"ho am I gives the details o' current user "ho is logged into the UNIX machine!

S/00 NI*UNA S12T3A/0 S14UTI1NS

8<

 

man

"an command nameD man command displas the manual 'or given comman

  Sntax: •

S/00 NI*UNA S12T3A/0 S14UTI1NS

8#

 

9nd !n( <location to search <t-pe to search <& 9nd command displas the location o' given 9le!

 Sntax:

S/00 NI*UNA S12T3A/0 S14UTI1NS  

 The vi editor editor •



Stands 'or 6isual E(itor! Godes o' operation - Command mode - Insert mode - The ex command mode

8>

S/00 NI*UNA S12T3 S12T3A/0 A/0 S14UTI1NS  

 The vi editor editor

8?

S/00 NI*UNA S12T3A/0 S14UTI1NS  

 The vi editor editor

8.

S/00 NI*UNA S12T3A/0 S14UTI1NS  

 The vi editor editor

88

S/00 NI*UNA S12T3A/0 S14UTI1NS  

editor - commands  The vi editor HH B "rite &uer to 9le and 7uit :"7 - "rite &uer to 9le and 7uit :7J B Kuit the editor "ithout saving changes to the 9le! :7 B Kuit i' the changes "ritten to 9le!

8%

S/00 NI*UNA S12T3A/0 S14UTI1NS  

Sample script   t   n   e   m   m   c  o

2ollo"ing commands Needs to &e executed

8

S/00 NI*UNA S12T3A/0 S14UTI1NS  

1utput

8;

S/00 NI*UNA S12T3A/0 S14UTI1NS  

Name!sh

1utput:

8$

S/00 NI*UNA S12T3A/0 S14UTI1NS  

e9ning varia&les Earia&le nameLvaria&le value

%<

S/00 NI*UNA S12T3A/0 S14UTI1NS

%#

 

Special varia&les 78 . !lena"e o/ the current cu rrent script3

7n& . Ar*u"ents %ith %hich a script %as in&o,e(397#7$ in&o,e(397#7$ an( so on 7 . Nu"=er o/ ar*u"ents supplie( to a script 7> . All the ar*u"ents are (ou=le 'uote(3 7? . All the ar*u"ents are in(i&i(uall- (ou=le 'uote(3 7@ . E4it status o/ the last co""an( 77 . Process nu"=er o/ the current shell 7 . Process nu"=er o/ the last =ac,*roun( co""an(

S/00 NI*UNA S12T3A/0 S14UTI1NS  

/elational operators -e7 - 07ual to -ne - Not e7ual to -gt - Mreater than -lt - less than -ge - Mreater than or e7ual to -le - 4ess than or e7ual to

%>

S/00 NI*UNA S12T3A/0 S14UTI1NS  

I'!else i'conditionD statementD 9 i'condition D statement D 0lse statement D 9

I'conditionD statementD eli'condition D statementD 0lse

%?

statementD 9

S/00 NI*UNA S12T3A/0 S14UTI1NS  

I'!else OJ6&in6sh aL#< &L>< i' P Fa LL F& Q then   echo Ra is e7ual to &R 9 i' P Fa JL F& Q then   echo Ra is not e7ual

%.

to &R 9

 

Sntaxes Some Sntax es •

case!!!esac

"hile command# do   Statements •

  "hile command>   do   Statements done   Statements done

S/00 NI*UNA S12T3A/0 S14UTI1NS

%8

S/00 NI*UNA S12T3A/0 S14UTI1NS  

pmcmd Sntax OJ6usr6&in6&ash pmcmd start"orko" -sv FINTVSEC -d FIN2AV1GAI FIN2AV1GAIN N -u FIN2AVUS0/I FIN2AVUS0/I  -p FIN2AV*3 -' FIN2AV2140/ FIN2AV2140/ -" F31/52413VNAG0

%%

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close