0% found this document useful (0 votes)
16 views28 pages

Q n A OS

The document consists of a series of multiple-choice questions related to operating systems, command line usage, and the vi editor. Each question provides options that cover fundamental concepts in computing, including commands and their functions in UNIX/Linux environments. The questions are designed to test knowledge on various topics such as memory, command syntax, and file management.

Uploaded by

Ghana Uni Help
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views28 pages

Q n A OS

The document consists of a series of multiple-choice questions related to operating systems, command line usage, and the vi editor. Each question provides options that cover fundamental concepts in computing, including commands and their functions in UNIX/Linux environments. The questions are designed to test knowledge on various topics such as memory, command syntax, and file management.

Uploaded by

Ghana Uni Help
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Directions: Select the letter that indicates the best answer for the question.

1. Operating system
a. is a collection of programs
b. provides user-interface
c. is a resource manager
d. all of the above
e. none of the above

2. Letter K represents
a. 1000 bytes
b. 10000 bytes
c. 100 bytes
d. 1024 bytes
e. none of the above

3. Computers main memory is primarily consisted of


a. ROM
b. RAM
c. disks
d. tapes
e. all of the above

4. A machine cycle consists of


a. instruction cycle and execution cycle
b. ALU and CU
c. hardware and software
d. system software and application software
e. none of the above

5. The operating system model consists of


a. kernel layer, service layer, and user-interface layer
b. hardware layer and software layer
c. multi-tasking, time sharing, and multi-user
d. system layer, utility layer, and application layer
e. none of the above

Directions: Select the letter that indicates the best answer for the question.

6. The argument part in the command line cal 2 2001 is


a. cal
b. 2 and 2001
c. only 2001
d. all of the above
e. none of the above

7. The option part in the command line who -H am i is


a. who
b. am i
c. -H
d. -H and am i
e. who -H

8. The $ prompt
a. indicates UNIX is ready to accept your next command
b. indicates the end of the session
c. indicates the beginning of a session
d. indicates system failure
e. indicates nothing and you can erase it
9. You log in to the system by
a. turning the terminal on
b. answering to the login prompt by typing your User Id
c. typing start
d. typing ready
e. none of the above

10. You log off from the system by


a. typing exit command or [Ctrl-d] key
b. typing good bye
c. just turning the terminal off
d. none of the above

11. The command to change your password is


a. passwd
b. password
c. PassWord
d. PWD
e. change pwd

12. Your password


a. must be at least six characters
b. must contain at least two characters and one number
c. must differ from your User Id
d. all of the above
e. none of the above

13. The end of the command line is indicated by


a. pressing the [Esc] Key
b. pressing the period [.] key
c. pressing the [End] key
d. pressing the [Return] Key
e. pressing the [Ctrl-d] key

14. The command options are


a. mandatory part of the command line
b. optional part of the command line
c. the same for all commands
d. placed before the command name
e. placed after the argument field

15. The command arguments are


a. mandatory part of the command line
b. optional part of the command line
c. the same for all commands
d. placed before the command name
e. placed before the option field

16. The command to display the calendar for January 2001 is


a. cal Jan 2001
b. cal 1 2001
c. calendar 2001 1
d. cal 1/1/2001
e. cal Month: 1 Year: 2001

17. The interrupt character is used to


a. log off
b. terminate a running program
c. erase the entire command line
d. turn the system off
e. delete a character from the command line
18. The Bourne shell is
a. super set of the Korn shell
b. superset of the C shell
c. just like the C shell
d. the standard shell
e. none of the above

19. The init program


a. initializes the shell
b. checks your password
c. activates the getty program for each terminal
d. initializes the terminal session
e. none of the above

20. Linux provides some alternative and new command options. When used, these command options are
preceded by
a. --(dash dash)
b. - -(dash space dash)
c. ÝÝ(dot dot)
d. -(dash)
e. - (dash space)

Directions: Select the letter that indicates the best answer for the question.

21. In a line oriented editor


a. changes are applied to a line or group of lines at a time
b. changes are applied to a character or group of characters at a time
c. changes are applied to a screen at a time
d. changes cannot be applied
e. none of the above

22. The vi editor


a. is a line oriented editor
b. is a screen oriented editor
c. is supported in most of the UNIX installations
d. is a text formatter
e. b and c

23. The command to exit vi and save your file is


a. w!q
b. qw
c. wq
d. WQ
e. w

24. The commands that place vi in the text input mode are
a. A and O
b. a and o
c. I and i
d. all of the above
e. none of the above

25. The command to delete 5 lines in the file you are editing is
a. dd5!
b. 5dd
c. 5delete
d. del 5
e. d5
26. The command to search for the word "hello" in the file you are editing is
a. /hello
b. \hello
c. s\hello
d. /hello/
e. hello?

27. The commands $ and 0 (zero) move the cursor from on the current line to
a. end and center
b. end and beginning
c. beginning and end
d. top and left
e. top and right

28. Using the [return] key while vi is in the text input mode
a. you can split the current line
b. you can open a new line above the current line
c. you can open a new line below the current line
d. all of the above
e. none of the above

29. In the text input mode of vi


a. keyboard becomes your typewriter
b. keys you press appear on the screen
c. keys you press are not interpreted as commands
d. pressing the space bar produces one space before the cursor position
e. all of the above

30. In vi command mode, to delete 3 characters starting from the cursor position you type
a. xxx
b. 3x
c. d3
d. 3dd
e. XXX

31. In vi command mode, to undo all the changes on the command line you type
a. UU
b. u
c. AU
d. U
e. UA

