A8-r3

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View A8-r3 as PDF for free.

More details

  • Words: 3,657
  • Pages: 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 A) B) C) D)

Which one of the following is used to replace a single character in “vi”? O x r N

1.2 A) B) C) D)

Which one of the following lets you know the line number of the current cursor position in “vi” ? g <shift> g h h

1.3 A) B) C) D)

The available disk space can be determined under Unix using the command dir df du file

1.4 A) B) C) D)

“init” run-level for system shutdown is: 3 2 1 0

1.5 A) B) C) D)

Which one of the following is a multipurpose tool? grep sed awk editor

1.6 A)

Shell is: Interactive command interpreter

B) C) D)

Programming language Both A) and B) None of the above

1.7 A) B) C) D)

Which one is an “awk” built-in variable NFS RF OFS None of the above

1.8 A) B) C) D)

Which of the following keys when pressed will generate a shell signal? <shift> a <del? a <del>

1.9 A) B) C) D)

State of a process changes from “run” to “ready” when: Time slice expires Waiting for disk read occurs Waiting for user response occurs All of the above

1.10 A) B) C) D)

A new process executes in Unix by the following command: execute ( ) exec ( ) exct ( ) 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 2.2 2.3 2.4

In “vi” A appends text at the end of line. In “vi” cc changes a line. A shell is a user interface. i-node is a unix command.

2.5 2.6 2.7 2.8 2.9 2.10

awk is only a command. passwd asks for the old password to every category of users. init run level 3 is a full multi-user mode. init startup file is /etc/initd. forkp ( ) is used to create a process in Unix. 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

3.1

~

A.

Y 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

J.

HOME

K.

Domain Name Service

L.

FTP

M.

Client server protocol

N.

WWW

O.

An Internet protocol for transmission of data

P.

Daemon

3.10 Request − reply protocol

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) B. trap

C. telnet

D. nice G. i-node J. startx

E. awk H. magic-no K. in-core inode

F. I. L.

M. command P. exec

N. a.out Q. PCB

O. unmask R. command

A.

sleep

head getty wait

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)

b)

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”? What do the following commands in “vi” specify? How are they used? i) map ii) ?pat iii) set iv) ab

(9+6) 6. a) b) c)

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

7. a) b) c) d)

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

8. a) b) c) d) 9. a) b)

What type of variables are PATH and HOME? Why are they called variables? In what ways are they used? What is sed? What are the advantages of cpio over tar? How a client-server environment is created in X? What is xterm? (6+4+3+2) Write a script to check whether right number of arguments (say, 4) have been entered. Consider the following table:

Employee Id 2256 2334 2987 3214

c) d)

Name A. SINHA R. KUMAR B. ROY M. PRAKASH

Designation Manager Sp. Officer Director Manager

Department Sales Accounts Personnel R&D

Date of birth 01/01/50 02/12/60 03/02/58 04/06/70

Salary 12000 16000 20000 12500

Using awk find the employees who are either born in 1996 or drawing a salary greater than 12000/What is grep used for? What are its various options? Give the syntax for the command. 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 A) B)

Which one of the following commands changes or assigns an inode number to file? cp mv

C) D)

chmod chgrp

1.2 A) B) C) D)

In which of the following case cmd2 does not start running until cmd1 has finished? cmd1 | cmd2 cmd1 ; cmd2 cmd1 & cmd2 cmd1 # cmd2

1.3 A) B) C) D)

The command grep ‘^Form” myfile displays those lines that begin with From. displays those lines that end with From. displays those lines that do not contain From. displays those lines that contain more than one instance of From.

1.4 A) B) C) D)

Consider the following code segment : x=10 y=20 The command to display the product of x and y is expr $x * $y expr $x \* $y echo $x * $y echo $x \* $y

1.5 A) B) C) D)

Which of the following is not a layer in TCP/IP Application layer Transport layer Internet layer Presentation layer

1.6 A) B) C) D)

Which of the following is not true for tar command? All the users are permitted to use tar. A tar command can be used to store data on a formatted disk only. A file system must be present on the disk before tar can be used to store data on it. tar can be used to store as well as extract files from a disk.

