Anda di halaman 1dari 15

Master of Computer Applications

Second Year

Unix Lab

1. Which of the following features of UNIX may be used for inter process communication?
A. Signals
B. Pipes
C. Semaphore
D. All of these

2. In a system, if 5 people are currently using the vi editor. then the number of corresponding
processes will be
A. 1
B. 5
C. 2
D. 0

3. The command echo welcome > /dev / tty


A. Echoes welcome in all the terminals that are switched on.
B. Echoes welcome in all the terminals that are logged on.
C. Echoes welcome only in the terminal in which it is run.
D. Both (a) and (c)

4. dev/null
A. Is a file
B. Has write permission for all
C. Is the UNIX built-in dustbin
D. All of these

5. The advantage of binary files over text files is that


A. It is compact
B. It can be accessed faster
C. They are more reliable
D. All of these

6: The permission bits of a file noname. can be set to _rws_ _x_ _x by the command.
A. chmod 711 noname
B. chmod go -rw noname
C. chmod 2711 noname
D. None of the above

7: /bin/passwd has the user execution permission set to 's' because


A. This facility assigns to the user, permissions of the program owner. temporarily
B. It should allow users who don't have write permission to /etc/passwd to write to it
C. /etc/passwd is write protected
D. All of these

8: If one doesn't want anyone else to read or write to a file named datfile, except through a
program in a file filex , then he may use
A. chmod u+s filex ; chmod go_rw datfile
B. chmod 4711 filex ; chmod go_rw datfile
C. chmod 4711 datfile ; chmod go_rw filex
D. Both (a) and (b)

9: Writing a C program that accepts input from keyboard, rather than from a file is advantageous
because
A. Keyboard is a file that is already open
B. It can be used in a pipe, if it writes to stdout
C. Both (a) and (b)
D. None of the above

10: Consider the following command that invokes the executable file a.out, with the following
command line arguments a .out God loves you argv( [1][2] )corresponds to the character
A. e
B. o
C. y
D. d

11: Which of the following string functions can be used to find the last occurrence of a given
character in a given string?
A. strncmp
B. strncpy
C. strchr
D. None of the above

12: Consider the program main ( )


{
printf("He arose a victor from\n");
system ("date") ;
printf("the dark domain");
}
If a.out is the executable code corresponding to the above source code, then the command
a.out > out f
A. Redirects the output of date to file out f
B. Displays the output of date on the screen
C. Prints everything on the screen
D. Prints the two messages on the screen

13: The default permission bits of a file when it is created for the first time, is controlled by
A. chmod value
B. fmask value
C. umask value
D. none of the above

14: Let x.c be a C source code. The command cc x.c > y


A. is equivalent to the command cc x.c;mv a.out y
B. is equivalent to the command cc -o y x.c
C. serves no purpose
D. None of the above

15: A file x is created with the following contents


echo today is:
date
If you type x.then
A. It echoes the message. followed by date.
B. It gives the desired output only if the execute permission of file x is set.
C. The desired output can be got by the command sh x. which works even if x has its
execute permission not set.
D. Both (b) and (c)

16: Shell script is preferable to other forms of programming because it


A. Makes programming task easier
B. Enhances portability
C. Occupies less space
D. All of these

17: Choose the incorrect statements.


A. Shell scripts can accept arguments
B. Shell scripts are interpreted
C. Shell is a programming language
D. Shell scripts are compiled

18: Files that store data in the same format as used in program are called
A. binary files
B. Source file
C. Text file
D. Core

19: To allow only one user to work with a particular file at a particular time, one has to use
A. Semaphore
B. Critical region
C. Locking
D. Dedicated mode

20: Which of the following remarks about realloc are true?


A. It allocates memory of required size that need not be contiguous
B. It may shift the existing block
C. It can work only with an existing block of memory
D. Both (b) and (c)

21: The differences between malloc( ) and calloc() are:


