Unix Question

Embed Size (px)

Citation preview

  • 7/27/2019 Unix Question

    1/11

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

    NOTE:

    1. There are TWO PARTS in this Module/paper. PART ONE contains FOUR questions andPART TWO contains FOUR questions.

    2. PART ONE is to be answered in the TEAR-OFFANSWER SHEET only, attached to thequestion paper, as per the instructions contained therein. PART ONE is NOT to beanswered in the answer book.

    3. Maximum time allotted forPART ONE is ONE HOUR. Answer book forPART TWO will besupplied at the table when the answer sheet for PART ONE is returned. However,candidates who complete PART ONE earlier than one hour, can collect the answer book forPART TWO immediately after handing over the answer sheet forPART ONE.

    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, followinginstructions therein. (1 x 10)

    1.1 Which one of the following commands changes or assigns an inode number to file?A) cpB) mvC) chmodD) chgrp

    1.2 In which of the following case cmd2 does not start running until cmd1 has finished?A) cmd1 | cmd2B) cmd1 ; cmd2C) cmd1 & cmd2

    D) cmd1 # cmd2

    1.3 The command grep ^Form myfileA) 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=20The command to display the product of x and y is

    A) expr $x * $yB) expr $x \* $y

    C) echo $x * $yD) echo $x \* $y

    A8-R3 Page 1 of 6 July, 2004

  • 7/27/2019 Unix Question

    2/11

    1.5 Which of the following is not a layer in TCP/IPA) Application layerB) Transport layer C) Internet layer D) Presentation layer

    1.6 Which of the following is not true fortarcommand?A) All the users are permitted to use tar.B) A tarcommand can be used to store data on a formatted disk only.

    C) A file system must be present on the disk before tarcan be used to store data on it.D) tarcan 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 xyzB) ln s xyz abcC) ln abc xyzD) 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 parentdirectory.D) One entry that refers to the root directory and one that refers to the home directory of the

    user.

    A8-R3 Page 2 of 6 July, 2004

  • 7/27/2019 Unix Question

    3/11

    2. Each statement below is either TRUE or FALSE. Choose the most appropriate one andENTER in the tear-off sheet attached to the question paper, following instructionstherein. (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 makechanges 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 $ xyz cat is a valid command.

    2.7 The tarutility 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 sheetattached to the question paper, following instructions therein. (1 x 10)

    X Y3.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. view3.10 File compression J. xhost

    K. view

    L. grep

    M. shell script name

    N. -eq

    O. tar -x

    P. gzip

    Q. HTML

    R. ftpS. chmod

    T. ==

    U. gunzip

    A8-R3 Page 3 of 6 July, 2004

  • 7/27/2019 Unix Question

    4/11

    4. Each statement below has blank space to fit one of the word(s) or phrases in the listbelow. Enter your choice in the tear-off answer sheet attached to the questionpaper, 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. signalP. 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.

    A8-R3 Page 4 of 6 July, 2004

  • 7/27/2019 Unix Question

    5/11

    PART TWO(Answerany FOUR questions)

    5.

    a) Write an awk program, which acts like wc command, i.e., reports the number of lines, wordsand 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 diagrammaticallyalso.

    (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 thesystem or not. If the person is authorized, then display whether that person is currentlylogged in or not.

    c) List the three standard file types available in UNIX. Which standard file type is redirectedwhen 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)

    A8-R3 Page 5 of 6 July, 2004

  • 7/27/2019 Unix Question

    6/11

    9.

    a) What is the difference between internal and external commands available in UNIX? Is itpossible to create a shell script with the same name as a UNIX command? On giving thatname on the prompt, what will be executed - command or the shell script. Explain w.r.t. bothinternal 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 treestructure 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)

    A8-R3 Page 6 of 6 July, 2004

  • 7/27/2019 Unix Question

    7/11

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

    NOTE:

    1. There are TWO PARTS in this Module/paper. PART ONE contains FOUR questions andPART TWO contains FOUR questions.

    2. PART ONE is to be answered in the TEAR-OFFANSWER SHEET only, attached to thequestion paper, as per the instructions contained therein. PART ONE is NOT to beanswered in the answer book.

    3. Maximum time allotted forPART ONE is ONE HOUR. Answer book forPART TWO will besupplied at the table when the answer sheet for PART ONE is returned. However,candidates who complete PART ONE earlier than one hour, can collect the answer book forPART TWO immediately after handing over the answer sheet forPART ONE.

    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, followinginstructions therein. (1 x 10)

    1.1 Implementation of UNIX system is called swapping system, if kernel writesA) Page of memory to swap deviceB) Entire processes to swap deviceC) Files to swap deviceD) None of the above

    1.2 Interrupts happenA) in the middle of execution of the instructionB) on execution of operating system instructionC) between execution of two instructions

    D) None of the above

    1.3 For copying files from one place to another, we may use utilityA) tarB) cpioC) ddD) None of the above

    1.4 Execute permission for file meansA) file may be used as running processB) copy can be make in order to execute the fileC) read is implied before executionD) None of the above

    A8-R3 Page 1 of 5 January, 2005

  • 7/27/2019 Unix Question

    8/11

    1.5 In vi, suppose pressing the character ] takes the cursor to next paragraph. If we give thecommand d], the

    A) The current paragraph is deletedB) The character with cursor and up to the end of paragraph is deletedC) The character following the cursor and up to ] character is deletedD) None of the above

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

    B) ddC) sedD) grep

    1.7 Execution of the program on the remote machine is possible throughA) ftpB) telnetC) httpD) None of the above

    1.8 Application programmers in X Windows environment quickly build sophisticated interface totheir programs and enforce a uniform look and feel to all part of GUI by using

    A) Widget set

    B) X toolkitC) Window manager D) None of the above

    1.9 Regular expression [ a-zA-Z] means thatA) the first character of the line is letterB) any character other than aC) any character that is not the letterD) None of these

    1.10 To search files which has been accessed in last n days is possible though the utility (withappropriate options)

    A) findB) lsC) awkD) None of the above

    A8-R3 Page 2 of 5 January, 2005

  • 7/27/2019 Unix Question

    9/11

    2. Each statement below is either TRUE or FALSE. Choose the most appropriate one andENTER in the tear-off sheet attached to the question paper, following instructionstherein. (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 Windowsapplication.

    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 sheetattached to the question paper, following instructions therein. (1 x 10)

    X Y3.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 eachcommand before its execution with substitution theshell makes

    G. Binary format

    3.8 A techniques to transfer file from one computer toanother computer on network

    H. M

    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. $$

    A8-R3 Page 3 of 5 January, 2005

  • 7/27/2019 Unix Question

    10/11

  • 7/27/2019 Unix Question

    11/11

    (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 innot echoed. Check the password with the PASSWORD. If it is not there display ACCESSDENIED.

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

    A8-R3 Page 5 of 5 January, 2005