32. In vi command mode, to open a line below the current line you type
a. B
b. o
c. O
d. ob
e. OB

33. To obtain a general command description under Linux's vi (vim) you type
a. linux help
b. vi help
c. help
d. man
e. [Ctrl-h]

34. To obtain description for wq under Linux's vi (vim) you type


a. help wq
b. hwq
c. wq
d. man wq
e. vi wq
35. The command to search backward for the word UNIX in a file you type
a. \UNIX
b. SB UNIX
c. UNIX/
d. man UNIX
e. ?UNIX

Directions: Select the letter that indicates the best answer for the question.

36. The command to show your current directory pathname is


a. pcd
b. ls -a
c. pwd
d. lp pwd
e. ls pwd

37. The command to create a directory called xyz is


a. mkdir xyz
b. mk xyz dir
c. md xyz
d. dir xyz
e. MKDIR xyz

38. The command to delete a file called xyz with confirmation option is
a. del xyz
b. rm xyz
c. rm -c xyz
d. rm -i xyz
e. rm xyz -i

39. If your current directory pathname is /usr/david, the command ls ..


a. displays the current directory
b. lists files in the working directory
c. lists files in david directory
d. lists files in the usr directory
e. displays invalid command message

40. Which of the following commands is not a correct use of the options?
a. ls -amF
b. ls -a -C
c. lp -tHELLO xyz
d. ls a
e. all of the above

41. Which of the following filenames is not a correct filename?


a. XYZ.xyz
b. XYZ>> xyz
c. Xyz
d. X.Y.Z
e. all of the above

42. If your current directory is /usr/david, the command cd / changes your current directory to
a. root
b. usr
c. david
d. /usr
e. none of the above

43. The command to print the files XYZ and xyz is


a. lp XYZ, xyz
b. print XYZ and xyz
c. P xyz, XYZ
d. lp XYZ xyz
e. lp -2 XYZ

44. The command to check the status of your print job is


a. lpstat printers
b. lpstat jobs
c. lpstat
d. lp status
e. status printers

45. Which one of the following pathnames is considered an absolute pathname?


a. absolute/xyz
b. /bin/usr/u/se-bin
c. david/memo/c
d. Ý/../xyz
e. ÝÝ/xyz/xxx/memo

46. The command to print a file on a specific printer is


a. lp -d filename
b. lp filename printer-name
c. lp -d printer-name filename
d. print filename ptr1
e. p -d printer-name filename

47. The command to obtain the name of the default printer is


a. lpstat -d
b. lpstat printer-name
c. lp -d
d. print default ptr
e. printer

48. The Linux command to print on a specific (named) printer is


a. lpr -d filename
b. lpr filename printer-name
c. lpr -p printer-name filename
d. print filename ptr1
e. pr -d printer-name filename

49. The command to delete a directory and all the subdirectories and files in it is
a. rm -r directory-name
b. rm directory-name
c. rm -all directory-name
d. rm -sub directory-name
e. rm all

50. The Linux command to delete a directory and all the subdirectories and files in it is
a. rm --recursive directory-name
b. rm --r directory-name
c. rm --all directory-name
d. rm --sub directory-name
e. rm --all

51. The Linux command to obtain help screen for the rm command is
a. rm --h
b. rm --help
c. help rm
d. help --rm
e. rm help
52. The command to list a hierarchy of directories is
a. ls -R directory -name
b. ls -a directory -name
c. ls -all directory -name
d. ls -hierarchy 3directory -name
e. ls directory Äname all

53. The Linux command to list a hierarchy of directories is


a. ls --R directory -name
b. ls --a directory -name
c. ls --all directory -name
d. ls --hierarchy directory -name
e. ls --recursive directory Äname

54. The command to create 2 levels of directories is


a. mkdir -p level-1/level-2
b. mkdir -l level-1/level-2
c. mkdir -2 level-1/level-2
d. mkdir -h level-1/level-2
e. mkdir -p level-1 level-2

55. The Linux command to create 2 levels of directories is


a. mkdir --parent level-1/level-2
b. mkdir --l level-1/level-2
c. mkdir -l level-1/level-2
d. mkdir -hierarchy level-1/level-2
e. mkdir -p level-1 level-2

56. The vi command :set all


a. sets all the vi parameters
b. sets the all option
c. displays a list of the parameters currently set for vi
d. invokes the .exrc file
e. none of the above

57. The vi command to set the showmode option is


a. set showmode
b. show mode
c. activate show mode
d. run showmode
e. none of the above

58. The vi command to display the list of abbreviations is


a. list ab
b. ab
c. set ab
d. showmode ab
e. display ab

59. The vi command to copy the content of the temporary buffer named w at the cursor position is
a. wp
b. copy w
c. "wp
d. Ctrl -c
e. cp w

60. The vi command to move the cursor to the top of the page is
a. 1g
b. G
c. 1G
d. top
e. go 1
61. The vi command to cancel the displaying of the line numbers is
a. no numbers
b. set number off
c. set nonumber
d. nu off
e. set no number

62. The vi commands sequence: dd G p


a. deletes the current line and saves it in the G buffer
b. deletes the current line and place it after the letter G
c. deletes two lines and place them in the G buffer
d. moves the current line to the end of the file
e. deletes the letter G

63. The vi command to repeat the last changes is


a. repeat
b. rc
c. Ý (dot)
d. ÝÝ (dot dot)
e. cw

64. The command line vi -c /print myfile


