Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

RGPV Diploma: Linux Unit 4

RGPV Diploma: Linux: Unit 4

 

Q1. शैल को परिभाषित किजिये ?

Or

शैल क्या है? किस प्रकार से यह kernel से भिन्न है, समझाइये ?

OR

शैल को समझाइये ?

OR

Linux मे उपलब्ध विभिन्न प्रकार के शैल को सम्झाइये ?

OR

शैल क्या है? शैल kernel से किस प्रकार से भिन्न है? शैल कि उप्योगिता को सम्झाइये।

OR

विभिन्न प्रकार के शैल को सम्झाइये एव्म उनके बिच तुलना किजिये।

OR

Bash शैल क्या है? और इसके features को विश्तारपूर्वक सम्झाइये।

OR

विभिन्न प्रकार के शैल क्या है? उन्हे सम्झाइये?

OR

Bash शैल पर संक्षिप्त टिप्पणी लिखिये?

OR

Linux शैल को समझाइये ?

Ans. Definition:

शैल को user एवम्‌ computer के मध्या एक interface के रुप मे जाना जाता हैं |

Command line पर जो command लिखते है, शैल उस command कि व्याख्या करता है और operating system कि और प्रेषित करता है।

Uses of शैल :

शैल के उपयोग निम्नलिखित है-

<![if !supportLists]> (i)       <![endif]> शैल का उपयोग user और kernel के मध्य interface का कार्य करने के लिये होता है।

<![if !supportLists]> (ii)      <![endif]> शैल का उपयोग command को process कराने के लिए होता है।

<![if !supportLists]> (iii)      <![endif]> शैल का उपयोग शैल स्क्रिप्ट बनाने के लिये किया जाता है।

Difference between शैल and kernel :-

Kernel एवम्‌ शैल के बिच अंतर निम्नलिखित है-

 

कर्नल

शैल

1

कर्नल, Linux मे multioperating system कि तरह होता है जो एक हि समय मे हज़ारो users को support करता है।

शैल एक programming language है जिसमे user script लिखकर function को execute करता है।

2

कर्नल hardware और program के मध्य interface क कार्य करता है।

शैल user और कर्नल के मध्य interface का कार्य करता है।

3

कर्नल linux system architecture मे दुसरे नंबर कि layer है।

शैल linux system architecture कि तिसरे नंबर कि layer है।

4

Users के द्वारा लिखे गये programs के समस्त communication केवल कर्नल के माध्यम से हि सम्भव होते है।

यह user द्वारा दि जाने वालि commands कि व्याख्या करता है और फिर उन commands को execute किया गया है या नहि, यह देखने के लिए कर्नल के साथ communicate करता है।

 

Different types of शैल इन linux :

Linux मे विभिन्न प्रकार के शैल होते है, कुछ सेर्वाधिक use होने वाले निम्नलिखित है-

<![if !supportLists]> (i)            <![endif]> Bourne Shell –

<![if !supportLists]> ·         <![endif]> इसके द्वारा command कि तरह script को भी उनके filename के द्वारा invoke किया जा सकता है।

<![if !supportLists]> ·         <![endif]> इस शैल को interactive अथवा non-interactive रूप में प्रयोग कर सकते है|

<![if !supportLists]> ·         <![endif]> यह शैल command के synchronous और asynchronous दोनो प्रकार से execution कि अनुमति देता है।

<![if !supportLists]> ·         <![endif]> यह शैल input एवम्‌ output redirection तथा pipelines को support करता है।

<![if !supportLists]> ·         <![endif]> यह शैल बिना data type के variables को support करता है।

<![if !supportLists]> ·         <![endif]> यह local एवम्‌ global variables को scope प्रदान करता है।

 

<![if !supportLists]> (ii)      <![endif]> Bourne Again Shell / Bash Shell –

<![if !supportLists]> ·         <![endif]> External process को create किए बिना हि bash शैल integer calculation कर सकता है।

<![if !supportLists]> ·         <![endif]> Input और output redirection syntax को sh कि अपेक्षा bash शैल मे अधिक आसान किया ग्या है।

<![if !supportLists]> ·         <![endif]> Bash शैल मे अनेक start-up scripts होति है, जो bash शैल को प्रारंभ करने पर हि execute कि जाति है।

<![if !supportLists]> ·         <![endif]> Bash शैल विभिन्न keyboard shortcuts को support करता है।

 

<![if !supportLists]> (iii)      <![endif]> C Shell –

