unix(tb)

3
Subject: UNIX & Shell Programming Subject Code: BSIT-43  !!ignment: TB 1. Wha t is a shell? Ex pla in its import anc e.  Ans.:-  A shell is a program which is run every time a user logs i n and is known as a command interpreter. All the commands entered are run by the shell. he prompt that appears when a user logs in is a shell and waits !or the user to enter a  command. When a command is entered" the shell scans the command line !or met characters" i.e." characters that have a special meaning to the shell. A!ter processing the met characters" the shells send the command line to the kernel !or execution. he shell waits !or the kernel to complete execution and then display the prompt !or the next command. his interpretive cycle continues !or the next command. #. Write a $%&' command to count how many users have logged on to the $%&' system.  Ans :- Who (ommand to count how many users have logged on to the $%&' system.  )ists the user*s name" terminal line and login date and time + Who ,ibns ttyp ec #/ 10:/ ysr ttyp1 ec #/ 10:21  3cepay ttyp# ec #/ 10:24 )ists only the names and number o! users logged in + Who 56 ,ibns !ysr 7cepay 8 $sers90 0. ow is a 7ob run pe riodically in $%&' s ystem? Explain with an example.  Ans :-  A task can be automatically run in the background at regular intervals by a $%&' utility called cron. he cron daemon takes care o! running these background 7obs" which are called 7ob run periodically. Example he !ollowing line in the crontab !ile removes all core !iles;users;users1 everyday at <:0 =>. 0 1/ rm;user;user1;core

Upload: rachit-khandelwal

Post on 04-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

8/13/2019 Unix(TB)

http://slidepdf.com/reader/full/unixtb 1/3

Subject: UNIX & Shell ProgrammingSubject Code: BSIT-43

  !!ignment: TB

1. What is a shell? Explain its importance.

 Ans.:- A shell is a program which is run every time a user logs in and is knownas a command interpreter. All the commands entered are run by the shell. heprompt that appears when a user logs in is a shell and waits !or the user to enter a

  command. When a command is entered" the shell scans the command line !or metcharacters" i.e." characters that have a special meaning to the shell. A!terprocessing the met characters" the shells send the command line to the kernel !orexecution. he shell waits !or the kernel to complete execution and then displaythe prompt !or the next command. his interpretive cycle continues !or the nextcommand.

#. Write a $%&' command to count how many users have logged on to the $%&'system.

 Ans :-Who (ommand to count how many users have logged on to the $%&' system.

  )ists the user*s name" terminal line and login date and time

+ Who,ibns ttyp ec #/ 10:/ysr ttyp1 ec #/ 10:21

  3cepay ttyp# ec #/ 10:24

)ists only the names and number o! users logged in

+ Who 56

,ibns !ysr 7cepay

8 $sers90

0. ow is a 7ob run periodically in $%&' system? Explain with an example.

 Ans :-  A task can be automatically run in the background at regular intervals by a $%&'

utility called cron. he cron daemon takes care o! running these background 7obs"which are called 7ob run periodically.

Examplehe !ollowing line in the crontab !ile removes all core !iles;users;users1 everydayat <:0 =>.

0 1/ rm;user;user1;core

8/13/2019 Unix(TB)

http://slidepdf.com/reader/full/unixtb 2/3

4. What is a process? Explain the mechanism o! process (reation in $%&' system.

 Ans :-

 A process in $%&' is an executing program" which is identi!ied by a uni6ue =& or

a process identi!ier. A !ile is a collection o! data created by a user using !eatures"such as text editor and compilers"

2. What is a !ilter? Explain any !ive !ilters in $%&' system.

 Ans.:-

 A !ilter is a program that takes its input !rom the standard input !ile" processes

@or !ilters it" and sends its output to the standard output !ile. $%&' has a rich set

o! !ilters that can be used to work on data in an e!!ective way. ,ome examples o!

!ilters are cat" grep" wc" tr" and cut.

 

B. Write a shell script to check whether given year is a leap year or not.

 Ans :-

he !ollowing command can be used to !ind whether the year 1/ is a leap year

or not :  + (al # 1/ as the output is showing #C days in ebruary" 1/ was not a

leap year .

<. Explain the di!!erent types o! variables in shell.

 Ans :-

here are three types o! variables commonly used in shell.

1 Environment Dariables: ,ometimes called special shell variables" keywordvariables" prede!ined shell variables" or standard shell variables" they are used totailor the operating environment to suit your needs. Examples =A" E>"F>E" and >A&).

# $ser-de!ined Dariables: hese are variables that you create yoursel!.

0 =ositional =arameters: hese are used by the shell to store the values o!

command-line arguments.

8/13/2019 Unix(TB)

http://slidepdf.com/reader/full/unixtb 3/3

C. What is the signi!icance o! write and talk command in $%&'.

 Ans.

he write command copies the text !rom one user terminal to the terminal o!another user who is also logged on the $%&' operating system. he recipient canreply the sender by writing on his terminal and communication starts between thetwo users. he (ommunication continues until an end-o!-!ile is read !rom the

terminal or an interrupt is sent. he talk command is a visual communicationprogram that copies lines !rom a user terminal to the terminal o! another user. hetalk command splits the user terminal into two sections. he upper section is usedby the sender to write messages and the lower section displays the receivedmessages.