a. invokes vi with two filenames: print and myfile
b. invokes vi and places the cursor on the first occurrence of print in myfile
c. displays an error message
d. prints myfile at the end of the editing session
e. changes the word print to myfile

65. The vi command Ctrl-g


a. places the cursor at the end of the file
b. places the cursor at the top of the file
c. cancels last changes on the current line
d. scrolls the cursor down one page
e. displays the line number of the current line

66. The vi command :ab hi hello


a. creates an abbreviation for hi
b. creates an abbreviation for hello
c. creates an abbreviation for greetings
d. abandons the abbreviation for hello
e. displays the list of abbreviations

67. The command line vi -r filename


a. opens vi for read only
b. opens vi for recovery
c. creates a new filename
d. removes filename form list of files to edit
e. refreshes the vi screen

68. The vi command : ! pwd


a. displays the current directory pathname
b. imports the current directory pathname
c. moves vi to the current directory
d. terminates vi without saving the file
e. exits vi and saves the file

69. The vi command : set report=2


a. sets confirmation messages for two or more lines
b. sets confirmation messages for exactly two lines
c. sets confirmation messages for less than two lines
d. sets vi to report two lines of error messages
e. sets vi to report twice
70. The vi command to save lines 1-5 of the text in another file is
a. :save 5 lines
b. :s 1-5 filename
c. :1,5 w filename
d. :w 5 filename
e. :!w 1 5 filename

71. The vi command : map


a. lists the macro names
b. lists the map points
c. deletes all the macros
d. manages the vi navigation
e. none of the above

72. The vi command :r ! ls


a. searches for the word ls in the file
b. searches for the name ls in the current directory
c. removes all occurrences of the word ls from the file
d. reads a file named ls
e. imports the list of the files in the current directory

73. The vi command :w !


a. saves the current file and overwrites the existing file
b. stops the write operation
c. saves in a file named w!
d. cancels the previous write command
e. none of the above

74. The vi command to join 2 lines is


a. J
b. join
c. j
d. :jn
e. none of the above

75. The vi command to access the contents of a numbered buffer (say buffer number 2) is
a. "2p
b. "bp
c. "two p
d. "pP
e. none of the above
Directions: Select the letter that indicates the best answer for the question.

76. The command to count number of lines in xyz is


a. wc count xyz
b. line count xyz
c. count -l xyz
d. wc -l xyz
e. wc -lines xyz

77. The command to display all the single capital letter filenames is
a. ls -A ... Z
b. ls [A-Z]
c. ls [AZ]
d. display [A-Z]
e. filename = [A-Z]

78. The command to copy xxx and yyy files into zzz file is
a. copy xxx and yyy to zzz
b. cp xxx + yyy to zzzls [A-Z]
c. cat xxx >> yyy >> zzz
d. cat xxx yyy >> zzz
e. cat xxx yyy << zzz
79. The command cp xxx yyy
a. creates a new i-node number for yyy
b. creates a new i-node number for xxx
c. assigns the i-node number of xxx to yyy
d. creates no new i-node number
e. creates two new i-node numbers

80. The command ln xxx yyy


a. creates a new i-node number for yyy
b. creates a new i-node number for xxx
c. creates no new i-node number
d. assigns a new i-node number to both yyy and xxx
e. creates two new i-node numbers

81. The command mv xxx yyy


a. creates a new i-node number for yyy
b. creates a new i-node number for xxx
c. creates a new i-node number associated with both files
d. The i-node number remains the same, only the filename is changed
e. creates two new i-node numbers

82. The command cat xxx >> zzz


a. copies xxx and to zzz
b. creates zzz if it does not exist
c. if zzz does exist xxx is appended to the end of zzz
d. all of the above
e. none of the above

83. The command ls ?? matches the filename(s)


a. AB and ab
b. abc
c. ??
d. AAAA
e. CCAA

84. The command more xyz


a. shows only the first page of the xyz file
b. shows xyz file one page at the time
c. shows only the last page of the xyz file
d. shows a file called more
e. shows the second copy of the file xyz

85. The cut command is used to


a. display specified columns or fields from a file
b. cut and paste columns
c. cut file into equal parts
d. cut file into screen full pages
e. truncate large files

86. The paste command is used to


a. cut and paste columns in a file
b. join files together line by line
c. append files
d. display a highlighted part of a file
e. paste directory files

87. The command find / -name "file?" -print


a. displays the absolute pathnames such as file1, filea, fileA
b. searches from the home directory
c. searches from the current directory
d. finds all files that have filenames such as myfile or yourfile
e. all of the above
88. The command find . -name "?" -print
a. starts from the current directory, and finds all files with filename ?
b. starts from the home directory, and finds all files with filename ?
c. starts from the root directory, and finds all files that have a ? mark as part of their
filenames
d. starts from the current directory, and finds all files with one character filename
e. none of the above

89. The command find / -name "*" -atime -5 -print


a. starts from the current directory, and finds all files with filename atime
b. starts from the home directory, and finds all files last accessed less than 5 minutes ago
c. starts from the root directory, and finds all files last accessed less than 5 days ago
d. starts from the root directory and sends 5 files to the printer
e. none of the above

90. The command find . -name "first.c" -exec rm {}\;


a. starts from the current directory, and deletes all instances of first.c
b. starts from the home directory, and executes all instances of first.c
c. starts from the root directory, and removes files that are executable
d. all of the above
e. none of the above

91. The command to rename the file called Xfile to Zfile is


a. cp Xfile Zfile
b. rename Xfile Zfile
c. mv Xfile Zfile
d. mv Zfile Xfile
e. ln Xfile Zfile

