Vous êtes sur la page 1sur 16

A8-R3: BASICS OF OS, UNIX AND SHELL PROGRAMMING

January 2006

TOTAL TIME: 3 HOURS TOTAL MARKS: 100


(PART ONE-40; PART TWO – 60)

PART ONE
(Answer all the questions)

1. Each question below gives a multiple choice of answers. Choose the most appropriate
one and enter in the “tear-off” answer sheet attached to the question paper, following
instructions therein. (1 x 10)

1.1 Which one of the following is used to replace a single character in “vi”?
A) O
B) x
C) r
D) N

1.2 Which one of the following lets you know the line number of the current cursor position in “vi”
?
A) <ctrl> g
B) <ctrl> <shift> g
C) <ctrl> <alt> h
D) <ctrl> h

1.3 The available disk space can be determined under Unix using the command
A) dir
B) df
C) du
D) file

1.4 “init” run-level for system shutdown is:


A) 3
B) 2
C) 1
D) 0

1.5 Which one of the following is a multipurpose tool?


A) grep
B) sed
C) awk
D) editor

1.6 Shell is:


A) Interactive command interpreter
B) Programming language
C) Both A) and B)
D) None of the above

1.7 Which one is an “awk” built-in variable


A) NFS
B) RF
C) OFS
D) None of the above

1.8 Which of the following keys when pressed will generate a shell signal?
A) <shift> <ctrl> a
B) <del?
C) <ctrl> a
D) <ctrl> <del>

1.9 State of a process changes from “run” to “ready” when:


A) Time slice expires
B) Waiting for disk read occurs
C) Waiting for user response occurs
D) All of the above

1.10 A new process executes in Unix by the following command:


A) execute ( )
B) exec ( )
C) exct ( )
D) xcute ( )

2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and
ENTER in the “tear-off” sheet attached to the question paper, following instructions
therein. (1 x 10)

2.1 In “vi” A appends text at the end of line.


2.2 In “vi” cc changes a line.
2.3 A shell is a user interface.
2.4 i-node is a unix command.
2.5 awk is only a command.
2.6 passwd asks for the old password to every category of users.
2.7 init run level 3 is a full multi-user mode.
2.8 init startup file is /etc/initd.
2.9 forkp ( ) is used to create a process in Unix.
2.10 URL provides the location of the content searched for

3. Match words and phrases in column X with the closest related meaning/
word(s)/phrases in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)

X Y
3.1 ~ A. Scheduling process
3.2 File restore B. Encryption of password
3.3 SMTP C. vi
3.4 IP D. HTML
3.5 /etc/shadow E. Toggle case of text in "vi"

3.6 File compression F. grep


3.7 Ipsched G. tar
3.8 DNS H. A mail protocol
3.9 cron I. gzip
3.10 Request − reply protocol J. HOME
K. Domain Name Service
L. FTP
M. Client server protocol
N. WWW
O. An Internet protocol for transmission of data
P. Daemon

4. Each statement below has blank space to fit one of the word(s) or phrases in the list
below. Enter your choice in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)

A. sleep B. trap C. telnet


D. nice E. awk F. head
G. i-node H. magic-no I. getty
J. startx K. in-core inode L. wait
M. command N. a.out O. unmask
P. exec Q. PCB R. command
4.1 _________ can be used to change the default access permission of file.
4.2 Most of the function in “vi” operate in _________ mode.
4.3 To start X server manually _________ command is needed.
4.4 _________ can be single-line programs also.
4.5 init spawns a(n) _________ at every serial port connected to a Terminal.
4.6 The shell built-in command _________ setup a sequence of commands to be executed
when a signal occurs.
4.7 Remote login to a machine can be done via _________ command.
4.8 The _________ command provides output from the beginning of the concerned file.
4.9 _________ contains the necessary information about a process.
4.10 _________ keeps description of an open file.

PART TWO
(Answer any FOUR questions)

5.
a) Using “vi” (i) how do you save your work without leaving the editor?
Using “vi” (ii) how will you write selected lines to a file? Mention all options. Give suitable
examples.
iii) What is “yanking”? What does the “I” operator do in “vi”?
b) What do the following commands in “vi” specify? How are they used?
i) map
ii) ?pat
iii) set
iv) ab
(9+6)

6.
a) What are the advantages of having distinct disk partitions?
b) What are the components of every file system?
c) How does kernel access a file?
(5+5+5)

7.
a) How does the “login:” prompt appear?
b) What is the use of sticky bit?
c) How does cron work?
d) What does shell’s & operator do?
(4+4+5+2)