<![if !supportLists]> ·         <![endif]> यह input / output redirection को support करता है।

<![if !supportLists]> ·         <![endif]> यह शैल पाइपिंग feature को support करता है।

<![if !supportLists]> ·         <![endif]> यह variables के लिए support करता है।

<![if !supportLists]> ·         <![endif]> इस शैल मे condition testing और looping के लिए structures को control करने हेतु support करता है।

 

विभिन्न प्रकार कि शैल के बिच तुलना-

 

बॉर्न शैल

बेश शैल

C शैल

1

इसे स्टीफन बॉर्न ने बनाया था।

इसे ब्रायन फौक्स ने बनाया था ।

इसे बिल जॉय ने बनाया था।

2

इसके लिए sh command का प्रयोग करते है। 

इसके लिए bash command का प्रयोग करते है। 

इसके लिए csh command का प्रयोग करते है। 

3

इसे 1977 मे बनाया गया था।

इसे 1987 मे बनाया गया था।

इसे 1970 मे बनाया गया था।

 

Q2. शैल स्क्रिप्ट पर संक्षिप्त टिप्पणी लिखिये?

OR

शैल variables पर संक्षिप्त टिप्पणी लिखिये?

OR

Linux के शैल variable और पाइप को सम्झाइये? उदाहरण भि दिजिये।

OR

शैल variable को समझाइये?

OR

शैल स्क्रिप्त समझाइये । इसे run करने के लिये command लिखिये ।

OR

शैल variable से आप क्या समझते है? बोर्न तथा c शैल के variables को सम्झाइये?

OR

शैल variable को समझाइये ।

OR

शैल programming पर चर्चा किजिये।

OR

शैल स्क्रिप्त क्या है? उदाहरन सहित समझाइये ?

OR

शैल स्क्रिप्त के creation तथा execution को बताइये।

Ans. Shell Script:

जब किसी फाइल मे linux commands को एकसाथ लिखकर execute किया जाता है तो इस प्रकार से बनि हुइ फाइल को शैल स्क्रिप्ट कहते है।

शैल स्क्रिप्ट मे commands को store किया जाता है।

यह शैल स्क्रिप्ट एक बार मे एक हि command को execute कर सकति है।

शैल स्क्रिप्ट को लिखने के निम्न्लिखित उद्देश्य है:

<![if !supportLists]> (i)       <![endif]> कार्य करने के वातावरन को customize करना। जैसे कि यदि आप current date को देख्ना चाहते है तो प्रत्येक बार login होना पड़ता है। अत: इस समस्त command कि list को स्क्रिप्ट मे लिख दिया जाता है।

<![if !supportLists]> (ii)      <![endif]> प्रत्येक दिन के कार्य को खुद करना, अथार्थ प्रत्येक दिन के कार्य के अंत मे data के backup के लिए command को लिखा जाता है। 

<![if !supportLists]> (iii)      <![endif]> कार्यो को खुद लगातर return करना।

<![if !supportLists]> (iv)      <![endif]> System कि महत्वपूर्ण procedures को execute करना। जैसे कि shutdown , disk formate आदि।

<![if !supportLists]> (v)      <![endif]> विभिन्न फाइलो पर साथ साथ काम करना।

<![if !supportLists]> (vi)      <![endif]> Programming बहुत जटिल हो ।

शैल स्क्रिप्ट का creation –

$vi jayesh

Echo I am jayesh kumar

Ls

इस स्क्रिप्ट मे पहला command echo तथा दुसरा command ls है।

शैल स्क्रिप्ट को execute करना-

शैल स्क्रिप्ट को दो तरह से execute किया जा सकता है-

<![if !supportLists]> (i)       <![endif]> पहलि विधि मे शैल प्रोग्रम sh के साथ execute किया जाता है।

$sh jayesh

<![if !supportLists]> (ii)      <![endif]> दुसरि विधि मे chmod command के साथ पुर्न execution permit जो कि 777 है. देकर रन किया जाता है।

$chmod  777 jayesh

 

शैल variable :

शैल variable information को store करने के काम आता है। जैसे कि किसि का नाम, मोबाइल नंबर store करने के लिये variable कि जरुरत होति है।

<![if !supportLists]> (i)       <![endif]> एक variable क नाम बनाने मे alphabet (a,b,c …..z ), digits(0,1 ……9 ) तथा underscore (‌‌ _ ) का उपयोग किया जा सकता है।

<![if !supportLists]> (ii)      <![endif]> Variable के नाम मे ( , ) तथा खालि जगह नहि होनि चाहिए।