92. The command to copy the file called Xfile to Zfile is


a. cp Xfile, Zfile
b. copy Xfile Zfile
c. cp Xfile Zfile
d. cp Zfile Xfile
e. ln Xfile Zfile

93. The command to display Xfile one screen at a time is


a. more Xfile
b. more -p Xfile
c. more page Xfile
d. show Xfile
e. Xfile - page

94. The command to copy the file called Xfile to Zfile is


a. cat Xfile Zfile
b. cat Xfile > Zfile
c. cat > Xfile Zfile
d. cat Xfile < Zfile
e. cat Xfile, Zfile

95. What is the content of the Xfile after the following command is executed?
ls > Xfile
a. nothing
b. the word ls
c. list of the filenames in the current directory
d. an error message
e. none of the above
96. What is the content of the Xfile after the following command is executed?
date > Xfile
a. nothing
b. the word date
c. list of the filenames in the current directory
d. current date and time
e. an error message

97. What is the content of the Xfile after the following command is executed?
cat Afile Bfile > Xfile
a. Afile and Bfile
b. only Afile
c. only Bfile
d. nothing
e. an error message

98. The command cat Afile >> Xfile


a. copies the Afile to Xfile and overwrites Xfile
b. appends the Afile to Xfile
c. terminates the command if Xfile already exists
d. Saves Xfile before copying the files
e. displays an error message if Xfile exists

99. What is the content of the Xfile after the following command is executed?
pr Afile > Xfile
a. a formatted copy of the Afile
b. nothing
c. Afile and Xfile
d. an error message
e. none of the above

100. The command cp -i Afile Xfile


a. asks for confirmation before copying the files
b. ignores the copy command
c. asks for confirmation after coping the files
d. removes Afile after copying the file
e. ignores user's answer before copying the files

101. What is the content of the Xfile after the following command is executed?
ls [Aa]* > Xfile
a. list of all the files that start with letter A or a
b. list of all the file that starts with the letter A
c. list of all the files that ends with the * sign
d. list of all the file with filename that contains at least a letter A
e. all of the above

102. What is the content of the Xfile after the following command is executed?
ls A?A > Xfile
a. list of files such as: AAA ABA AZA
b. list of files such as: aaa aBa aZa
c. list of files such as: A?A B?B BAB
d. list of files such as: ABACC ABA.C ABA.CPP
e. list of files such as: AAAfile ABAfile Afile

103. The command rm [a-c]Report


a. deletes files with filename such as: aReport
b. deletes files with filename such as: bReport
c. deletes files with filename such as: cReport
d. all of the above
e. none of the above
104. The command to list all the files that have filenames that starts with letter a and ends
with a number from 1 to 5 is
a. ls a?1-5
b. ls a[1-5]*
c. ls a*[1-5]
d. ls *a*[1,5]*
e. ls ?a?1?5

105. The command to delete all the files that have filenames that starts with letter C or c and
ends with a letter Z or z is
a. rm all Cc Zz
b. rm [Aa]*[Zz]
c. rm [A-a]*[Z-z]
d. rm [Aa][Zz]*
e. rm [Aa]?[Zz]*

106. The command find . -name Xfile -print


a. finds and displays all the files named name
b. finds and displays all the files named xfile
c. finds and displays all the files named print
d. finds and displays all the hidden files such as .hidden
e. none of the above

107. The command find . -atime 10 -print


a. finds and displays files accessed exactly 10 days ago
b. finds and displays files accessed less than 10 days ago
c. finds and displays files accessed more than 10 days ago
d. finds and displays the first 10 files named atime
e. finds and displays files 10 times

108. The command head -5 Xfile Zfile


a. displays the first 5 lines of the Xfile and Zfile files
b. displays the first 5 pages of the Xfile and Zfile files
c. displays the first 5 characters of the Xfile and Zfile files
d. displays the first 5 paragraphs of the Xfile and Zfile files
e. displays the header pages of the Xfile and Zfile

109. The command ln Xfile Zfile


a. links Xfile to Zfile
b. lists and numbers Xfile and Zfile
c. creates a new version of each file
d. creates new i-nodes for Xfile and Zfile
e. all of the above

110. The command cut -f 1,3 Xfile


a. displays the first or third field in the Xfile
b. displays the first and third fields in the Xfile
c. displays the first, second and third fields in the Xfile
d. removes the first and third fields from the Xfile
e. displays all fields except the first, second and third fields in the Xfile

111. The command to sort the xyz file in the background is


a. sort -b xyz
b. sort xyz &
c. &sort xyz
d. sort xyz >> &
e. none of the above

112. The command to display the number of lines in a file and also save the count in a file is:
a. wc -l >> xyz
b. wc -l xyz
c. wc -l xyz outfile
d. wc -l ³ xyz
e. wc -l xyz ³ tee outfile
113. The command to prevent the termination of a background process after the user is logged off
is:
a. nohup sleep 1200
b. sleep 1200 ; sort xyz
c. sleep 1200 ; sort xyz &
d. nohup sort xyz &
e. nohup & sort xyz

114. The command kill -9 0


a. terminates the process identified by PID 9
b. terminates all processes including your login shell
c. terminates the processes identified by PIDs 9 and 0
d. terminates all active processes and shuts down the whole system
e. none of the above

115. The command sort -r -o yourfile myfile


a. sorts yourfile and saves it in myfile
b. sorts yourfile in reverse order and saves it in myfile
c. sorts myfile in reverse order and saves it in yourfile
d. sorts yourfile and myfile in reverse order and displays the results
e. none of the above