1.7 A) B) C) D)

The command rm xyz will lead to a dangling link, abc, if it is executed after the command _________. ln –s abc xyz ln –s xyz abc ln abc xyz ln xyz abc

1.8 A) B) C) D)

Which of the following is not a part of the inode for a file? File permissions. File modification time. Inode modification time. Name of the directory to which the file belongs.

1.9 A) B)

Which of the following statement is true for a sticky bit? If the sticky bit for a file is set, then nobody can delete that file. The sticky bit can be set for ordinary files only.

C) D)

A file with sticky bit set, remains in the memory even after execution of that file is over. Every user of the system can set sticky bit on for their files.

1.10 A) B) C)

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

D)

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 2.2

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

2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 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)

3.1

X Order of search for commands

A.

Y 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 3.7

A daemon process To find and display lines in a file that contains a pattern

F. G.

HTTP =

3.8

Remote program execution

H.

PATH

3.9

The command init

I.

view

J.

xhost

K.

view

L.

grep

M.

shell script name

N.

-eq

O.

tar -x

P.

gzip

Q.

HTML

R.

ftp

S. T. U.

chmod == gunzip

3.10 File compression

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. D. G. J.

left to right trap 022 nice

M. sleep P. S. V.

superblock abbr right to left

B. E. H. K.

a.out set prime.out ?

C. F. I. L.

xterm exec startx filename extension

N. wait

O. signal

Q. * T. inode block

R. 644 U. magic number

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 MARKS: 100

TOTAL (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 A) B) C) D)

Implementation of UNIX system is called swapping system, if kernel writes Page of memory to swap device Entire processes to swap device Files to swap device None of the above

1.2 A) B) C) D)

Interrupts happen in the middle of execution of the instruction on execution of operating system instruction between execution of two instructions None of the above

1.3 A) B) C) D)

For copying files from one place to another, we may use utility tar cpio dd None of the above

1.4 A) B) C) D)

Execute permission for file means file may be used as running process copy can be make in order to execute the file read is implied before execution 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) B) C) D)

The current paragraph is deleted The character with cursor and up to the end of paragraph is deleted The character following the cursor and up to ] character is deleted None of the above

1.6 A) B) C) D)

Which of the filter command is used for character translation? tr dd sed grep

1.7 A) B) C) D)

Execution of the program on the remote machine is possible through ftp telnet http None of the above

1.8 A) B) C) D)

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 Widget set X toolkit Window manager None of the above

1.9 A) B) C) D)

Regular expression [^a-zA-Z] means that the first character of the line is letter any character other than a any character that is not the letter None of these

1.10

To search files which has been accessed in last n days is possible though the utility (with appropriate options) find ls awk None of the above

A) B) C) D)

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 2.2

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

2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 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)

3.1

X 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 3.7

The process number of last background command F. The option of sh causing the shell to echo each G. command before its execution with substitution the shell makes

Cntl M Binary format

3.8

A techniques to transfer file from one computer to H. another computer on network Controls access to a X display I.

M

3.9

3.10 To find the lines containing specific word in a file

Y

context

J.

Text format

K.

$!

L.

xhost

M.

grep

N.

-x

O.

4.

A. D. G. J.

$$

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) inode ls links pair of double quote

M. DNS P. DISPLAY S. awk

B. E. H. K.

2dw dw fsmk include

N. www Q. head T. /etc/passwd

C. F. I. L.

is not fsck Pair of single quote export

O. xterm R. /etc/shadow

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) b)

6. a) b) c) 7. a) b)

8. a) b)

Write sequence of vi commands to exchange top three lines with bottom three lines of the screen on the vi session. 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) Write a shell script to display login names of all users who have logged off in last 10 minutes. What is the purpose of having /etc/passwd and /etc/shadow files? Write a shell script to print the system time. (7+4+4) What is motivation for weekly or monthly backup? Explain tar utility with examples. 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) 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? 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) b)

Explain the booting process of Unix system. Describe the data structures associated with processes. How are these affected by exec, form and exit system calls. (9+6)