8.
a) What type of variables are PATH and HOME? Why are they called variables? In what ways
are they used? What is sed?
b) What are the advantages of cpio over tar?
c) How a client-server environment is created in X?
d) What is xterm?
(6+4+3+2)

9.
a) Write a script to check whether right number of arguments (say, 4) have been entered.
b) Consider the following table:

Employee Id Name Designation Department Date of birth Salary


2256 A. SINHA Manager Sales 01/01/50 12000
2334 R. KUMAR Sp. Officer Accounts 02/12/60 16000
2987 B. ROY Director Personnel 03/02/58 20000
3214 M. PRAKASH Manager R&D 04/06/70 12500

Using awk find the employees who are either born in 1996 or drawing a salary greater than
12000/-
c) What is grep used for? What are its various options? Give the syntax for the command.
d) What is the purpose of nice command?

JULY 2004

TOTAL TIME: 3 HOURS TOTAL MARKS: 100


(PART ONE-40; PART TWO – 60)

PART ONE
(Answer all the questions)

1. Each question below gives a multiple choice of answers. Choose the most appropriate
one and enter in the “tear-off” answer sheet attached to the question paper, following
instructions therein. (1 x 10)

1.1 Which one of the following commands changes or assigns an inode number to file?
A) cp
B) mv
C) chmod
D) chgrp

1.2 In which of the following case cmd2 does not start running until cmd1 has finished?
A) cmd1 | cmd2
B) cmd1 ; cmd2
C) cmd1 & cmd2
D) cmd1 # cmd2

1.3 The command grep ‘^Form” myfile


A) displays those lines that begin with From.
B) displays those lines that end with From.
C) displays those lines that do not contain From.
D) displays those lines that contain more than one instance of From.

1.4 Consider the following code segment :


x=10 y=20
The command to display the product of x and y is
A) expr $x * $y
B) expr $x \* $y
C) echo $x * $y
D) echo $x \* $y

1.5 Which of the following is not a layer in TCP/IP


A) Application layer
B) Transport layer
C) Internet layer
D) Presentation layer

1.6 Which of the following is not true for tar command?


A) All the users are permitted to use tar.
B) A tar command can be used to store data on a formatted disk only.
C) A file system must be present on the disk before tar can be used to store data on it.
D) tar can be used to store as well as extract files from a disk.

1.7 The command rm xyz will lead to a dangling link, abc, if it is executed after the command
_________.
A) ln –s abc xyz
B) ln –s xyz abc
C) ln abc xyz
D) ln xyz abc

1.8 Which of the following is not a part of the inode for a file?
A) File permissions.
B) File modification time.
C) Inode modification time.
D) Name of the directory to which the file belongs.

1.9 Which of the following statement is true for a sticky bit?


A) If the sticky bit for a file is set, then nobody can delete that file.
B) The sticky bit can be set for ordinary files only.
C) A file with sticky bit set, remains in the memory even after execution of that file is over.
D) Every user of the system can set sticky bit on for their files.

1.10 Which of the following entries are always present in a directory file?
A) One entry that refers to the root directory and one that refers to the parent directory.
B) One entry that refers to the directory itself and one that refers to the parent directory.
C) One entry that refers to the home directory of the user and one that refers to the parent
directory.
D) One entry that refers to the root directory and one that refers to the home directory of the
user.

2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and
ENTER in the “tear-off” sheet attached to the question paper, following instructions
therein. (1 x 10)

2.1 The command ls > ls.out will have ls.out in the list of the files displayed.
2.2 If a user have write permission over a directory, then it implies that the user can make
changes to the file using an editor.
2.3 The du command returns the disk utilization only for the user who invokes it.
2.4 The terminal file is a block special file.
2.5 A multiblock file is always allocated contiguous blocks on the disk.
2.6 The command $ <abc >xyz cat is a valid command.
2.7 The tar utility can also be used to backup to a diskette.
2.8 The fsck command stores the names of the unreferenced files in /lost+found.
2.9 The /mnt is the only mount point possible in UNIX system.
2.10 When a user logs out, all the processes started by the user are killed.

3. Match words and phrases in column X with the closest related meaning/
word(s)/phrases in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)

X Y
3.1 Order of search for commands A. WWW
3.2 Hidden file B. /ect/inittab
3.3 Equality operator for integers C. corn
3.4 Protocol for transfer of hypertext D. .
3.5 Read only mode E. HOME
3.6 A daemon process F. HTTP
3.7 To find and display lines in a file that contains a pattern G. =
3.8 Remote program execution H. PATH
3.9 The command init I. view
3.10 File compression J. xhost
K. view
L. grep
M. shell script name
N. -eq
O. tar -x
P. gzip
Q. HTML
R. ftp
S. chmod
T. ==
U. gunzip