116. The command to display your home directory pathname is


a. echo $HOME
b. echo HOME
c. echo Current Directory
d. echo $PATH
e. echo pathname

117. The command to display the string "? is >> * \" is


a. echo ? is >> * \
b. echo \? is \>> \* \\
c. echo ? "is" >> * \\
d. echo ?? is >>>> ** \\
e. all of the above

118. The command to display your home directory pathname is


a. echo home
b. echo HOME
c. echo $HOME
d. echo $home
e. all of the above

119. The command to find the word UNIX in files called File1, File2 and File3 is
a. grep UNIX File?
b. grep UNIX Files
c. ls UNIX File?
d. grep File1 File2 File3 "UNIX"
e. find UNIX in Files

120. The command sort +1 xyz sorts the xyz file


a. on the first character
b. on the first field
c. on the second field
d. on the second character
e. on the first line

121. The command to change the prompt to the string "Next? " is
a. PS1=Next ?
b. set PS1=Next?
c. ps1="Next?"
d. PS1="Next? "
e. Prompt="Next? "
122. The command G
a. shows the last command in the history file
b. shows the variable called G
c. goes to the first command in the history file
d. does not do anything
e. grants access to the history file

123. The statement PS1="! $"


a. sets the prompt sign to !$
b. sets the prompt sign to $
c. sets the prompt sign to show the last event number from the history file
d. sets the prompt sign to !
e. none of the above

124. The statement HISTSIZE=100


a. sets the number of entries for .shhistory file to 100
b. sets the number of entries for HISTFILE to 100
c. creates 100 history files
d. displays the entry number 100 from the history file
e. none of the above

125. The command to turn on command line editing options is


a. set -o vi
b. EDITOR=/usr/bin/vi
c. VISUAL=/usr/bin/vi
d. all of the above
e. none of the above

126. The command to set the option to prevent overwriting an existing file is
a. set option noclobber
b. set -o noclobber
c. set -o ignoreeof
d. set +o noclobber
e. set on ignoreeof

127. The command to set the option to prevent accidental log off when using [Ctrl-d] key is
a. set option ignoreeof
b. set on noclobber
c. set -o noclobber
d. set +o ignoreeof
e. set -o ignoreeof

128. The command to display the word UNIX in quotation marks is:
a. echo "UNIX"
b. echo ""UNIX""
c. echo " \"UNIX\" "
d. display "UNIX"
e. none of the above

129. The file(s) that will be executed by shell before prompt string is displayed is
a. ÝStartupfile
b. Ýprofile
c. Ýexrcfile
d. all hidden files
e. none of the above

130. To quotation marks used for command substitution (executing a command) is


a. "command" (double quotation marks)
b. 'command' (single quotation marks)
c. `command` (single back quotation marks - grave accent)
d. all of the above
e. none of the above
131. The command stty kill \^u sets the kill key to
a. [Ctrl-u]
b. ^u
c. u
d. kill
e. \u

132. The command stty sane sets the terminal values to


a. nothing
b. opposite of the default values
c. a sensible default values
d. S, A, N and E values
e. command line values

133. The command to execute the shell script named myscript is


a. run myscript
b. execute myscript
c. load myscript
d. sh myscript
e. all of the above

134. The command to execute the shell script named myscript if it is an executable file is
a. run myscript
b. execute myscript
c. myscript
d. sh myscript
e. c and d

135. The command to execute a program named xyz in the current shell environment is
a. run xyz
b. sh xyz
c. xyz
d. Ý
e. a.out

136. The command unset myvar


a. changes the value assigned to myvar
b. makes myvar to be an empty variable
c. deletes myvar variable
d. resets myvar to its previous value
e. none of the above

137. The command to display the contents of the variable named myvar is
a. echo myvar
b. echo $myvar
c. display myvar
d. $myvar
e. none of the above

138. The command set one last assigns


a. one to $1 and last to $2
b. one to $0 and last to $9
c. one to $one and last to $last
d. one last to $1
e. none of the above

139. The positional variable $# contains


a. the UNIX version
b. user number
c. name of the script as typed on the command line
d. name of the arguments as typed on the command line
e. none of the above
140. To create an empty (null) variable called xyz you type
a. xyz=null
b. xyz=
c. xyz=empty
d. xyz=""
e. b and d

141. The command to add the numbers 1 and 10 is


a. add 1+10
b. a 1 + 10
c. expr 1+10
d. expr 1 + 10
e. expr -a 1 10

142. The output of the command expr xyz = xyz is


a. xyz
b. 2 xyz
c. 1
d. 2
e. none of the above

143. Which of the following is a valid variable assignment?


a. count=1
b. count="hello"
c. count=hello
d. count=
e. all of the above

144. What symbol or character at the beginning of a line indicates a comment line?
a. ?
b. !
c. #
d. @
e. C

145. Which of the following commands changes the name of the file assigned to a variable such as:
File=memo?
a. mv $File $Filex
b. mv $File momoX
c. mv $File ${File}X
d. mv memo $FileX
e. mv $FileX $FileX

146. The output of the following program is


for number in 10 11 5
do
echo "$number \c"
done
a. "10 11 5 \c"
b. number number number
c. 10115
d. 10 11 5
e. none of the above
147. The output of the following program is
number=2
while [ $number -gt 0 ]
do
echo "$number \c"
number=`expr $number - 1`
done
a. "number \c"
b. number number
c. 2 1
d. 1 2
e. 0 1 2

148. The output of the following program is