<![if !supportLists]> (iii)      <![endif]> Variable के नाम क प्रथम अक्षर हमेशा alphabet या फिर underscore हि होना चाहिए।

<![if !supportLists]> (iv)      <![endif]> Variable का नाम case sensitive होना चहिए। जैसे कि NAME ,name ,Name , NaMe आदि अलग अलग variable है।

 

Q3. लूप पर संक्षिप्त टिप्पणी लिखिये?

OR

लूपिंग statements को दर्शाने के लिये शैल programming लिखिये।

Ans. एक लुप या लुपिंग का मतलब इसके किसि भाग का लगातार repeat होना है।

लुप निम्नलिखित तिन प्रकार के होते है-

<![if !supportLists]> (i)       <![endif]> For loop

<![if !supportLists]> (ii)      <![endif]> While loop

<![if !supportLists]> (iii)      <![endif]> Until loop

 

<![if !supportLists]> (i)       <![endif]> For loop –

यह लुप अन्य लुपो कि तुलना मे ज्यादा उपयोग किया जाता है। तथा यह ज्यादा तेज होता है।

यह अन्य लुपो से अलग प्रकार से कर्य करता है। इस लुप को निम्नलिखित प्रकार से लिखा जाता है-

for control variable in value1 value2 value3…..

do

   command1

   command2

   command3

done

 

for लुप को निम्नलिखित उदाहरण द्वारा समझाया गया है-

for word in $*

do

   echo $word

done

 

 

<![if !supportLists]> (ii)      <![endif]> While loop :

यह एक आइदियल लुप है, जो कि एक निश्चित समय तक चलता है।

 

उदाहरण –

 

#Calculate the simple interest for 3 sets of p, n and r

count=1

while[$count-le 3]

do

echo”\n enter values of p, n and r \c”

read p n r

si=’echo $p\*$n\*$r/100|bc’

echo simple interest=rs. $si

count=’expr $count+1’

done

 

 

<![if !supportLists]> (iii)      <![endif]> Until loop –

Until लुप निम्नलिखित प्रकार से कार्य करता है-

do

   this

   and this

done

Until लुप के अंदर उपयोग होने वाले स्टेटमेन्ट उस समय तक चलते है जब तक कंडिसन फाल्स रहति है।

उदाहरण –

# prints numbers 1 to 10 using until

i=1

until[$i-gt 10]

do

   echo $i

i=’expr $i+1’

done

 

Q4. Conditional statements को दर्शाने के लिये शैल programming लिखिये।

Ans.

Bash में निम्लिखित कंडीशनल स्टेटमेंट्स है –

 

<![if !supportLists]> 1)      <![endif]> if..then..fi statement (Simple If)

<![if !supportLists]> 2)      <![endif]> if..then..else..fi statement (If-Else)

<![if !supportLists]> 3)      <![endif]> if..elif..else..fi statement (Else If ladder)

<![if !supportLists]> 4)      <![endif]> if..then..else..if..then..fi..fi..(Nested if)

 

<![if !supportLists]> 1)      <![endif]> Bash If..then..fi statement

Syntax:

if [ conditional expression ]

then

            statement1

            statement2

Fi

 

Example:

 

 

 

<![if !supportLists]> 2)      <![endif]> Bash If..then..else..fi statement

 

Syntax:

 

If [ conditional expression ]

then

            statement1

            statement2

else

            statement3

            statement4

Fi

 

Example:

 

<![if !supportLists]> 3)      <![endif]> Bash If..elif..else..fi

 

Syntax:

 

If [ conditional expression1 ]

then

            statement1

            statement2

elif [ conditional expression2 ]

then

            statement3

            statement4

else

            statement5

fi

 

Example:

 

<![if !supportLists]> 4)      <![endif]> Bash If..then..else..if..then..fi..fi..

 

Syntax:

 

If [ conditional expression1 ]

then

            statement1

            statement2

else

            if [ conditional expression2 ]

            then

                        statement3

fi

fi

 

Example:

 

Q5. शैल programming मे parameter किस प्रकार से पास करते है? समझाइये ।

OR

शैल programming मे parameter और agreement को उदाहरण सहित विस्तार से समझाइये ।

