Q n A OS
Q n A OS
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
Directions: Select the letter that indicates the best answer for the question.
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
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.
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
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]
Directions: Select the letter that indicates the best answer for the question.
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
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
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
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
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
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.
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
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
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
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
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]*
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
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
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
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
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
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
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
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.
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
221. Remove mydir directory (note: you have files in mydir directory)
rm –r mydir
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
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
236. Display the first 3 fields of the file named Xfile, using the space character as field
delimiter
cut –f 3 –d “ “ Xfile
238. Append files named Afile,Bfile and Cfile to a file named Zfile
cat Afile Bfile Cfile >> Zfile
241. Copy a file named Xfile to a file named Zfile and ask for confirmation before coping the
files
mv –i 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”
260. Use the pipe operator to send the list of the files in the current directory to the printer
ls | lp
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
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
275. Turn off the option that prevents overwriting an existing file
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
302. Read the current date and time and place it in your message
~ << ! date
312. Exit without removing the mail from your system mailbox
X
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.
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
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
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"}
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