number=2
until [ $number -eq 0 ]
do
echo "$number \c"
number=`expr $number - 1`
done
a. "number \c"
b. number number
c. 2 1
d. 1 2
e. 2 1 0

149. The output of the following program is


number=2
if [ $number -eq 3 ]
then
echo "Hi!"
else
echo "Bye!"
fi
a. number =2
b. number number
c. Hi!
d. Bye!
e. Hi! Bye!

150. The output of the following program is


read x y z
echo z y x
Assume the input to this program to be: What a wonderful day!
a. What a wonderful day!
b. Whatawonderfulday!
c. day! wonderful What a
d. wonderful day! a What
e. z y x

Directions: Match the following commands to the corresponding descriptions. Place the letter that
indicates your answer on the line in front of each command.
a. Command to change your password
b. Lists users of the system
c. Lists users and displays column headings
d. Shows calendar for the second month of the current year
e. On line system documentation
f. Displays date and time
g. The kill character
h. The command to end a session (to log off)
151. __b___ who
152. __c___ who -H
153. __f___ date
154. __d___ cal 2
155. __a___ passwd
156. __e___ man
157. __h___ [Ctrl-d]
158. __g___ [Ctrl-c]

Directions: Match the following commands to the corresponding descriptions. Place the number that
indicates your answer on the line in front of each command description.
a. Searches backward through a file
b. Deletes a line
c. Opens a line above the current line
d. Repeats the last text changes
e. Opens a line below the current line
f. Exits the vi editor and saves the file
g. Exits the vi editor without saving the file
h. Deletes a character indicated by the cursor position
i. Undoes the recent changes on the current line
j. Replaces character(s) and places vi in the text input mode
k. Places the cursor at the end of the current line
l. Places the cursor at the beginning of the current line
n. Moves the cursor one word forward
m. Places the vi editor in the command mode
o. Undoes all changes on the current line
159. __o___ U
160. __m___ Esc
161. __c___ O
162. __g___ q!
163. __h___ x
164. __b___ dd
165. __d___ . (dot)
166. __j___ R
167. __e___ o
168. __a___ ?
169. __k___ $
170. __l___ 0 (zero)
171. __n___ w
172. __i___ u
173. __f___ wq

Directions: Match the following commands to the corresponding descriptions. Place the letter that
indicates your answer on the line in front of each command.
a. absolute pathname to the file called xyz
b. changes the directory to the parent of the current directory
c. lists current directory files including the invisible files
d. sends xyz file to the line printer
e. deletes the directory called xyz
f. displays the content of the file called xyz
g. displays the current directory pathname
h. cancels the printing job on the lp1 printer
i. confirms the deletion of the xyz file before deleting it
j. lists the current directory in long format
k. lists files across the page separated by commas
l. changes the current directory to the HOME directory
m. removes all subdirectories and files under the current directory
n. shows name of the default printer
o. shows status of the printing requests
p. sends mail to the user mailbox after completion of the print request
q. prints on a specific (named) printer (Linux)
r. displays usage message for the rm command (Linux)
s. creates two levels of directories under the current directory
(Linux)
t. prints the specified title on the banner page (Linux)
174. __d___ lp xyz
175. __f___ cat xyz
176. __i___ rm -i xyz
177. __a___ /david/xyz
178. __h___ cancel lp1
179. __j___ ls -l
180. __b___ cd ..
181. __c___ ls -a
182. __e___ rmdir xyz
183. __g___ pwd
184. __n___ lpstat -d
185. __r___ rm --help
186. __q___ lpr -p filename
187. __m___ rm -r *
188. __o___ lpstat
189. __k___ ls -m
190. __l___ cd
191. __s___ mkdir --parent xx/yy
192. __t___ lpr -T
193. __p___ lp -m filename

Directions: Match the following commands to the corresponding descriptions. Place the letter that
indicates your answer on the line in front of each command.
a. copies the current line into the temporary buffer
b. cancels the showmode set up
c. copies the content of buffer number 2 to the cursor position
d. deletes a line and saves it in the a buffer
e. displays line numbers
f. copies the text starting from the cursor to the end of the line to
the temporary buffer
g. opens a file for read only
h. scrolls the cursor down, usually 12 lines
i. lists the abbreviations
j. opens a file for recovery
k. name of the file that vi looks for when it is invoked
l. vi command to create a macro
m. displays list of the parameters and their set up values
n. sets confirmation messages for editing any number of lines
o. copies 3 words to the temporary buffer
194. __e___ set number
195. __f___ y$
196. __b___ set noshowmode
197. __h___ Ctrl-d
198. __d___ "add
199. __a___ yy
200. __c___ "2p
201. __o___ 3yw
202. __m___ set all
203. __i___ ab
204. __l___ map
205. __j___ vi -r filename
206. __n___ set report=0
207. __g___ view filename
208. __k___ .exrc

Directions: Read the following scenario. Provide the command(s) in context of the environment
established in the scenario.

209. Make 2 new directories called mydir and backup


mkdir mydir
mkdir backup

210. Copy all files from current directory to backup directory


cp * backup

211. Move all files from current directory to mydir directory


mv * mydir

212. Change to mydir directory


cd mydir

213. List files which have .cpp extension


ls * .cpp

214. List all files with prefix file


ls file*

215. List all files with postfix file


ls *file
216. List all files that start with the letter W or w
ls [Ww]

217. Delete file1, file2, file3, and file4 using one command line
rm file[1-4]

218. Delete all files with postfix .cpp, and ask for confirmation before deletion
rm –i *.cpp

219. Change file1 name to oldfile1


mv file1 oldfile1

220. Change to your home directory