A. Malloc is used for dynamic allocation of memory, while cal:1c can't be used for that
purpose
B. Malloc needs only one argument. while cal loc needs two.
C. unlike malloc, calloc allocates memory and initializes it to 0.
D. Both (b) and (c)

22: The file that stores an integer as a sequence of characters is a


A. Text file
B. Data file
C. Binary file
D. Core file

23: If cat x. prints garbage. then x is probably a


A. Data file
B. Binary file
C. Text file
D. Source file

24: Which of the following file names can be found in more than one directoy?
A. passwd
B. bin
C. date
D. Both (a) and (b)

25: /bin
A. Is a bucket for storing information
B. Has files in binary code
C. is a directory
D. Both (b) and (c)

26: The main reasons for the success of pipes are


A. The availability of many filter programs
B. UNIX treats devices as files
C. It provides a 2-way communication channel
D. Both (a) and (b)

27: Which of the following are not filter programs?


A. date
B. sort
C. cat
D. grep

28: Redirection in pipes can be achieved by using


A. >
B. >>
C. tee
D. lpr

29: Choose the correct statements.


A. The symbols > and | are both processed by shell
B. > can be used to direct output to a named file
C. | can be used to direct output to programs
D. All of above

30: The command who sort - file1 > file2


A. Results in an error
B. Sorts the contents of file1 and puts it in file2
C. Both (a) and (b)
D. None of the above

31. The logout built in command is used to


A. shutdown the computer
B. logoff of the computer
C. logout the current user
D. to exit the current shell

32. The command umask -S


A. prints the current mask using symbolic notation
B. prints the current mask using octal numbers
C. sets the mask to 000
D. sets the mask to 777

33. The mapfile command


A. reads lines of standard input and assigns each to the element of an indexed array
B. reads lines of standard output file
C. reads lines of standard error file
D. none of the mentioned

34. Which option of the kill command sends the given signal name to the specified process?
A. -l
B. -n
C. -s
D. -a

35. Which command removes a directory from directory stack?


A. dirs
B. popd
C. pushd
D. rm

36. Which command puts a script to sleep untill a signal is recieved?


A. sleep
B. suspend
C. disown
D. break

37. The command ulimit


A. set a limit on specified resource for system users
B. set/show process resource limit
C. both (a) and (b)
D. none of the mentioned

38. Which command identifies the resource of a command?


A. type
B. typeset
C. select
D. source

39. Which command wait for the specified process to complete and return the exit status?
A. sleep
B. wait
C. delay
D. stop

40. Which command prints the accumulated user and system times for processes run from the
shell?
A. time
B. times
C. both (a) and (b)
D. none of the mentioned

41. In UNIX resources are shared by all the users, so UNIX is_____________ System.
A. multiuser
B. featureless
C. portable
D. multitasking

42. Root directory in UNIX is denoted by ____________


A. --
B. ()
C. /
D. \
43. _____________ directory contain executable file for most of the UNIX commands.
A. lib
B. bin
C. dev
D. tmp

44. dev directory contain files for controlling ____________.


A. input/output
B. OS
C. Both A and B
D. None

45. When scheduler submits process to the queue, process is said to be in ____________ state.
A. hold
B. submit
C. run
D. ready-to-run

46. Process whose execution comes to an end will be in _____________state.


A. hold
B. submit
C. complete
D. run

47. PWD stands for ______________.


A. present working directory
B. past working directory
C. present working diary
D. past working diary

48. Unix Operating System is an __________.


A. Time Sharing Operating System
B. Multi-User Operating System
C. Multi-tasking Operating System
D. All the Above

49. How do you get help about the command "cp"?


A. help cp
B. man cp
C. cp ?
D. cat cp

50. How do you rename file "new" in file "old"?


A. mv new old
B. cp new old
C. rm new old
D. rn new old

51. Which command is used with vi editor to move the cursor one row up?
A. i
B. j
C. h
D. k