4. Each statement below has blank space to fit one of the word(s) or phrases in the list
below. Enter your choice in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)

A. left to right B. a.out C. xterm


D. trap E. set F. exec
G. 022 H. prime.out I. startx
J. nice K. ? L. filename extension
M. sleep N. wait O. signal
P. superblock Q. * R. 644
S. abbr T. inode block U. magic number
V. right to left

4.1 The _________ command is used to change the priority of running process.

4.2 If the system default permissions for an ordinary file in 666 and the umask value is 022, then
permissions for the file, a, created by the command cat > a is _________.

4.3 The command cc prime.c generates _________ as the executable file.

4.4 A fully qualified domain name (FQDN) is resolved in _________ order by Domain Name
Server (DNS).

4.5 The shell Meta character _________ match any string of zero or more characters in file.
4.6 The file command differentiates between the various types of files on the basis of
_________.

4.7 The list and the number of free inode blocks available in the system is stored in _________.

4.8 The system call that stops parent process and let it resume on termination of child process is
_________.

4.9 Unix command to specify what to do upon receipt of a signal is _________.

4.10 To manually start X server, use _________ on prompt.

PART TWO
(Answer any FOUR questions)

5.
a) Write an awk program, which acts like wc command, i.e., reports the number of lines, words
and characters in every file passed to it as command line argument.
b) How are the pointers to the data blocks of a file stored in its inode? Show diagrammatically
also.
(8+7)

6.
a) Differentiate between the following
i) A system call, a library function and a UNIX command.
ii) /etc/passwd and /etc/shadow
iii) User mode and kernel mode in UNIX.
(9+6)

7.
a) What will be the output of the following codes? Also explain the reason for it.
for j in a b c d e f
do
echo $ > f1
done

and
for j in a b c d e f
do
echo $j
done > f2
b) Write a shell script to read a name and display whether that person is authorized to use the
system or not. If the person is authorized, then display whether that person is currently
logged in or not.
c) List the three standard file types available in UNIX. Which standard file type is redirected
when the following shell metacharacter(s) is used in the commands: - <, >, >>, 2> and |
(pipe)?
(5+5+5)

8.
a) What is a URL? What are its various components?
b) What is setuid bit? How does it work and what is its importance?
c) What are system run-levels in Unix? How can run-level be changed from command line?
(5+5+5)

9.
a) What is the difference between internal and external commands available in UNIX? Is it
possible to create a shell script with the same name as a UNIX command? On giving that
name on the prompt, what will be executed - command or the shell script. Explain w.r.t. both
internal and external commands.
b) Write the commands or shell scripts to do the following
i) list all the ordinary files with names starting with a vowel and present in the tree
structure from the HOME directory downwards.
ii) given a file, f1 with record format as
RollNo Name Mark
(Alphanumeric field) (Alphabetic field) (Numeric field)
Sort f1 on the basic of Marks and store the result in f1.out
iii) extract the name and phone fields from a file, f2 with the record format as
Name:Age:Address:Phone
Display the data on the screen
iv) to display the list of last 10 files present in the current directory.
(7+8)
January 2004

TOTAL TIME: 3 HOURS TOTAL


MARKS: 100
(PART ONE-40; PART
TWO – 60)

PART ONE
(Answer all the questions)

1. Each question below gives a multiple choice of answers. Choose the most
appropriate one and enter in the “tear-off” answer sheet attached to the
question paper, following instructions therein.
(1 x 10)

1.1 Implementation of UNIX system is called swapping system, if kernel writes


A) Page of memory to swap device
B) Entire processes to swap device
C) Files to swap device
D) None of the above

1.2 Interrupts happen


A) in the middle of execution of the instruction
B) on execution of operating system instruction
C) between execution of two instructions
D) None of the above

1.3 For copying files from one place to another, we may use utility
A) tar
B) cpio
C) dd
D) None of the above

1.4 Execute permission for file means


A) file may be used as running process
B) copy can be make in order to execute the file
C) read is implied before execution
D) None of the above

1.5 In vi, suppose pressing the character ] takes the cursor to next paragraph. If we give
the command d], the
A) The current paragraph is deleted
B) The character with cursor and up to the end of paragraph is deleted
C) The character following the cursor and up to ] character is deleted
D) None of the above

1.6 Which of the filter command is used for character translation?


A) tr
B) dd
C) sed
D) grep

1.7 Execution of the program on the remote machine is possible through


A) ftp
B) telnet
C) http
D) None of the above

1.8 Application programmers in X Windows environment quickly build sophisticated