cd

221. Remove mydir directory (note: you have files in mydir directory)
rm –r mydir

222. Change to backup directory and delete all files


cd backup

223. Remove all files from the backup directory


cd backup
rm *

Direction: Read the following scenario. Provide the command(s) in the context of the environment
established in the scenario.

224. List files in your current directory that are 5 days old.
find .-name “*” –atime -5 print

225. List files in your home directory that are larger than 6 blocks
find . –name “*” –size -6 print

226. Find all hidden files pathnames, starting from your current directory.
find .-name “.*” –print

227. Starting from your current directory, find and delete all instances of myfile.
find . –name “myfile” –exec rm {}\;

228. Starting from your current directory, find and delete all instances of myfile and ask for
confirmation before deletion.
find . –name “myfile” –ok rm {}\;

229. Starting from your current directory, find all the files that their filenames are two
characters.
find . –name “??” –print

230. Display the last 20 lines of the file called xyz.


tail -20 xyz

231. Starting from your current directory, find all instances of the files with .extension
find . –name “*.c” –print

232. Starting from your home directory, find all the files that their names start with letter A,
B, C, or D.
find .-name [A-D]* -print

233. Starting from your home directory, find all the files that their names end with letter A,
B, C, or D.
find .-name *[A-D] –print

234. Display first 5 lines of the file named Xfile


head -5 Xfile
235. Display how many lines are in the file named Xfile
wc –l Xfile

236. Display the first 3 fields of the file named Xfile, using the space character as field
delimiter
cut –f 3 –d “ “ Xfile

237. Append the file named Xfile to a file named Zfile


cat Xfile >> Zfile

238. Append files named Afile,Bfile and Cfile to a file named Zfile
cat Afile Bfile Cfile >> Zfile

239. Rename a file called Xfile to Zfile


mv Xfile Zfile

240. Display the content of the Xfile one screen at a time


more Xfile

241. Copy a file named Xfile to a file named Zfile and ask for confirmation before coping the
files
mv –i Xfile Zfile

242. Display the last 10 lines of the Xfile


tail -10 Xfile

243. Link (create another reference name) Xfile to Zfile


ln Xfile Zfile

Directions: Match the following commands to the corresponding descriptions. Place the letter that
indicates your answer on the line in front of each command.
a. deletes all the files in the current directory
b. lists only the invisible files
c. copies wc to yyy and asks for confirmation if yyy exists
d. displays a file called xxx
e. displays all the filenames that end with the letter a, b, c, or d
f. copies wc to yyy
g. displays all the filenames that begin with a or A
h. copies wc to xxx
i. counts the words and characters in wc and saves them in xxx
j. renames the file named xxx to yyy
244. __f___ cp wc yyy
245. __h___ cat cw >> xxx
246. __d___ cat < xxx
247. __i___ wc -cw wc >> xxx
248. __c___ cp -i wc yyy
249. __e___ ls *[a-d]
250. __a___ rm *
251. __b___ ls .*
252. __g___ ls [Aa]*
253. __j___ mv xxx yyy

Directions: Read the following scenario. Provide the command(s) in context of the environment
established in the scenario.
254. Display the word UNIX on the screen
echo “UNIX”

255. Display the * (asterisk) on the screen


echo “*”

256. Set a variable called Number to 10


Number=10

257. Delete (unset) the variable called Number


unset Number
258. Display the value of the variable called Number
echo $Number

259. Change the prompt string to a smiley face such as :-)


PS1=“:-) ”

260. Use the pipe operator to send the list of the files in the current directory to the printer
ls | lp

261. Delay execution of a command (say date command) for 2 minutes


sleep 120 ; date

262. Execute a command (say sort command) as a background process


sort Xfile &

263. Display the status of all processes


ps –a

264. List the signals used for the kill command


kill –l

265. Terminate the process identified by process ID 12345


kill 12345

266. Display a file named Xfile and at the same time save it in a file named Saved
cat Xfile ‘ tee saved

267. Look for the word UNIX in the files in the current director. Use an option that ignores
distinction between upper and lower case letters.
grep –i UNIX *

268. Sort a file named Xfile. Use an option that ignores distinction between upper and lower case
letters.
sort –f Xfile

269. Export the two variables called Var1 and Var2.


export Var1 Var2

270. Set the number of entries in the history file to 200


HISTSIZE=200

271. lists commands in the history list


fc –l or history

272. Set the option that prevents accidental log off when [Ctrl-d] key is used
set –o ignoreeof

273. Turn off the option that prevents accidental log off when [Ctrl-d] key is used
set +o ignoreeof

274. Set the option that prevents overwriting an existing file


set –o noclobber

275. Turn off the option that prevents overwriting an existing file
set +o noclobber

276. Turn on the command line editing option


set –o vi

277. Turn off the command line editing option


set +o vi

278. List the name of aliases