52. Which command is used with the vi editor to save file and remain in the editing mode?
A. :q
B. :q!
C. :w
D. :x

53. How do you delete a file?


A. rm filename
B. cut filename
C. touch filename
D. less filename

54. ____________works as a command interpreter.


A. Hardware
B. Shell
C. Kernel
D. CPU

55. vi always starts in ____________ mode.


A. command
B. insert
C. last line
D. ex

56. To get out of insert mode, press the _____ key, which will put you back into command mode.
A. Shift
B. Ctrl
C. Esc
D. Alt

57. Which command is used to copy all files having the string chap and any two characters after
that to the progs directory?
A. cp chap* progs
B. cp chap?? progs
C. cp chap[12] /progs/*.*
D. None of these
58. Which command can be used to display the contents of a file on the screen?
A. ls
B. grep
C. cat
D. cut

59. How can you append the output of a command to a file?


A. command < file
B. command << file
C. command > file
D. command >> file

60. When the shell is used from a terminal it will issue a prompt before reading a command. By
default this prompt is _____.
A. >
B. $
C. &
D. #

61. The shell prompt when further input is needed, by default it is ______.
A. >
B. $
C. &
D. #

62. The cat command is used to


A. capture a file
B. print a file
C. copy a file
D. display a file

63. When you execute a script called test at $ prompt as $test hi hello then test will be stored in
_____ positional parameter.
A. $#
B. $*
C. $0
D. $1

64. Use of \ in removing meaning of any meta character placed after it is known as
_______________.
A. Escaping
B. Treating
C. Editing these
D. None o
65. Any command surrounded by backquote is executed by shell and its output is inserted in the
place it was found. This is known as _________________________.
A. Command replacement
B. Parsing
C. Command substitution
D. Command execution

66. ________ pathname uses the current directory as point of reference for the file.
A. Relative
B. Absolute
C. Both A and B
D. None of these

67. ________ commands are executed directly by the shell. These commands will not have a
separate process running for each.
A. External
B. Background
C. Internal
D. None of these

68. Which command is used to extract specific columns from the file?
A. cat
B. grep
C. cut
D. paste

69. In delimited file format, designated keyboard characters known as ___________ are used to
maintain the data's tabular organization.
A. delimiters
B. separator
C. partition
D. divider

70. _______________ format eliminate the need for delimiters.


A. Fixed length file
B. Delimited file
C. Both A and B
D. None of above

71. Which of the following is not a filter program?


A. date
B. sort
C. cat
D. grep

72. Which of the following results in error?


A. expr 4 + 5
B. expr 4 - 5
C. expr 4 * 5
D. expr 4 / 5

73. _______command copies to output those lines in the input that match a specified pattern.
A. cut
B. paste
C. echo
D. grep

74. Full form of grep is ________________________________________.


A. Globally search with Regular Expressions and Print
B. Global Read Expression and Print
C. Goto Regular Expression and Print
D. None of above

75. Full form of sed is


A. Sequential Data
B. Stream Editor
C. Sequence Editor
D. None of these

76. ______ option of grep doesnt display lines matching expression.


A. -c
B. -i
C. -v
D. -x

77. Which symbol will be used with grep command to match the pattern pat at the beginning of a
line?
A. ^pat
B. $pat
C. pat$
D. pat^

78. ____ command display the status of a process.


A. ls
B. ps
C. grep
D. cat

79: cat/dev/tty
A. Throws garbage onto the terminal 1.
B. Just echoes what you type. line by line
C. Terminates if one types control at the beginning of a line
D. Both (b) & (c)

80: The header files used in C programs arc usually found in


A. /bin/include
B. usr/bin/include
C. /dev/ include
D. iusr/include

81: Choose the correct statements.


A. Any process has an associated owner ID and group ID
B. Effective ID defines who you are for the duration of a process
C. Real ID defines who you are for the duration of a process
D. Both (a) & (b)

82: No shell script can take input from


A. stdin
B. the output of the previously executed command redirected to it
C. the shell holds the script
D. none of the above

83: The command cc x.c && a.out


A. is equivalent to cc x.c ; a . out
B. means execute a . out only when x . c compiles successfully
C. means execute a . out only if cc x .c retuns a value 0 to the system
D. Both (b) & (c)

84: Which of the following shell script's looping features does not recognize the break
command?
A. while
B. until
C. for
D. None of the above

85: Shell script


A. Needs no compilation
B. Enhances portability
C. Is not good in arithmetic operations
D. All of these

86: The desirable features of a new shell script you write is that
A. It should take its input from stdin
B. It does some cleaning up operation, on termination
C. It should not accept command line arguments
D. Both (a) & (b)
87: Which of the following shell commands displays the contents of each of the command line
arguments one by one
A. cat $
B. cat "$@"
C. Both (a) & (b)
D. cat "$"

88: The disadvantage of a pipe is that


A. It is a one way communication channel
B. It dies along with the process that created it
C. It can't he shared by unrelated processes
D. All of these

89: The state of signals are


A. preserved across a fork call
B. not preserved across an exec call
C. preserved across an exec call
D. Both (a) & (b)

90: Which of the following options for the shell command test should be followed by the file
descriptor"'
A. r
B. d
C. The data type of all fields in all file
D. s

91: Which of the following displays the exit status of the last executed command?
A. echo $4
B. echo $$
C. echo $?
D. echo $!

92: Which of the following file names cannot be displayed if la ls* is run?
A. .x
B. ?x
C. Both (a) & (b)
D. hidden

93: Which of the following initiates the sequence of events that ultimately allows a user to
login?
A. clri
B. sync
C. login
D. init

94: getc (stdin)


A. results in run time error
B. results in syntax error
C. is equivalent to get char ( )
D. none of the above

95: Which of the following is not the work of a C-preprocessor?


A. Macro expansion
B. File inclusion
C. Conditional compilation
D. None of the above

96: Choose the correct statement


A. To read successive characters from an open file . getchar and scan f can be used
interchangeably
B. To read successive characters from an open file. getchar and read can be used
interchangeably
C. The read system call reads from the buffer
D. None of the above

97: The following program


main()
{
close(1);
print("How R U?");
}
A. is syntactically incorrect
B. results in a run-time error
C. will wait indefinitely, if executed
D. none of the above

98: Choose the correct remarks


A. exit and return can be used interchangeably
B. Use of return terminates the program
C. Use of exit terminates the program
D. exit retuns a value to the system

99: Choose the correct statements.


A. The default linking arrangement for cc is dynamic
B. Dynamically linked programs save disk storage
C. Dynamically linked programs enhances shareability of library routines
D. All of these

100: Context switch changes the process mode from


A. user to kernel mode
B. kernel to user mode
C. kernel mode to the kernel process
D. Both (a) and (b)

Answer Keys:
1. D 2. B 3. D 4. D 5. D 6. D 7. D 8. D 9. C 10. D
11. C 12. A 13. C 14. C 15. D 16. D 17. D 18. A 19. C 20. D
21. D 22. A 23. B 24. D 25. D 26. D 27. A 28. C 29. D 30. D
31. D 32. A 33. A 34. S 35. B 36. B 37. C 38. A 39. B 40. B
41. A 42. C 43. B 44. A 45. B 46. C 47. A 48. D 49. B 50. A
51. D 52. C 53. A 54. B 55. A 56. C 57. B 58. C 59. D 60. B
61. A 62. D 63. C 64. A 65. C 66. A 67. C 68. C 69. A 70. A
71. A 72. C 73. D 74. A 75. B 76. C 77. A 78. B 79. D 80. A
81. D 82. D 83. D 84. D 85. D 86. D 87. C 88. D 89. D 90. C
91. C 92. C 93. D 94. C 95. D 96. A 97. D 98. D 99. D 100. D

Anda mungkin juga menyukai