Ans. शैल स्क्रिप्ट मे पैरामीटर को पास करने के लिए सर्वप्रथम शैल स्क्रिप्ट क्रिएट करते है| शैल स्क्रिप्ट क्रिएट करने के बाद जब उसे कमांड लाइन पर रन करते है तब सर्वप्रथम स्क्रिप्ट का नेम टाइप करते है एवं उसके बाद जो पैरामीटर पास करने होते है उन्हें टाइप करते है| इसे निम्नलिखित उदाहर्ण द्वारा समझाया गया है-

निचे दिए गए प्रोग्राम में एक शेल स्क्रिप्ट बने गई है|

निचे दिए प्रोग्राम में पहली लाइन में cat कमांड Parameter_pass_shellscript.sh नाम की फाइल को दिखाने का काम कर रही है |

Program: Parameter passing shell script

उपर दिखाए गए प्रोग्राम को जब हम रन करेगे तो निचे वाला आउटपुट दिखाई देगा|

आउटपुट देखने के लिए इस कमांड को चलायेगे-

sh Parameter_pass_shellscript.sh 23 22 20

यहां 23 22 20 इनपुट को है, जो की आउटपुट कमांड के टाइम देना पड़ते है }

$1 में 23 इनपुट गया|

$२ में 22 इनपुट गया|

$३ में 20 इनपुट गया|

Program: Run of Parameter passing shell script

 

 

Q7. Ps command को समझाइये ।

OR

Ps command को option एव्म उचित उदाहरन के साथ समझाइये ?

OR

Ps command का कार्य एव्म syntax लिखिये ।

OR

Process कि listing के लिये किस command का उपयोग किया जात है?

Ans.

Ps कमांड active processes को दिखाती है |

Syntax:

ps कमांड का syntax निम्नलिखित है –

ps [option]

कुछ basic ps कमांड्स निम्नलिखित है –

1`) Displays all processes on a terminal, with the exception of group leaders.

Ps –a

2) Displays scheduler data.

Ps –c

3) Displays all processes with the exception of session leaders.

Ps –d

4) Displays all processes.

Ps –e

5) Displays a full listing.

Ps –f

6) Displays the process group ID and session ID.

Ps –j

7) Displays a long listing

Ps –l

 

Q6. Process management पे संक्षिप्त टिप्पणी लिखिये ।

OR

Process management कि व्याख्या किजिये ।

OR

Process managing पर संक्षिप्त टिप्पणी लिखिये ।  

OR

Linux में process को create करने कि विधियाँ लिखिये।

OR

Process क्या है? Process कि विभिन्न स्टेटस को बताइये?

Ans. एक्जिक्युसन के समय प्रोग्राम को ही प्रोसेस कहा जाता है , अथार्थ जब प्रोग्राम सेकेंडरी मेमोरी से प्राइमरी मेमोरी में आता है तब उसे प्रोसेस कहा जाता है |

प्रोसेस को निम्नलिखित स्टैट्स के द्वारा मैनेज किया जाता है

(i)

 

Q8. Background process पर संक्षिप्त टिप्पणी लिखिये।

OR

पाइप और background process को समझाइये ।

OR

Redirecting input-output और background process को विस्तार से समझाइये ।

OR

Background process से आप क्या समझते है? Logout करने के बाद भि background process किस तरह काम करेगि? सम्झाइये ।

 

 

Q9. Process कि प्राथमिकता पर संक्षिप्त टिप्पणी लिखिये ?

OR

Scheduling प्राथमिकता से आप क्या समझते है ? altering scheduling priority को संक्षेप मे सम्झाइये।

OR

Linux मे process प्राथमिकता किस प्रकार से change कि जाति है? बताइये।

 

Q10. Logged in users कि संख्य प्रदर्शित करने के लिये एक शैल स्क्रिप्त लिखिए ?

OR

Logged in users कि संख्या, user name ,date /type को प्रदर्शित करने के लिये शैल स्क्रिप्त लिखिए?

 

Q11. एक ऐसा शैल program लिखिए जो कि एक string को reverse order मे print करे।

Ans.

read -p “Enter string:” string

 

len=${#string}

 

for (( i=$len-1; i>=0; i– ))

 

do

 

# “${string:$i:1}”extract single single character from string.

 

reverse=”$reverse${string:$i:1}”

 

done

 

echo “$reverse”

 

Q12. लूप क्या है? For लूप कि सहायता से 1 से 10 तक कि c language मे table print किजिये।

Ans.

#include<stdio.h>

#include<conio.h>

void main()

{

int I, j;

for(i=1; i<=10; i++)

{

for (j=1; j<=10; j++)

{

printf(“%d”,i*j);

}

}

}

 
Stay tuned for updates……..