alias
Directions: Match the following commands to the corresponding descriptions. Place the letter that
indicates your answer on the line in front of each command.
a. removes the specified variable
b. displays the list of the shell variables
c. removes the specified process
d. displays the current directory and saves it in a file
e. finds the string hello in the specified file
f. displays exported variables
g. reassigns the prompt string
h. assigns value to variable HI
i. displays the status of all active processes
j. displays the content of the specified variable
k. makes letter D the alias name for the rm command
l. displays the 10th command from the history file
m. exports the variable called xyz
n. lists commands in the history list
o. shows the last command in the history file
p. sets the option to prevent overwriting an existing file
q. sets the option to prevent accidental log off when [Ctrl-d] key is
used
r. turns off the option that prevents overwriting an existing file
s. turns on the command line editing option
t. lists the name of aliases
279. __h___ HI= hello
280. __g___ PS1="Hi: "
281. __i___ ps -a
282. __j___ echo $HI
283. __b___ set
284. __c___ kill -9 11237
285. __f___ export
286. __d___ ls ³ tee xyz
287. __e___ grep hello xyz
288. __a___ unset xyz
289. __o___ G
290. __m___ export xyz
291. __s___ set -o vi
292. __l___ 10G
293. __k___ alias D=rm
294. __t___ alias
295. __p___ set -o noclobber
296. __q___ set -o ignoreeof
297. __n___ fc -l
298. __r___ set +o noclobber

Directions: Read the following scenario. Provide the command(s) in context of the environment
established in the scenario.
- Your home directory is /usr/students/project
- You have just logged in, and system informs you that you have
mail
- You have a file called myfile in your home directory
299. Send myfile to the user ID number DU007
mailx DU007 << myfile

300. Compose the following mail and send it to the user ID number DU007
mailx -s greeting DU007

301. Start composing the message


Hi, what a day!
Hi, what a nice day!

302. Read the current date and time and place it in your message
~ << ! date

303. Save your composed message in mymail file


~ w mymail
304. End your message
[Ctrl-d]

305. Mail myfile to yourself


mailx your login ID << myfile

306. Read your mail


mailx [return]

307. Display message number 3


3 [return]

308. Replay to the current message


R [return] replay message [Ctrl-d]

309. Delete message numbers 3 and 4


d3-4

310. Undelete all the deleted messages


U*

311. Save the message number 6 in mymail file


s6 mymail

312. Exit without removing the mail from your system mailbox
X

313. Display the message headers only


mailx –H

314. Read message number 1<%0>


1 [Return]

315. Replay to the message number 1


r 11

316. Delete message numbers 1 to 4


d 1-4

317. Exit mailx and remove mail from your system mailbox
q

318. Read your mail from another file, let's say mbox
mailx -f mbox

Direction: Read the following scenario. Provide the command(s) in the context of the environment
established in the scenario. Write your answers on the line under each question.

- Assume you have a script file called testing.


You execute testing as follows.
testing one two three and the rest
Write the output of the following commands
319. echo $0
test
320. echo $2
Two

321. echo $#
6

322. echo $@
one two three and the rest

323. echo $*
one two three and the rest

Direction: Read the following scenario. Provide the command(s) in the context of the environment
established in the scenario.
- Assuming the date string is
Wed Nov 29 14: 00: 52 EDT 2005
324. Write the output of the command: date +%H
14

325. Write the output of the command: date '+DATE: %m-%d-%y'


DATE: Nov-Wed-2001

326. Write the output of the following commands.


Y=`date +%y`
echo $Y

2001

327. Write the command(s) to display the sum of the variables x and y
sum=`expr $x + $y`
echo $sum

328. Write the command(s) to display the product of the variables x and y
product=`expr $x \* $y`
echo $product

329. Write the command that makes the file called Xfile an executable file
chmod u+x test

330. Write the script that displays "hi" five times, using the for loop
for x in 1 2 3 4 5
do
echo "hi"
done

331. Write the script that displays "hi" five times, using the while loop
count=1
while [ $count -lt 5 ]
do
echo "hi"
let count=count+1
done
332. Write the script that displays "hi" five times, using the until loop
count=1
until [ $count -gt 5 ]
do
echo "hi"
let count=count+1
done

333. Write the script that reads your name from the keyboard and displays (echoes) it on the
screen
echo "Enter your name: \c"
read name
echo "Your name is: $name"

334. Write a script file called cm (change mode) that changes the specified file mode to
executable.
The filename is specified on the command line as
follows:
cm xyz

chmod u+x "$1"

335. Write a script file called sdate that reads the system date and displays the date string in
the following format:
Time:
Day:
Month:
Year:
date '+Time: %H: %M%S'
date '+Day: %d'
date '+Month: %m'
date '+Year: %y'

Directions: Match the following commands to the corresponding outputs. Place the letter that
indicates your answer on the line in front of each command.
- You have the following two variables defined:
XYZ=HELLO EMPTY=
a. HELLO
b. BYE
c. Nothing is displayed
336. __a___ echo $XYZ
337. __c___ echo $EMPTY
338. __a___ echo ${XYZ: - "BYE"}
339. __b___ echo ${EMPTY: - "BYE"}
340. __b___ echo ${XYZ: + "BYE"}
341. __c___ echo ${EMPTY: + "BYE"}
342. __a___ echo ${XYZ: = "BYE"}
343. __b___ echo ${EMPTY: = "BYE"}
344. __a___ echo ${XYZ: ? "BYE"}
345. __b___ echo ${XYZ: ? "BYE"}

Direction: Write the following script files.


346. Write a script file called srm (super remove) that deletes the specified filename(s) and
asks for confirmation before deletion.
# super delete program
echo "Enter file(s) name you intend to delete: \c"
read filename
rm -i filename

347. Write a script file that shows the following menu and calls appropriate commands according
to the user selection.
My Super Duper menu
0: Exit
1: List Current Directory Files
2: Show Who Is Logged In

# menu program
tput clear
echo "0: exit"
echo "1: List Current Directory Files
echo "2: Show Who Is Logged In
echo "Selection: \c"
read selection
# checking the selection
case $selection in
0) exit ;;
1) ls -l ;;
2) who ;;
*) echo "sorry, wrong function"
esac

You might also like