Test #4 Multiple Choice Important Instructions 1. Read all the instructions and both sides of all pages. 2. Manage your time when answering questions on this test. Answer the questions you know, first. _________________________________________________________________ Multiple Choice - 44 Questions - 12 of 35% (Office use only: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44) 1. Which command sequence below does not generate an error message from the last command in the sequence? *a. mkdir ddd ddd/fff fff ; rmdir ddd/fff b. mkdir foo bar ; ln foo xxx c. date >foo ; cp foo/. bar d. cat /etc/passwd > mail idallen@idallen.ca e. mkdir foo ; touch foo/bar ; rmdir foo 2. What is the link count of directory x after this set of successful commands? mkdir x ; mkdir x/y ; mkdir x/z ; mkdir x/y/z *a. 4 b. 3 c. 2 d. 5 e. 1 3. What is the link count of directory d after this set of successful commands? mkdir d ; mkdir d/a ; touch d/b *a. 3 b. 2 c. 5 d. 1 e. 4 4. What is the link count of directory d after this set of successful commands? mkdir d ; touch f ; cd d ; ln ../f x *a. 2 b. 5 c. 3 d. 1 e. 4 5. What is the link count of directory d after this set of successful commands? mkdir d ; cd d ; touch f ; ln f x ; ln f y *a. 2 b. 5 c. 3 d. 1 e. 4 6. What is the link count of directory d after this set of successful commands? mkdir d ; cd d ; touch a ; mkdir b c d *a. 5 b. 4 c. 3 d. 2 e. 6 7. What is the link count of file f after this set of successful commands? rm f ; touch f ; cp f x ln f a ; ln x y ; ln a z ; ln x b *a. 3 b. 4 c. 5 d. 6 e. 2 8. What will appear on your screen after this sequence of commands: echo one >x ; ln x y ; echo ten >y ; echo two >x ; cat y *a. two b. ten c. one d. one followed by ten and two e. no output on screen 9. What will appear on your screen if you execute this sequence of commands in your home directory: ln /etc/passwd bar ; ln bar foo ; echo hi >foo ; cat foo *a. an error message and then the contents of the password file b. the conents of the password file followed by hi c. an error message and then hi d. hi e. foo 10. What will appear on your screen if you execute this sequence of commands: echo 1 >a ; ln a b ; echo 2 >b ; chmod 266 b ; cat a *a. an error message b. 1 c. 2 d. 1 followed by 2 e. no output on screen 11. Who is the owner of file bar after you execute this sequence of commands in your home directory: ln /etc/passwd x ; ln x y ; cp y z ; ln y bar *a. the file is owned by root b. you own the file bar c. the file is owned by home d. the file is owned by passwd e. you cannot execute the given commands; no file will be created 12. If file foo occupies two disk blocks, how many disk blocks are in use after this sequence of commands: cp foo bar ; ln bar one ; cp one two ; ln one ten *a. 6 blocks b. 4 blocks c. 2 blocks d. 8 blocks e. 10 blocks 13. What appears on your screen after this sequence of commands: echo 1 >x ; ln x y ; echo 2 >>y ; head -1 x >y ; cat y *a. empty file - no output on the screen b. 1 c. 2 d. 1 followed by 2 e. 2 followed by 1 14. What appears on your screen after this sequence of commands: echo 1 >x ; cp x y ; echo 2 >>y ; sort x >y ; cat y *a. 1 b. 1 followed by 2 c. 2 d. 2 followed by 1 e. empty file - no output on the screen 15. What appears on your screen after this sequence of commands: echo 1 >x ; ln x y ; echo 2 >>y ; sort x *a. 1 followed by 2 b. 1 c. 2 d. 2 followed by 1 e. empty file - no output on the screen 16. What is true about this output from ls -il foo bar 23 -rwxr----- 3 root root 2 Jul 31 12:33 foo 24 -rwxr----- 3 root root 2 Jul 31 12:33 bar *a. foo and bar are names for different files b. foo and bar are names for the same file c. foo and bar are two of three names for this file d. foo and bar each have two names (four names total) e. this output is not possible 17. What is true about this output from ls -il foo bar 72 -rwxrwxrwx 2 bin bin 3 Oct 30 09:23 foo 72 -r--r--r-- 2 bin bin 3 Oct 30 09:23 bar *a. this output is not possible b. foo and bar are names for different files c. foo and bar are names for the same file d. foo and bar are two of three names for this file e. foo and bar each have two names (four names total) 18. What is true about this output from ls -ild foo bar 96 -rwxr-xr-x 2 root root 3 Jan 24 01:03 foo 96 -rwxr-xr-x 3 root root 3 Jan 24 01:03 bar *a. this output is not possible b. foo and bar are names for different files c. foo and bar are names for the same file d. foo and bar are two of five names for this file e. foo and bar each have three names (six names total) 19. What is true about this output from ls -il foo bar 15 -r-x-----x 2 bin bin 3 Oct 30 09:23 foo 15 -r-x-----x 2 bin bin 3 Oct 30 09:23 bar *a. foo and bar are names for the same file b. foo and bar are names for different files c. foo and bar are two of three names for this file d. foo and bar each have three names (six names total) e. this output is not possible 20. What is true about this output from ls -il foo bar 35 -rw-rw-r-- 2 bin bin 3 Jan 24 01:03 foo 36 -rw-rw-r-- 2 bin bin 3 Jan 24 01:03 bar *a. foo and bar each have two names (four names total) b. foo and bar each have three names (six names total) c. foo and bar are names for the same file d. foo and bar are two of three names for this file e. this output is not possible 21. A Makefile contains the following target: ant: foo bar which means: *a. item ant depends on items foo and bar b. items foo and bar depend on item ant c. items ant and foo depend on item bar d. item bar depends on items ant and foo e. the syntax "ant:" is not valid in a Makefile target 22. A Makefile contains the following lines: one: rm foo bar This means: *a. if the user types "make one", items foo and bar will be removed b. if the user types "make foo", items foo and bar will be removed c. if the user types "make bar", items foo and bar will be removed d. if the user types "make rm", items foo and bar will be removed e. the syntax "one:" is not valid in a Makefile target 23. The correct g++ compiler suffix for a C++ source file is: *a. .cpp b. .cplus c. .g++ d. .gpp e. .C++ 24. The correct option to enable warning messages from the g++ compiler is: *a. -Wall b. -wALL c. -wall d. -warn e. +Warn 25. The default output file generated by the C and C++ compilers is named: *a. a.out b. a.cpp c. a.c++ d. a.o e. argv 26. In an empty directory, what is the length of the longest file name (including extension) after this sequence of commands? date >sixsix ; cp sixsix no ; mv sixsix four ; gzip no *a. 5 b. 4 c. 3 d. 2 e. 6 27. In an empty directory, what is the length of the longest file name (including extension) after this sequence of commands? date >four ; cp four five5 ; mv five5 hi ; bzip2 hi *a. 6 b. 5 c. 4 d. 3 e. 7 28. Which command line copies all the files from directory a to directory b? *a. cd a ; tar czf /tmp/i . ; cd ../b ; tar xzf /tmp/i b. cd a ; tar czf /tmp/i . ; cd ../b ; tar xvf /tmp/i c. cd a ; tar xf /tmp/i . ; cd ../b ; tar czvf /tmp/i d. cd a ; tar -r /tmp/i . ; cd ../b ; tar -rvx /tmp/i e. cd a ; tar -rc /tmp/i . ; cd ../b ; tar -rx /tmp/i 29. What is the output on your screen if a user signals an end- of-file from the keyboard during this command sequence? read input && echo $? *a. no output on screen b. $? c. 0 d. 1 e. an error message 30. What is the output on your screen if a user signals an end- of-file from the keyboard during this command sequence? read input || echo $? *a. 1 b. no output on screen c. $? d. 0 e. an error message 31. What is the output on your screen if a user signals an end- of-file from the keyboard during this command sequence? read input ; echo $? *a. 1 b. no output on screen c. $? d. 0 e. an error message 32. If variable a might contain nothing (a null value - defined but empty), which command sequence correctly tests for this and prints the date? *a. if test "" = "$a" ; then date ; fi b. if [ $a = /dev/null ] ; then date ; fi c. if test "" -eq $a ; then date ; fi d. if [ '''' = ''$a'' ] ; then date ; fi e. if [ "$a" = * ] ; then date ; fi 33. What is the output on your screen of the following sequence of commands: a=pig ; b=bat ; touch $b ; test -n $b ; echo $? *a. 0 b. 1 c. the number 0 or 1 followed by another 0 or 1 on a new line d. test: $b: integer expression expected e. no output 34. If directory /000 contains these three four-character file names: .abc, .xyz, .???, then what is the output on your screen of the following command line: echo /000/???? *a. /000/???? b. /000/.abc /000/.xyz /000/.??? c. /000/.abc /000/.xyz d. echo: /000/????: No such file or directory e. no output 35. Which command line below allows programs in the current directory to execute without preceding the names with ./? *a. PATH=/usr/bin:.:/bin b. PATH=/usr/bin/.:$HOME c. PATH=./$HOME:/usr/bin d. $PATH=/usr/bin:./bin e. $PATH=.:$HOME:/usr/bin 36. Which command sequence correctly searches for foo and then prints the date if it is found inside the file bar? *a. if grep pig ; echo one | tail pig *a. bat b. one c. bat followed by one d. one followed by bat e. an error message 39. If cow=cow and pig=pig then which of the following command lines outputs only the date (and nothing else)? *a. test cow = cow && date b. test cow -ne pig && date c. [!cow = pig] && date d. [cow -ne pig] || date e. [cow!=cow] || date 40. What is the output on your screen of this two-command sequence: cd /home || echo "cd $(pwd)" *a. no output b. cd /home c. cd 0pwd) d. cd $(pwd) e. /home 41. What is the output on your screen of this sequence of three shell commands: umask 475 ; mkdir dir ; ls -ld dir *a. d-wx----w- 2 it it 400 Jul 3 8:00 dir b. d-w-----w- 2 it it 400 Jul 3 8:00 dir c. d-wxrwx-w- 2 it it 400 Jul 3 8:00 dir d. dr--rwxr-x 2 it it 400 Jul 3 8:00 dir e. dr-xrwxr-x 2 it it 400 Jul 3 8:00 dir 42. What is the output on your screen of this sequence of three shell commands: echo ls >cat ; >cat ls cat ; wc cat *a. 1 1 4 cat b. 1 1 3 cat c. 1 1 2 cat d. 0 0 0 cat e. no output 43. What is the output on your screen of the following sequence of commands: x=0 ; [ $x = 00 ] ; echo $? *a. 1 b. 0 c. the number 0 or 1 followed by another 0 or 1 on a new line d. test: $x: integer expression expected e. no output 44. Select the correct bash shell order of command line processing: *a. aliases, redirection, variables, GLOBs b. aliases, variables, redirection, GLOBs c. aliases, variables, GLOBs, redirection d. aliases, GLOBs, variables, redirection e. redirection, aliases, GLOBs, variables Answer Key - DAT2330 - Ian Allen - Fall 2004 - DAT2330 Unix Test #4 - 35% Office use only: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 1. a 44 2. a 3. a Macro .cmd split no indent: 0 4. a Macro .cmd split with indent: 18 5. a Macro .ans splits: 0 6. a 7. a 8. a 9. a 10. a 11. a 12. a 13. a 14. a 15. a 16. a 17. a 18. a 19. a 20. a 21. a 22. a 23. a 24. a 25. a 26. a 27. a 28. a 29. a 30. a 31. a 32. a 33. a 34. a 35. a 36. a 37. a 38. a 39. a 40. a 41. a 42. a 43. a 44. a Count of a: 44 100% With 5 choices: 44 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43