interface to their programs and enforce a uniform look and feel to all part of GUI by
using
A) Widget set
B) X toolkit
C) Window manager
D) None of the above

1.9 Regular expression [^a-zA-Z] means that


A) the first character of the line is letter
B) any character other than a
C) any character that is not the letter
D) None of these

1.10 To search files which has been accessed in last n days is possible though the utility
(with appropriate options)
A) find
B) ls
C) awk
D) None of the above
2. Each statement below is either TRUE or FALSE. Choose the most appropriate
one and ENTER in the “tear-off” sheet attached to the question paper,
following instructions therein.
(1 x 10)

2.1 UNIX kernel provides its services transparently.


2.2 In UNIX system, mapping of virtual address to physical address is machine
independent.
2.3 Inode specifies the pathname, which accesses the file.
2.4 Every directory contains at least two filenames.
2.5 Kernel may allow the mounting the same file system again.
2.6 The sticky bit is only set by super user.
2.7 $* and $@ are same.
2.8 http is the specification language to construct web pages.
2.9 Ping command is used to test the connecting of network.
2.10 Tk widget set and Motif widget set both give similar look and feel to the X Windows
application.

3. Match words and phrases in column X with the closest related meaning/
word(s)/phrases in column Y. Enter your selection in the “tear-off” answer
sheet attached to the question paper, following instructions therein.
(1 x 10)

X Y
3.1 Execution of the system call A. find
3.2 Frozen image of what process is doing B. FIFO (pipes)
3.3 File type C. User mode
3.4 Storing directory file D. Kernel mode
3.5 Moving cursor to middle line in screen window in vi E. ftp
3.6 The process number of last background command F. Cntl M
3.7 The option of sh causing the shell to echo each G. Binary format
command before its execution with substitution the
shell makes
3.8 A techniques to transfer file from one computer to H. M
another computer on network
3.9 Controls access to a X display I. context
3.10 To find the lines containing specific word in a file J. Text format
K. $!
L. xhost
M. grep
N. -x
O. $$

4. Each statement below has blank space to fit one of the word(s) or phrases in
the list below. Enter your choice in the “tear-off” answer sheet attached to the
question paper, following instructions therein.
(1 x 10)

A. inode B. 2dw C. is not


D. ls E. dw F. fsck
G. links H. fsmk I. Pair of single quote
J. pair of double quote K. include L. export
M. DNS N. www O. xterm
P. DISPLAY Q. head R. /etc/shadow
S. awk T. /etc/passwd

4.1 The kernel _______ a separate set of processes, which run parallel to user process.

4.2 Number of _______ to the file represents the number of names the file has in the
directory hierarchy.

4.3 Reclaiming unlinked disk blocks is done by _______ program.

4.4 In vi, to delete 12.357 we give _______ command.

4.5 _______ negates special properties of all enclosed character in UNIX.

4.6 A variable can be make the part of environment of current shell and of all processes
(including shell script) descending from it, by using _______ command.

4.7 Conversion of domain name to an IP address is done by _______.

4.8 Applications use the value _______ variable to determine which display, keyboard
and mouse to use.

4.9 _______ utility displays the beginning of the file.

4.10 All encrypted passwords are kept in the file _______.


PART TWO
(Answer any FOUR questions)

5.
a) Write sequence of vi commands to exchange top three lines with bottom three lines
of the screen on the vi session.
b) Write a shell script, which asks user to enter the login name. If the name is not in the
“LOGFILE”, display “Sorry! You cannot work.”, otherwise ask for password. The
password in not echoed. Check the password with the “PASSWORD”. If it is not
there display “ACCESS DENIED”.
(7+8)

6.
a) Write a shell script to display login names of all users who have logged off in last 10
minutes.
b) What is the purpose of having /etc/passwd and /etc/shadow files?
c) Write a shell script to print the system time.
(7+4+4)

7.
a) What is motivation for weekly or monthly backup? Explain tar utility with examples.
b) Write the shell script to add a new user in password file /etc/passwd with the
following details:
- group name ‘india’
- log in name ‘guru’
- user name ‘Ramauli of Vindhyachal’
- file system ‘/selected’
(9+6)

8.
a) What is the design principle of X windows? Describe system architecture and
Window manager of X Windows. What is X-toolkits? What does it contain?
b) What is IP address? Explain its construction. Calculate the maximum possible
numbers of class A, class B and class C networks, which can be addressed by IP
scheme.
(9+6)
9.
a) Explain the booting process of Unix system.
b) Describe the data structures associated with processes. How are these affected by
exec, form and exit system calls.
(9+6)

Vous aimerez peut-être aussi