Practice Test #2 Questions 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 - 278 Questions This is a practice test containing many practice questions. The real test will contain some questions similar to these. There are probably many more questions in this practice test than there will be time for in the real test. The real test will have approximately one question per minute. The real test may have some questions unlike anything given here. Knowing the concepts behind the questions is necessary; memorizing these specific answers won't help. (Office use only: 265 179 80 181 264 221 88 226 79 145 33 5 217 67 237 99 121 32 233 191 70 194 195 34 198 262 272 160 105 86 54 22 124 136 11 27 249 156 37 167 112 220 267 257 89 126 227 161 41 245 263 244 238 55 58 53 65 15 185 142 163 77 46 10 155 180 12 74 251 172 123 218 63 24 113 8 274 66 186 17 92 50 250 252 48 209 204 23 85 75 100 230 157 222 162 21 49 175 239 81 141 114 130 197 219 4 178 236 96 231 229 95 270 210 254 97 127 243 164 205 3 235 94 276 52 143 43 83 246 51 193 111 256 247 104 168 7 68 16 38 184 132 64 13 2 170 183 202 120 18 278 150 232 211 234 78 269 258 149 201 36 125 25 29 59 47 260 174 60 147 115 107 268 20 173 128 187 82 14 110 140 240 151 72 102 148 158 261 224 200 45 133 192 275 248 69 98 116 190 91 213 57 146 188 35 103 152 189 6 139 207 42 159 182 176 73 154 177 241 61 277 144 87 84 253 44 165 71 39 208 40 129 153 137 90 255 223 93 119 242 26 225 196 271 109 122 106 166 56 228 169 1 273 131 134 215 28 138 31 135 30 266 203 19 108 206 9 199 216 212 118 214 171 117 62 76 101 259) 1. Which of the following shell command lines displays only the names in the current directory that are exactly three numeric digits long? a. echo '0-9'0-9'0-9' b. echo '[0-9]''[0-9]''[0-9]' c. echo [1-3][1-3][1-3] d. echo ??? e. echo [0-9][0-9][0-9] 2. What is the output on your screen of this command sequence: true && echo Linux Rocks $? a. no output b. Linux Rocks 1 c. Linux Rocks ? d. Linux Rocks 0 e. Linux Rocks ? 3. If the file foo contained the word mom, what would be the output on your screen of this two command sequence: PATH=/bin/ps:/bin/echo:/bin/ls ; /bin/ls foo a. no output b. mom c. foo d. /bin/ls: foo: No such file or directory e. bash: /bin/ls: command not found 4. What is the output on your screen of this sequence of three shell commands: echo ls >fil ; >fil ls fil ; wc fil a. 1 1 2 fil b. 1 1 3 fil c. no output d. 0 0 0 fil e. 1 1 4 fil 5. Which of the following shell command lines displays all the names in the current directory that are exactly three letters (alphabetic) long (and nothing else)? a. echo [a-zA-Za-zA-Za-zA-Z] b. echo [a-zA-Z][a-zA-Z][a-zA-Z] c. echo ??? d. echo [azAZ][azAZ][azAZ] e. echo [a,zA,Z][a,zA,Z][a,zA,Z] 6. 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:./bin c. PATH=./$HOME:/usr/bin d. $PATH=.:$HOME:/usr/bin e. PATH=/usr/bin/.:$HOME 7. If your PATH variable contains /bin:/usr/bin, what is the output on your screen of this command line: echo '$PATH' a. '/bin:/usr/bin' b. $PATH c. /bin:/usr/bin d. echo: $PATH: No such file or directory e. '$PATH' 8. Which command line locates scripts in the /bin directory? a. cat /bin | file | grep script b. ls /bin/* | file | grep script c. cat /bin/* | file | grep script d. file /bin/* | grep script e. file /bin | grep script 9. If the file bat contained the word foo, what would be the output on your screen of this two command sequence: PATH=/etc/passwd:/bin/ls:/bin/cat ; /bin/ls bat a. bash: /bin/ls: command not found b. /bin/ls: bat: No such file or directory c. no output d. bat e. foo 10. What is the output on your screen of the following command sequence: f=1 ; touch f ; test ! -z $f ; echo $? a. no output b. 0 c. 1 d. the number 1 or 0 followed by another 1 or 0 on a new line e. test: $f: integer expression expected 11. If /bin/pig is a program that outputs hi and /usr/bin/pig is a program that outputs foo what is the output on your screen of this shell command sequence: PATH=/etc:/usr/bin:/bin ; pig a. hi b. hi followed by mom c. bash: pig: command not found d. foo e. foo followed by hi 12. A shell script named bar is executed as follows: ./bar "a b" "c d e" f Inside the script is the line: echo "$2" What is the output on your screen from this line? a. b" b. $2 c. c d e d. a b e. b 13. Which command line below allows programs in the current directory to execute without preceding the names with ./? a. PATH=/usr/bin/.:$HOME b. PATH=./$HOME:/usr/bin c. $PATH=/usr/bin:./$HOME d. PATH=/usr/bin:.:$HOME e. $PATH=$HOME:/usr/bin:. 14. If x=one and y=two then what is the output on your screen of the following sequence of commands: if $x = $y ; then echo $a ; fi a. test: one: integer expression expected b. test: $x: integer expression expected c. one d. bash: one: command not found e. no output 15. Which command sequence below does not generate an error message from the last command in the sequence? a. cat /etc/passwd > mail idallen@idallen.ca b. mkdir foo ; touch foo/bar ; rmdir foo c. date >foo ; cp foo/. bar d. mkdir ddd ddd/fff fff ; rmdir ddd/fff e. mkdir foo bar ; ln foo xxx 16. In an empty directory, what is the shell output on your screen of these three commands: touch .1 .2 .3 11 12 ; a='.1* .2*' ; echo '$a' a. 11 .1 12 .2 b. $a c. '.1* .2*' d. .1* .2* e. .1 .2 17. What is in the file cow after this command line: echo a >b ; echo b >a ; mv b a >cow a. no such file (nonexistent) b. b c. a d. nothing - empty file - no data e. a followed by b 18. If /bin/pig is a program that outputs hi and /usr/bin/pig is a program that outputs foo what is the output on your screen of this shell command sequence: PATH=/etc:/usr/bin:/bin ; pig a. foo followed by hi b. foo c. hi d. hi followed by foo e. bash: pig: command not found 19. Which command sequence below always outputs just the date only if the first argument is both a directory and not empty? a. if [ -s "$1" -a -d "$1" ]; then date ; fi b. if [ "$1" -eq -f -a "$1" -eq -d ]; then date ; fi c. if [ -n "$1" -o -d "$1" ]; then date ; fi d. if [ "-s $1" && "-d $1" ]; then date ; fi e. if [ -s -a -d "$1" ]; then date ; fi 20. What is the output on your screen of this two command sequence: PATH=/bin/cat:/bin/sh:/bin/ls ; ls nosuchfile a. bash: /bin/ls: command not found b. bash: ls: command not found c. bash: /bin/sh: No such file or directory d. ls: /bin/ls: command not found e. ls: nosuchfile: No such file or directory 21. If a shell script named foo contains the line: if [ '$1' = "$2" ] ; then echo SAME ; fi then which of the following command lines will produce SAME as output? a. ./foo bar '$1' b. ./foo 'bar' "bar" c. ./foo 1 "$1" d. ./foo bar 'bar' e. ./foo $1 $1 22. What is the output on your screen of this two command sequence: PATH=/bin/ls:/bin/wc:/bin/sh ; wc nosuchfile a. ls: /bin/wc: command not found b. bash: /bin/sh: No such file or directory c. bash: /bin/ls: command not found d. bash: wc: command not found e. wc: nosuchfile: No such file or directory 23. What is the output on your screen of this two-command sequence if run in a directory containing 123 files with names that are all the numbers from 1 to 123 inclusive: bat="*" ; echo "$bat" a. $bat b. the file names 1 through 123, surrounded by quotes c. * d. "$bat" e. the file names 1 through 123 24. If /bin/pig is a program that outputs xx and /usr/bin/pig is a program that outputs foo what is the output on your screen of this shell command sequence: PATH=/home:/bin:/dev:/usr/bin ; pig a. foo followed by xx b. foo c. bash: pig: command not found d. xx e. xx followed by foo 25. What is the output on your screen of this two-command sequence: cd /bin && echo "cd $(pwd)" a. cd /bin b. no output c. /bin d. cd $(pwd) e. cd 0pwd) 26. Which of the following bash PATH statements makes the most sense? a. PATH=/bin:/usr/bin:/etc/passwd b. PATH=/bin:/usr/bin:/etc c. PATH=/bin/sh:/usr/bin:/etc:/bin d. PATH=/bin:/bin/cat:/usr/bin e. PATH=/bin/ls:/etc:/usr/bin 27. Which of these first lines will cause this executable file to be interpreted using the Bash shell? a. !/bin/bash b. !#/bin/bash -u c. #!/bin/bash d. /bin/bash -u e. #/bin/bash 28. What is the output on your screen of the following sequence of commands: wc='one two' ; test wc = wc a. 0 b. 1 c. test: too many arguments d. no output e. 1 2 8 wc 29. In an empty directory, what is the length of the longest file name created by the following two-command sequence: a="1234 123 12 1" ; touch '$a' a. 4 characters b. 2 characters c. 3 characters d. 13 characters e. 1 character 30. If variable x might contain nothing (a null value - defined but empty), which command sequence correctly tests for this and prints OK? a. if [ $x -eq : ] ; then echo OK ; fi b. if [ $x -eq "" ] ; then echo OK ; fi c. if [ "$x" = * ] ; then echo OK ; fi d. if [ ''$x'' = '''' ] ; then echo OK ; fi e. if [ "$x" = "" ] ; then echo OK ; fi 31. If one were a file of text containing 10 different lines, what would be the output on your screen of this command line: cp one two ; diff one two a. several lines, which are the lines that are different between the two files b. an error message because diff doesn't allow different file names c. the contents of one of the files would be displayed d. no output on screen e. an error message because diff only allows one file name 32. How many arguments are passed to the command by the shell on this command line: bar bar bar a. 5 b. 3 c. 4 d. 2 e. 6 33. What is the correct syntax to redirect both standard output and standard error into the same output file? a. ls -l >foo 2>foo b. ls -l >foo 2>$1 c. ls -l 2>$1 >foo d. ls -l >foo 2>&1 e. ls -l 2>&1 >foo 34. 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. 0 b. 1 c. no output on screen d. $? e. an error message 35. Given my directory dir and my file dir/bar owned by me, which permissions allow me to delete the file dir/bar from the directory, but not change the content (data) in the file? a. Permissions 300 on directory dir and 500 on file dir/bar. b. Permissions 100 on directory dir and 200 on file dir/bar. c. Permissions 100 on directory dir and 100 on file dir/bar. d. Permissions 300 on directory dir and 300 on file dir/bar. e. Permissions 500 on directory dir and 400 on file dir/bar. 36. If /bin/foo is a program that outputs dad and /usr/bin/foo is a program that outputs mom what is the output on your screen of this shell command sequence: PATH=/usr:/etc:/bin:/usr/bin ; foo a. dad followed by mom b. dad c. mom d. mom followed by dad e. bash: foo: command not found 37. Which command tells you the count of lines in the bash manual page? a. apropos bash | wc b. man bash > wc ; cat wc c. man bash | wc d. which bash | wc e. whereis bash | wc 38. What is the output on your screen of the following sequence of commands: false && echo "foo bar $?" a. foo bar 1 b. foo bar 1 c. foo bar 0 d. no output e. foo bar 0 39. If bar is an executable script containing the line foo=dog then what is the output on your screen of this sequence of three commands: foo=cat ; ./bar ; echo "the '$foo' ate" a. the 'dog' ate b. the $foo ate c. the 'foo' ate d. the 'cat' ate e. the '$foo' ate 40. What is the output on your screen of the following sequence of commands: x=1 ; y=2 ; [ $x -ge $y ] ; echo $? a. 0 b. 1 c. the number 0 or 1 followed by another 0 or 1 on a new line d. no output e. test: $x: integer expression expected 41. Select the correct bash shell order of command line processing: a. quotes, variables, GLOBs, redirection b. redirection, quotes, GLOBs, variables c. quotes, GLOBs, variables, redirection d. quotes, variables, redirection, GLOBs e. quotes, redirection, variables, GLOBs 42. Which command line below allows programs in the current directory to execute without preceding the names with ./? a. PATH=./$HOME:/usr/bin b. PATH=/usr/bin/.:$HOME c. $PATH=/usr/bin:./bin d. PATH=/usr/bin:.:/bin e. $PATH=.:$HOME:/usr/bin 43. Which of the following shell command lines removes all the names in the current directory that are exactly three letters (alphabetic) long (and nothing else)? a. rm [azAZ][azAZ][azAZ] b. rm [3][3][3] c. rm ??? d. rm [a-zA-Z][a-zA-Z][a-zA-Z] e. rm [a-zA-Z,a-zA-Z,a-zA-Z] 44. Which of the command lines below can generate a non-empty file? a. sort -r /a/b >/a/b b. ls /a/b >/a/b c. grep -v /a/b /a/b >/a/b d. tr abc ABC /a/b e. tail -5 /a/b >/a/b 45. If your PATH variable contains /bin:/usr/bin, what is the output on your screen of this command line? echo '$PATH' a. $PATH b. echo: $PATH: No such file or directory c. '/bin:/usr/bin' d. /bin:/usr/bin e. '$PATH' 46. What is the correct syntax to redirect both standard output and standard error into the same output file? a. wc >out 2>1 foo b. wc >out 2>out foo c. wc >out 2>&1 foo d. wc 2>1 >out foo e. wc 2>&1 >out foo 47. Which command line shows just the count of lines in the file? a. wc file | awk '{print #1}' b. wc file | awk '{print $1}' c. wc file | awk '{print 1}' d. wc file | awk '[print $1]' e. wc file | awk '[print #1]' 48. What is the output on your screen of the following sequence of commands: x=0 ; [ $x = 00 ] ; echo $? a. 1 b. 0 c. no output d. test: $x: integer expression expected e. the number 0 or 1 followed by another 0 or 1 on a new line 49. If cow=cow and pig=pig then which of the following command lines outputs only the date (and nothing else)? a. test cow -ne pig && date b. [cow -ne pig] || date c. test cow = cow && date d. [cow!=cow] || date e. [!cow = pig] && date 50. Which command sequence correctly searches for the chars and then prints OK if it is found inside the password file? a. grep chars /etc/passwd || echo OK c. grep chars /etc/passwd && echo OK 51. Which of the following shell command lines displays all the names in the current directory that are exactly three letters (alphabetic) long (and nothing else)? a. echo [0-89][01-9][0-45-9] b. echo [a-mn-zA-YZ][ab-zAB-YZ][za-yZA-Y] c. echo [a,zA,Z][a,zA,Z][a,zA,Z] d. echo [azAZ][azAZ][azAZ] e. echo ??? 52. Which command sequence correctly searches for str and then prints OK if it is found inside the file foo? a. if test str foo ; then echo OK ; fi b. if [ test str foo ] ; then echo OK ; fi c. if grep one ; mv one/. bar d. mkdir one one/two ; rmdir one e. cat /etc/passwd > mail idallen@ncf.ca 54. If a=1 and b=1, which command sequence correctly compares the two numbers as equal and prints OK? a. if [ $a -eq $b ] ; then echo OK ; fi b. if test a -eq b ; then echo OK ; fi c. if ( a == b ) ; then echo OK ; fi d. if [ $a==$b ] ; then echo OK ; fi e. if [ a = b ] ; then echo OK ; fi 55. If a=ant and b=bat then what is the output on your screen of the following command sequence: [ $a = ant -a $b = ant ] ; echo $? a. 1 b. no output c. the number 1 or 0 followed by another 1 or 0 on a new line d. 0 e. test: $a: integer expression expected 56. If happy were a file of text containing 50 different lines, what would be the output on your screen of this exact command line: diff happy happy a. an error message because diff only allows one file name b. the contents of file happy would be displayed c. an error message because diff doesn't allow the same file name twice d. no output e. several lines, which are the lines that are different between the two files 57. If a=xxx and b=yyy then what is the output on your screen of the following sequence of commands: if $a = $b ; then echo $a ; fi a. no output b. test: $a: integer expression expected c. test: xxx: integer expression expected d. xxx e. bash: xxx: command not found 58. Given my directory dir and my file dir/foo owned by me, which permissions allow me to delete the file dir/foo from the directory, but not change the content (data) in the file? a. Permissions 300 on directory dir and 500 on file dir/foo. b. Permissions 300 on directory dir and 300 on file dir/foo. c. Permissions 100 on directory dir and 200 on file dir/foo. d. Permissions 500 on directory dir and 400 on file dir/foo. e. Permissions 100 on directory dir and 100 on file dir/foo. 59. What is the output on your screen of this sequence of three shell commands: umask 457 ; mkdir newdir ; ls -ld newdir a. dr--r-xrwx 2 me me 512 Oct 1 1:12 newdir b. dr-xr-xrwx 2 me me 512 Oct 1 1:12 newdir c. d-wx-w-rwx 2 me me 512 Oct 1 1:12 newdir d. d-w--w---- 2 me me 512 Oct 1 1:12 newdir e. d-wx-w---- 2 me me 512 Oct 1 1:12 newdir 60. What is the output on your screen of the following command sequence: date='Friday March 12' ; test date = date a. no output b. 0 c. test: too many arguments d. 1 e. Fri Mar 12 10:20:39 EST 2004 61. What is the output on your screen of the following sequence of commands: x=0 ; test $x ; echo $? a. test: $x: integer expression expected b. 0 c. no output d. 1 e. the number 0 or 1 followed by another 0 or 1 on a new line 62. If the file bat contained the word foo, what would be the output on your screen of this two command sequence: PATH=/bin/cat:/bin/who:/bin/ls ; cat bat a. foo b. no output on screen c. bat d. bash: cat: command not found e. cat: bat: No such file or directory 63. If foo is a file containing the first column of the output of the last command, which command line shows the most frequent login? a. uniq -c foo | sort -nr | head -1 b. cat sort foo | uniq -c | sort -nr | head -1 c. sort foo > uniq -c ; sort -nr uniq | head -1 d. sort foo | uniq -c | sort -nr | head -1 e. sort | uniq -c | sort -nr | head -1 foo 64. Given my directory dir and my file dir/bar owned by me, which permissions allow me to delete the file dir/bar from the directory, but not change the content (data) in the file? a. Permissions 100 on directory dir and 300 on file dir/bar. b. Permissions 100 on directory dir and 500 on file dir/bar. c. Permissions 300 on directory dir and 200 on file dir/bar. d. Permissions 300 on directory dir and 400 on file dir/bar. e. Permissions 500 on directory dir and 500 on file dir/bar. 65. What is the output on your screen of the following sequence of commands: date='October Monday' ; test date = date a. 0 b. test: too many arguments c. no output d. Mon Oct 27 17:01:38 EST 2003 e. 1 66. 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 3 cat b. 1 1 4 cat c. no output d. 0 0 0 cat e. 1 1 2 cat 67. Given my directory dir and my file dir/fil owned by me, which permissions allow me to access and change the content (data) in the file but not delete the file? a. Permissions 100 on directory dir and 200 on file dir/fil. b. Permissions 500 on directory dir and 500 on file dir/fil. c. Permissions 700 on directory dir and 300 on file dir/fil. d. Permissions 300 on directory dir and 500 on file dir/fil. e. Permissions 600 on directory dir and 200 on file dir/fil. 68. If directory /dir contains these three four-character file names: .123, .124, .???, then what is the output on your screen of the following command line: echo /dir/???? a. echo: /dir/????: No such file or directory b. /dir/.123 /dir/.124 c. /dir/.123 /dir/.124 /dir/.??? d. /dir/???? e. no output 69. Which correct command sequence below always outputs just the date only if the first argument is both not empty and a directory? a. if [ "$1" -eq -f -a "$1" -eq -d ]; then date ; fi b. if [ -s -a -d "$1" ]; then date ; fi c. if [ -d "$1" -a -s "$1" ]; then date ; fi d. if [ -s && -d "$1" ]; then date ; fi e. if [ "-s $1" && "-d $1" ]; then date ; fi 70. What is the output on your screen of the following sequence of commands: x=ok ; y=ok ; [ x = y ] a. 0 b. test: x: integer expression expected c. 1 d. no output e. bash: x: command not found 71. What is the correct syntax to redirect both standard output and standard error into the same output file? a. command 2>out >out b. command >out 2>&1 c. command 2>&1 >out d. command >out 2>1 e. command 2>1 >out 72. Which command line below allows programs in the current directory to execute without preceding the names with ./? a. PATH = ./$HOME:/bin b. PATH = /bin:$HOME:. c. PATH=/bin:$HOME:. d. $PATH=.:$HOME:/bin e. $PATH=/bin:./$HOME 73. If a=cow and b=dog then what is the output on your screen of the following sequence of commands: [ $a = dog -o $b = dog ] ; echo $? a. 0 b. test: $a: integer expression expected c. no output d. 1 e. the number 1 or 0 followed by another 1 or 0 on a new line 74. How many arguments are passed to the command by the shell on this command line: bat bat bat a. 2 b. 5 c. 6 d. 4 e. 3 75. The correct g++ compiler suffix for a C++ source file is: a. .C++ b. .gpp c. .cpp d. .g++ e. .cplus 76. Given my directory dir and my file dir/bar owned by me, which permissions allow me to access and change the content (data) in the file dir/bar but not delete the file? a. Permissions 700 on directory dir and 300 on file dir/bar. b. Permissions 300 on directory dir and 500 on file dir/bar. c. Permissions 100 on directory dir and 200 on file dir/bar. d. Permissions 500 on directory dir and 500 on file dir/bar. e. Permissions 600 on directory dir and 200 on file dir/bar. 77. Which of these statements is true? a. If /p is an empty directory, sort /p/* produces an error message. b. Typing ./script and bash script always give identical results. c. Only single quotes are strong enough to stop shell GLOB (wildcard) patterns from expanding. d. The rm file command looks up the file name argument file in your $PATH. e. If /x is an empty directory, echo /x/* produces an error message. 78. If x=5 and y=5, which command sequence correctly compares the two numbers as equal and prints OK? a. if ( x == y ) ; then echo OK ; fi b. if [ $x==$y ] ; then echo OK ; fi c. if test $x -eq $y ; then echo OK ; fi d. if [ x = y ] ; then echo OK ; fi e. if test x -eq y ; then echo OK ; fi 79. 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. dr-xrwxr-x 2 it it 400 Jul 3 8:00 dir c. d-wxrwx-w- 2 it it 400 Jul 3 8:00 dir d. d-w-----w- 2 it it 400 Jul 3 8:00 dir e. dr--rwxr-x 2 it it 400 Jul 3 8:00 dir 80. Given the following command line: read xx yy zz which user keyboard input line below will assign the text 22 to the shell variable named yy? a. 11 22 33 b. 11;22;33 c. 11:22:33 d. 11,22,33 e. xx=11 yy=22 zz=33 81. In an empty directory, how many lines are in file bar after this command line: ls . nosuchfile 1>bar a. 2 b. empty file (no data) c. 4 d. 1 e. 3 82. If foo is an executable script containing the line: PATH=/etc ; export PATH what is the output on your screen of the following sequence of commands: PATH=/bin ; ./foo ; echo "$PATH" a. /bin b. $PATH c. /bin:/etc d. ./foo e. /etc 83. Which command tells you the full absolute pathname of the lynx command? a. absolute "$PATH" | grep lynx b. whereis lynx c. echo "$PATH" | grep lynx d. whereis | grep lynx e. absolute lynx 84. Which line below is most likely to be the beginning of an error message? a. echo 2<$1 "... " b. echo 1<&2 "... " c. echo 1>&2 "... " d. echo 2>$1 "... " e. echo 2>&1 "... " 85. If foo is a script containing the line TERM=vt100 ; export TERM, what is the output on your screen of the following sequence of commands: TERM=linux ; ./foo ; echo $TERM a. linux b. foo c. vt100 d. $TERM e. TERM 86. 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 are names for the same file b. foo and bar are two of three names for this file c. foo and bar each have two names (four names total) d. this output is not possible e. foo and bar each have three names (six names total) 87. What is the possible output on your screen of this command line: echo wc >date ; sort date >date ; cat date a. no output on screen b. wc c. Mon Sep 27 15:58:34 EDT 2004 d. 1 6 28 date e. 1 6 29 date 88. How many arguments are passed to the command by the shell on this command line: bar" bar >out a. 4 b. 2 c. 5 d. 3 e. 6 89. If variable mt might contain nothing (a null value - defined but empty), which command sequence correctly tests for this and prints OK? a. if [ $mt -eq : ] ; then echo OK ; fi b. if [ $mt -eq "" ] ; then echo OK ; fi c. if [ "$mt" = "" ] ; then echo OK ; fi d. if [ "$mt" = * ] ; then echo OK ; fi e. if [ ''$mt'' = '''' ] ; then echo OK ; fi 90. If file foo contains nine lines, each of which is the number of the line in the file, what is the output on your screen of this command: cat foo foo | sort | tail -4 | head -1 a. no output b. 4 c. 6 d. 8 e. 1 91. In an empty directory, what is the shell output on your screen of these three commands: touch xx .x xy .y xz ; x='x* y*' ; echo "$x" a. *x *y b. x* y* c. xx xy d. xx xy xz y* e. $x 92. Which command line shows the file in /bin with the largest checksum? a. sum /bin | sort -nr | head -1 b. cat /bin | sum | sort -nr | head -1 c. cat /bin/* | sum | sort -nr | head -1 d. sum /bin/* | sort -nr | head -1 e. ls /bin/* | sum | sort -nr | head -1 93. What is the output on your screen of the following sequence of commands: false && echo "linux rocks $?" a. linux rocks 1 b. linux rocks 0 c. no output d. linux rocks 0 e. linux rocks 1 94. Which command line below allows the shell to execute programs in the current directory without preceding the names with ./? a. PATH=./dev:./bin b. PATH=/usr/bin/.:/dev/null c. PATH=./dev:/usr/bin d. PATH=/etc:/dev:. e. PATH=/bin/.:.. 95. What is the output on your screen of the following sequence of commands: x=0 ; [ $x ] ; echo $? a. 0 b. the number 0 or 1 followed by another 0 or 1 on a new line c. 1 d. test: $x: unary operator expected e. no output 96. How many arguments and options are there to the command: wc wc a. One argument: a single option argument with two option letters. b. Three arguments, each of which is a pathname argument. c. Two arguments: an input file and an option argument with two options. d. Four arguments, only one of which is an option argument with two options. e. Three arguments: two file names and one option argument with two options. 97. If foo is an executable script containing the line: PATH=/bin ; export PATH what is the output on your screen of the following sequence of commands: PATH=/etc ; ./foo ; echo "$PATH" a. /bin b. foo c. /etc:/bin d. $PATH e. /etc 98. What is the output on your screen of this command sequence: echo pig >one ; echo bat | tail one a. bat followed by pig b. an error message c. pig d. pig followed by bat e. bat 99. Which command sequence below does not generate an error message from the last command in the sequence? a. mkdir foo foo/bar ; rmdir foo b. date >foo ; cp foo/. bar c. mkdir foo ; ln foo bar d. cat /etc/passwd > mail idallen@ncf.ca e. mkdir one one/two ; rmdir one/two 100. If the file foo contained the word mom, what would be the output on your screen of this two command sequence: PATH=/bin/ps:/bin/echo:/bin/ls ; /bin/ls foo a. mom b. no output on screen c. /bin/ls: foo: No such file or directory d. foo e. bash: /bin/ls: command not found 101. What is the output on your screen of the following command sequence: cd /etc/passwd && echo "in $(pwd)" a. bash: cd: /etc/passwd: Not a directory b. no output c. in /etc d. in $(pwd) e. in 0pwd) 102. The correct option to enable warning messages from the g++ compiler is: a. +Warn b. -wall c. -Wall d. -wALL e. -warn 103. What is the link count of directory d after this set of successful commands? mkdir d ; touch f ; cd d ; ln ../f x a. 3 b. 5 c. 1 d. 4 e. 2 104. What is the output on your screen of this two-command sequence if run in a directory containing 888 files with names that are all the numbers from 1 to 888 inclusive: cow="*" ; echo '$cow' a. '$cow' b. the file names 1 through 888 c. the file names 1 through 888, surrounded by quotes d. * e. $cow 105. Which command line below allows programs in the current directory to execute without preceding the names with ./? a. PATH=/usr/bin:$HOME:. b. $PATH=/usr/bin:./$HOME c. PATH=./$HOME:/usr/bin d. PATH=/usr/bin/.:$HOME e. $PATH=.:$HOME:/usr/bin 106. A Makefile contains the following target: foo: bar ant which means: a. items foo and bar depend on item ant b. items bar and ant depend on item foo c. the syntax "foo:" is not valid in a Makefile target d. item ant depends on items foo and bar e. item foo depends on items bar and ant 107. What is the output on your screen of this command sequence: true && echo Hello There $? a. Hello There ? b. Hello There 0 c. Hello There ? d. no output e. Hello There 1 108. Which command sequence below always outputs just the date only if the first argument is either readable or executable? a. if [ "$1" -eq -r -o "$1" -eq -x ]; then date ; fi b. if [ -r -o -x "$1" ]; then date ; fi c. if [ -r || -x "$1" ]; then date ; fi d. if [ -r "$1" -o -x "$1" ]; then date ; fi e. if [ "-r $1" || "-x $1" ]; then date ; fi 109. In an empty directory, what appears on your screen after this command line? ls 2>/dev/null nosuchfile a. ls: nosuchfile: No such file or directory b. no output c. nosuchfile d. ls: 2>/dev/null nosuchfile: No such file or directory e. ls: /dev/null: No such file or directory 110. Which command line tells you the recursive count of all pathnames under the current directory and all subdirectories? a. wc "$PATH" b. ls | wc c. find | wc d. wc . e. wc * 111. Which command line shows the current date? a. date | bash b. bash >date ; cat date c. echo date | bash d. bash /dev/null nosuchfile a. ls: 1>/dev/null nosuchfile: No such file or directory b. no output c. ls: nosuchfile: No such file or directory d. ls: /dev/null: No such file or directory e. nosuchfile 113. Which of these commands makes a file owned by me, also readable by me? a. umask 300 ./myfile b. chmod r=u ./myfile c. chmod u+r ./myfile d. chmod r+u myfile e. umask 400 myfile 114. 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. 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 two names (four names total) e. this output is not possible 115. Which line below passes three separate arguments to the sort command when placed inside a shell script named foo invoked by the command line: ./foo 111 222 333 a. sort "$#" b. sort "$@" c. sort "$1 $2 $3" d. sort "$*" e. sort "$? $? $?" 116. In an empty directory, what appears on your screen after this command line? ls out 2>/dev/null a. ls: /dev/null: No such file or directory b. out c. ls: out: No such file or directory d. no output e. ls: out 2>/dev/null: No such file or directory 117. 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. 2 b. 3 c. 4 d. 5 e. 6 118. Which command sequence correctly searches for foo and then prints the date if it is found inside the file bar? a. if test foo = bar ; then date ; fi b. if grep out a. no output (empty file) b. 1 c. 3 d. 4 e. 2 124. Which of these statements is true? a. Unix commands must be entered in lower-case letters. b. To erase an entire line of typing, type [CTRL]-[D]. c. You can only login to Unix once per userid; you cannot be logged in to the same machine twice. d. Unix commands can be entered in upper-case or lower-case letters; they are equivalent. e. To indicate End-of-File (no more input), type [CTRL]-[C]. 125. If happy were a file of text containing 50 different lines, what would be the output on your screen of this exact command line: cp happy sad ; diff happy sad a. an error message because diff only allows one file name b. no output c. several lines, which are the lines that are different between the two files d. an error message because diff doesn't allow different file names e. the contents of file happy would be displayed 126. What is the output on your screen of the following command sequence: echo hi >wc ; wc wc >hi ; cat hi a. 1 1 2 wc b. hi c. 1 1 3 wc d. 0 0 0 wc e. no output 127. If dog is an executable script containing the line: umask 0777 what is the output on your screen of the following sequence of commands: umask 0022 ; ./dog ; umask a. nothing; no output b. 0022 c. 0799 d. 0755 e. 0777 128. If the file pig contained the word foo, what would be the output on your screen of this two command sequence: PATH=/etc/passwd:/bin/ls:/bin/cat ; /bin/ls pig a. pig b. bash: /bin/ls: command not found c. /bin/ls: pig: No such file or directory d. foo e. no output 129. Which command sequence correctly searches for the chars and then prints OK if it is found inside the password file? a. if [ test chars /etc/passwd ] ; then echo OK ; fi b. if [ grep chars /etc/passwd ] ; then echo OK ; fi c. if test chars /etc/passwd ; then echo OK ; fi d. if grep chars /etc/passwd ; then echo OK ; fi e. if test chars = /etc/passwd ; then echo OK ; fi 130. If foo were a file of text containing 50 different lines, what would be the output on your screen of this exact command line: diff foo foo a. the contents of file foo would be displayed b. an error message because diff doesn't allow the same file name twice c. an error message because diff only allows one file name d. no output e. several lines, which are the lines that are different between the two files 131. What is the output on your screen of this two command sequence: PATH=/bin/ls:/bin/head:/bin/sh ; head nosuchfile a. bash: /bin/ls: command not found b. bash: head: command not found c. bash: /bin/sh: No such file or directory d. ls: /bin/head: command not found e. head: nosuchfile: No such file or directory 132. In response to the following command line: read var1 var2 var3 which user keyboard input line below will assign the text three to the shell variable named var3? a. one:two:three b. one,two,three c. var1=one var2=two var3=three d. $var1="one" $var2="two" $var3="three" e. one two three 133. Which line below puts the count of the number of lines in the password file into the variable foo? a. foo=$( cat -c /etc/passwd ) b. foo=[ grep -c /etc/passwd ] c. foo=[ wc /etc/passwd | echo $1 ] d. foo=[ cat -l /etc/passwd ] e. foo=$( wc -l sixsix ; mv sixsix four ; cp four hi ; gzip hi a. 3 b. 2 c. 4 d. 5 e. 6 136. What is the output on your screen of the following sequence of commands: x=1 ; y=2 ; test $x -le $y ; echo $? a. the number 0 or 1 followed by another 0 or 1 on a new line b. 1 c. test: $x: integer expression expected d. no output e. 0 137. Given my directory ddd and my file ddd/fff owned by me, which permissions allow me to delete the file from the directory, but not change the content (data) in the file? a. Permissions 500 on directory ddd and 400 on file ddd/fff. b. Permissions 300 on directory ddd and 500 on file ddd/fff. c. Permissions 100 on directory ddd and 200 on file ddd/fff. d. Permissions 300 on directory ddd and 300 on file ddd/fff. e. Permissions 100 on directory ddd and 100 on file ddd/fff. 138. If x=pig and y=dog then what is the output on your screen of the following sequence of commands: if $x = $y ; then echo $y ; fi a. dog b. bash: pig: command not found c. no output d. test: pig: integer expression expected e. test: $x: integer expression expected 139. Given the following command line: read one two three which user keyboard input line below will assign the text bb to the shell variable named two? a. aa;bb;cc b. aa bb cc c. aa:bb:cc d. aa,bb,cc e. one=aa two=bb three=cc 140. If bar is an executable script containing the line: TERM=vt100 ; export TERM what is the output on your screen of the following sequence of commands: TERM=linux ; ./bar ; echo "$TERM" a. vt100 b. linux c. TERM d. $TERM e. ./bar 141. What is the output on your screen of this sequence of three shell commands: umask 457 ; mkdir dir ; ls -ld dir a. dr--r-xrwx 2 me me 128 Jan 9 9:34 dir b. d-w--w---- 2 me me 128 Jan 9 9:34 dir c. dr-xr-xrwx 2 me me 128 Jan 9 9:34 dir d. d-wx-w-rwx 2 me me 128 Jan 9 9:34 dir e. d-wx-w---- 2 me me 128 Jan 9 9:34 dir 142. 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. 6 b. 2 c. 3 d. 4 e. 5 143. If a=cow and b=dog then what is the output on your screen of the following sequence of commands: if $a = $b ; then echo $a ; fi a. bash: cow: command not found b. test: $a: integer expression expected c. no output d. cow e. test: cow: integer expression expected 144. Given my directory dir and my file dir/foo owned by me, which permissions allow me to access and change the content (data) in the file dir/foo but not delete the file? a. Permissions 500 on directory dir and 600 on file dir/foo. b. Permissions 400 on directory dir and 400 on file dir/foo. c. Permissions 600 on directory dir and 700 on file dir/foo. d. Permissions 300 on directory dir and 200 on file dir/foo. e. Permissions 100 on directory dir and 100 on file dir/foo. 145. A Makefile contains the following lines: one: rm foo bar This means: a. if the user types "make bar", items foo and bar will be removed b. if the user types "make one", items foo and bar will be removed c. if the user types "make rm", items foo and bar will be removed d. the syntax "one:" is not valid in a Makefile target e. if the user types "make foo", items foo and bar will be removed 146. What is the output on your screen of the following sequence of commands: x=cow ; y=dog ; touch $x ; test -z $x ; echo $? a. test: $x: integer expression expected b. the number 0 or 1 followed by another 0 or 1 on a new line c. 0 d. 1 e. no output 147. What is the output on your screen of this sequence of three shell commands: umask 162 ; touch newfile ; ls -l newfile a. -rw----r-- 1 me me 0 Oct 1 01:12 newfile b. -rw---x-w- 1 me me 0 Oct 1 01:12 newfile c. ---xrw--w- 1 me me 0 Oct 1 01:12 newfile d. ----rw--w- 1 me me 0 Oct 1 01:12 newfile e. -rw---xr-x 1 me me 0 Oct 1 01:12 newfile 148. What is the output on your screen of this two-command sequence: cd /etc/passwd && echo "in $(pwd)" a. no output b. in $(pwd) c. in /etc d. bash: cd: /etc/passwd: Not a directory e. in 0pwd) 149. What can you do to get back (redo) the last command you typed to the bash (Linux) shell? a. Type [ALT]-[F2] b. Type [CONTROL]-[ALT]-[DEL] c. Type [CONTROL]-[BACKSPACE] d. Use the "PageUp" key. e. Use the "UpArrow" key. 150. How can you ask the bash (Linux) shell to complete commands or file names for you? a. Type the first part of the command or file name and press the [CTRL]-[D] key. b. Type the first part of the command or file name and press the [ALT]-[F1] key. c. Type the first part of the command or file name and press the [ALT] key. d. Type the first part of the command or file name and press the [TAB] key. e. Type the first part of the command or file name and press the [CTRL]-[C] key. 151. what is the output on your screen of the following command sequence: true && echo Linux Rocks $? a. Linux Rocks ? b. no output c. Linux Rocks $? d. Linux Rocks 1 e. Linux Rocks 0 152. What is the output on your screen of the following sequence of commands: a=cow ; b=dog ; touch $a ; test -z $a ; echo $? a. 1 b. no output c. 0 d. test: $a: integer expression expected e. the number 1 or 0 followed by another 1 or 0 on a new line 153. Which command sends a file to a remote machine foo.ca? a. mv one foo.ca:two b. cat one >foo.ca:two c. scp one >foo.ca:two d. cp one foo.ca:two e. scp one foo.ca:two 154. 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 two of five names for this file d. foo and bar each have three names (six names total) e. foo and bar are names for the same file 155. Which command sequence below always outputs just the date only if the first argument is both not empty and a directory? a. if [ -d "$1" -a -s "$1" ]; then date ; fi b. if [ -s && -d "$1" ]; then date ; fi c. if [ "-s $1" && "-d $1" ]; then date ; fi d. if [ -s -a -d "$1" ]; then date ; fi e. if [ "$1" -eq -f -a "$1" -eq -d ]; then date ; fi 156. If the file bat contained the word foo, what would be the output on your screen of this two command sequence: PATH=/bin/ls:/bin/who:/etc/passwd ; /bin/ls bat a. foo b. bat c. no output d. bash: /bin/ls: command not found e. /bin/ls: bat: No such file or directory 157. Which of these commands makes a file owned by me, also executable by me? a. umask 111 myfile b. umask 777 myfile c. chmod u+x ./myfile d. chmod x+u myfile e. chmod x=u ./myfile 158. Which of the command lines below can generate a non-empty file? a. tail -5 /out >/out b. tr abc ABC /out c. grep -v /out /out >/out d. ls /out >/out e. sort -r /out >/out 159. What is the output on your screen of the following sequence of commands: a=9 ; b=9 ; [ $a -le $b ] ; echo $? a. 0 b. test: $a: integer expression expected c. the number 1 or 0 followed by another 1 or 0 on a new line d. no output e. 1 160. What is the output on your screen of this two-command sequence: cd /etc || echo "cd $(pwd)" a. cd /etc b. cd $(pwd) c. no output d. /etc e. cd 0pwd) 161. If bar is an executable script containing the line dog=bat then what is the output on your screen of this sequence of three commands: dog=cat ; ./bar ; echo "the '$dog' ate" a. the '$dog' ate b. the 'dog' ate c. the 'bat' ate d. the 'cat' ate e. the $dog ate 162. What is the correct syntax to redirect both standard output and standard error into the same output file? a. sum foo 1>out 2>1 b. sum 2>&1 foo >out c. sum 1>out 2>out foo d. sum >out foo 2>&1 e. sum 2>1 >out foo 163. If /bin/bat is a program that outputs foo and /usr/bin/bat is a program that outputs hi what is the output on your screen of this shell command sequence: PATH=/usr:/usr/bin:/bin ; bat a. foo followed by hi b. bash: bat: command not found c. hi followed by foo d. foo e. hi 164. If /bin/foo is a program that outputs one and /usr/bin/foo is a program that outputs two, what is the output on your screen of this command sequence: PATH=/bin/ls:/home:/usr/bin/cat:/etc ; foo a. one followed by two b. one c. bash: foo: command not found d. two e. two followed by one 165. If a=ant and b=bat then what is the output on your screen of the following command sequence: [ $a = bat -o $b = bat ] ; echo $? a. no output b. the number 1 or 0 followed by another 1 or 0 on a new line c. test: $a: integer expression expected d. 1 e. 0 166. If foo is a script containing the line TERM=linux ; export TERM, what is the output on your screen of the following sequence of commands: TERM=vt100 ; ./foo ; echo "$TERM" a. $TERM b. TERM c. foo d. vt100 e. linux 167. Which of the following PATH statements makes the most sense? a. PATH=/dev/null:/usr/bin:/etc:/bin b. PATH=/bin/ls:/etc:/usr/bin c. PATH=/dev:/bin:/usr/bin:/etc d. PATH=/bin:/bin/cat:/usr/bin e. PATH=/bin:/usr/bin:/etc/passwd 168. What is the output on your screen of this command sequence: echo bat >pig ; echo one | tail pig a. bat b. bat followed by one c. an error message d. one e. one followed by bat 169. If a=cow and b=dog then what is the output on your screen of the following sequence of commands: [ $a = cow -a $b = cow ] ; echo $? a. 1 b. the number 1 or 0 followed by another 1 or 0 on a new line c. test: $a: integer expression expected d. 0 e. no output 170. What is the output on your screen of the following command sequence: x=1 ; y=2 ; test $x -le $y ; echo $? a. 0 b. the number 0 or 1 followed by another 0 or 1 on a new line c. test: $x: integer expression expected d. 1 e. no output 171. The default output file generated by the C and C++ compilers is named: a. a.o b. a.c++ c. a.cpp d. argv e. a.out 172. In an empty directory, what is the length of the longest file name created by the following two-command sequence: var='1 12 123 1234 12345' ; touch '$var' a. 4 characters b. 2 characters c. 19 characters d. 5 characters e. 3 characters 173. Which of the following statements is true about this shell command line: >foo file bar haven a. Error: The command name is missing from the command line. b. The command file sees three arguments. c. The command file sees two arguments. d. The command foo sees three arguments. e. The command foo sees only two arguments 174. How many arguments and options are there to the command: wc sixsix ; cp sixsix no ; mv sixsix four ; gzip no a. 4 b. 3 c. 5 d. 6 e. 2 186. What is the output on your screen of the following sequence of commands: a=1 ; b=2 ; test $a -ge $b ; echo $? a. the number 1 or 0 followed by another 1 or 0 on a new line b. 1 c. 0 d. test: $a: integer expression expected e. no output 187. What is the output on your screen of the following sequence of commands: i=0 ; test $i = 00 ; echo $? a. 1 b. 0 c. no output d. test: $i: integer expression expected e. the number 0 or 1 followed by another 0 or 1 on a new line 188. Which of the following PATH statements makes the most sense? a. PATH=/bin/sh:/usr/bin:/etc:/bin b. PATH=/usr:/bin:/usr/bin:/etc c. PATH=/bin:/usr/bin:/etc/passwd d. PATH=/bin/ls:/etc:/usr/bin e. PATH=/bin:/bin/cat:/usr/bin 189. Which command line copies all the files from directory a to directory b? a. cd a ; tar -rc /tmp/i . ; cd ../b ; tar -rx /tmp/i b. cd a ; tar xvf /tmp/i . ; cd ../b ; tar czf /tmp/i c. cd a ; tar -r /tmp/i . ; cd ../b ; tar -rx /tmp/i d. cd a ; tar czf /tmp/i . ; cd ../b ; tar xvf /tmp/i e. cd a ; tar cf /tmp/i . ; cd ../b ; tar xf /tmp/i 190. What is the output on your screen of this two-command sequence: cd /bin/ls && echo "in $(pwd)" a. bash: cd: /bin/ls: Not a directory b. in $(pwd) c. in 0pwd) d. no output e. in /etc 191. If dog=dog and cat=cat then which of the following command lines outputs only the word hi (and nothing else)? a. test dog -ne cat && echo hi b. test dog = dog && echo hi c. [!dog = cat] && echo hi d. [dog -ne cat] || echo hi e. [dog!=dog] || echo hi 192. What is the link count of file foo after this set of successful commands? rm foo ; touch foo ; ln foo bar cp bar x ; ln x y ; ln bar z ; ln z a a. 2 b. 5 c. 1 d. 4 e. 3 193. What is the output on your screen of this two command sequence: PATH=/bin/ls:/bin/cat:/bin/sh ; cat nosuchfile a. bash: /bin/ls: command not found b. bash: cat: command not found c. bash: /bin/sh: No such file or directory d. cat: nosuchfile: No such file or directory e. ls: /bin/cat: command not found 194. Which of these statements is true? a. The cat food command looks up the file name argument food in your $PATH. b. If /x is an empty directory, sort /x/* produces an error message. c. Typing ./script and bash script always give identical results. d. Only single quotes are strong enough to stop shell GLOB (wildcard) patterns from expanding. e. If /y is an empty directory, echo /y/* produces an error message. 195. Which command stops people from using write to put lines of text on your screen? a. mesg n b. chmod 000 c. stop 0 d. umask 000 e. write n 196. If a shell script named foo contains the line: if [ "$1" = '$2' ] ; then echo SAME ; fi then which of the following command lines will produce SAME as output? a. ./foo '$2' bar b. ./foo "bar" 'bar' c. ./foo "$1" '$2' d. ./foo bar bar e. ./foo $2 $2 197. In an empty directory, what is the output on your screen of these commands: touch uu .u uv .v uw ; a="*u *v" ; echo "$a" a. $a b. *u *v c. uu uv d. uu .u uv .v e. u* v* 198. What appears on your screen after this command line? echo hi >ls ; cat ls > wc a. 1 1 2 b. 1 1 3 c. no output on screen d. hi e. ls 199. What is the output on your screen of this sequence of three shell commands: umask 762 ; touch newfile ; ls -l newfile a. -------r-- 1 me me 0 Oct 1 1:12 newfile b. --------wx 1 me me 0 Oct 1 1:12 newfile c. ------xr-x 1 me me 0 Oct 1 1:12 newfile d. -rwxrw--w- 1 me me 0 Oct 1 1:12 newfile e. -rw-rw--w- 1 me me 0 Oct 1 1:12 newfile 200. In a directory containing one file named dog, what appears on your screen after this command line? 2>/dev/null ls nosuchfile a. no output on screen b. bash: 2>/dev/null: command not found c. ls: nosuchfile: No such file or directory d. dog e. nosuchfile 201. 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. 1 b. 1 followed by 2 c. an error message d. no output on screen e. 2 202. If a=aaa and b=bbb then what is the output on your screen of the following command sequence: if $a = $b ; then echo $a ; fi a. bash: aaa: command not found b. no output c. aaa d. test: $a: integer expression expected e. test: aaa: integer expression expected 203. What is the output on your screen of the following command sequence: i=0 ; test $i = 00 ; echo $? a. no output b. 1 c. the number 0 or 1 followed by another 0 or 1 on a new line d. test: $i: integer expression expected e. 0 204. What is the output on your screen of this sequence of three shell commands: umask 574 ; mkdir newdir ; ls -ld newdir a. d-w-----w- 1 me me 0 Oct 1 07:55 newdir b. dr--rw-r-- 1 me me 0 Oct 1 07:55 newdir c. d-w-rwx-wx 1 me me 0 Oct 1 07:55 newdir d. d-w-----wx 1 me me 0 Oct 1 07:55 newdir e. dr-xrwxr-- 1 me me 0 Oct 1 07:55 newdir 205. If bar is a script containing the line TERM=vt100 ; export TERM, what is the output on your screen of the following command sequence: TERM=linux ; ./bar ; echo $TERM a. TERM b. vt100 c. $TERM d. linux e. bar 206. In an empty directory, what is the length of the longest file name after this sequence of commands? echo hi >four ; cp four five5 ; mv five5 hi ; bzip2 hi a. 5 b. 3 c. 4 d. 2 e. 6 207. What is the output on your screen of the following sequence of commands: a=pig ; b=bat ; touch $b ; test -n $b ; echo $? a. 1 b. the number 0 or 1 followed by another 0 or 1 on a new line c. test: $b: integer expression expected d. 0 e. no output 208. What is the output on your screen of this sequence of three shell commands: umask 674 ; touch newfile ; ls -l newfile a. --------w- 1 me me 0 Feb 20 07:55 newfile b. -rw-rwxr-- 1 me me 0 Feb 20 07:55 newfile c. --w--wxr-x 1 me me 0 Feb 20 07:55 newfile d. -rw-rw-r-- 1 me me 0 Feb 20 07:55 newfile e. ---x----wx 1 me me 0 Feb 20 07:55 newfile 209. A shell script named foo is executed as follows: ./foo 1 2 "3 4" 5 Inside the script is the line: echo "$3" What is the output on your screen from this line? a. $3 b. 1 2 3 c. 2 3 4 d. 3 4 e. "3 210. What is the output on your screen of the following command sequence: a=sky ; touch $a ; test -z $a ; echo $? a. test: $a: integer expression expected b. 1 c. sky d. no output e. 0 211. 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 two of three names for this file b. foo and bar each have three names (six names total) c. foo and bar are names for the same file d. this output is not possible e. foo and bar are names for different files 212. If dog is an executable script containing the line: umask 0002 what is the output on your screen of the following sequence of commands: umask 0077 ; ./dog ; umask a. 0077 b. 0075 c. 0079 d. no output on screen e. 0002 213. What is the output on your screen of the following sequence of commands: i=00 ; [ $i = 0 ] ; echo $? a. 0 b. the number 0 or 1 followed by another 0 or 1 on a new line c. test: $i: integer expression expected d. no output e. 1 214. What is the output on your screen of this sequence of three shell commands: echo x >abc ; ls >abc abc ; wc abc a. no output b. 1 1 2 abc c. 0 0 0 abc d. 1 1 3 abc e. 1 1 4 abc 215. What is the output on your screen of this command sequence: false && echo "hello there $?" a. no output b. hello there 1 c. hello there 1 d. hello there 0 e. hello there 0 216. 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/.abc /000/.xyz /000/.??? b. /000/???? c. no output d. /000/.abc /000/.xyz e. echo: /000/????: No such file or directory 217. What is the output on your screen of the following sequence of commands: cd /etc && echo "in $(pwd)" a. in 0pwd) b. bash: cd: /etc: No such file or directory c. no output d. in /etc e. in $(pwd) 218. What is the output on your screen of this command sequence: false && echo "linux rules $?" a. linux rules 1 b. linux rules 1 c. linux rules 0 d. linux rules 0 e. no output 219. Which command sequence correctly compares the numbers and prints OK? a. if ( let 2 > 1 ) ; then echo OK ; fi b. if [ 2 > 1 ] ; then echo OK ; fi c. if [ 1 -lt 2 ] ; then echo OK ; fi d. if ( 1 let 2 ) ; then echo OK ; fi e. if [ ! 2 < 1 ] ; then echo OK ; fi 220. If a=cow and b=dog then what is the output on your screen of the following sequence of commands: [ $a = cow -a $b = dog ] ; echo $? a. 0 b. test: $a: integer expression expected c. no output d. 1 e. the number 1 or 0 followed by another 1 or 0 on a new line 221. what is the output on your screen of the following command sequence: false && echo "hello there $?" a. hello there 0 b. no output c. hello there 1 d. hello there 1 e. hello there 0 222. What is the output on your screen of the following command sequence: echo wc >wc ; wc wc >wc ; head wc a. 1 1 3 wc b. 0 0 0 wc c. no output d. wc e. 1 1 2 wc 223. If variable x might contain nothing (a null value - defined but empty), which command sequence correctly tests for this and prints OK? a. if [ "$x" = * ] ; then echo OK ; fi b. if [ $x = /dev/null ] ; then echo OK ; fi c. if test $x -eq "" ; then echo OK ; fi d. if [ ''$x'' = '''' ] ; then echo OK ; fi e. if test "" = "$x" ; then echo OK ; fi 224. 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 [ "$a" = * ] ; then date ; fi b. if test "" = "$a" ; then date ; fi c. if test "" -eq $a ; then date ; fi d. if [ '''' = ''$a'' ] ; then date ; fi e. if [ $a = /dev/null ] ; then date ; fi 225. Which line below passes three separate arguments to the cat command when placed inside a shell script named foo invoked by the command line: ./foo one two three a. cat "$@" b. cat "$1 $2 $3" c. cat "$? $? $?" d. cat "$*" e. cat "$#" 226. If dog=12 and cat=99 then which of the following command lines outputs only the word hi (and nothing else)? a. [ dog -ne cat ] && echo hi b. [dog!=dog] || echo hi c. [dog -ne cat] || echo hi d. [!dog = cat] && echo hi e. [ dog = dog ] && echo hi 227. What is the output on your screen of the following sequence of commands: x=0 ; y=1 ; touch $x ; test ! -z $x ; echo $? a. 0 b. the number 1 or 0 followed by another 1 or 0 on a new line c. test: $x: integer expression expected d. 1 e. no output 228. If a shell script named foo contains the line: if [ '$3' = "$2" ] ; then echo SAME ; fi then which of the following command lines will always produce SAME as output? a. ./foo $3 "$2" $1 b. ./foo '$1' "$3" $2 c. ./foo $1 $2 $3 d. ./foo 2 '$3' 1 e. ./foo $1 '$2' $3 229. If bat=12 and cat=99 then which of the following command lines outputs only the word hi (and nothing else)? a. [ bat -ne cat ] && echo hi b. [ bat = bat ] && echo hi c. [!bat = cat] && echo hi d. [bat!=bat] || echo hi e. [bat -eq 12] || echo hi 230. 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 each have two names (four names total) b. foo and bar are two of three names for this file c. this output is not possible d. foo and bar are names for the same file e. foo and bar are names for different files 231. If cat is an executable script containing the line: TERM=linux ; export TERM what is the output on your screen of the following sequence of commands: TERM=vt100 ; ./cat ; echo "$TERM" a. vt100 b. linux c. cat d. TERM e. $TERM 232. What is the link count of directory d after this set of successful commands? mkdir d ; mkdir d/a ; touch d/b a. 4 b. 3 c. 1 d. 5 e. 2 233. What is the output on your screen of the following sequence of commands: a=sky ; touch $a ; test -z $a ; echo $? a. no output b. 0 c. 1 d. sky e. test: $a: integer expression expected 234. What is the output on your screen of the following command sequence if run in a directory containing 123 files with names that are all the numbers from 1 to 123 inclusive: glob="*" ; echo "$glob" a. the file names 1 through 123 b. "$glob" c. * d. $glob e. the file names 1 through 123, surrounded by quotes 235. In a directory containing one file named dog, what appears on your screen after this command line? 1>/dev/null ls * a. * b. no output on screen c. ls: *: No such file or directory d. dog e. bash: 1>/dev/null: command not found 236. Which line below puts the count of the number of lines in the password file into the variable foo? a. foo=$( wc /etc/passwd | awk echo $1 ) b. foo=$( wc -l foo a. 4 b. 2 c. 3 d. empty file (no data) e. 1 239. 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. 2 c. 2 followed by 1 d. empty file - no output on the screen e. 1 240. Which command sequence correctly compares the two numbers and prints OK? a. if [ 4 > 3 ] ; then echo OK ; fi b. if [ 4 -gt 3 ] ; then echo OK ; fi c. if [ ! 4 <= 3 ] ; then echo OK ; fi d. if ( let 4 > 3 ) ; then echo OK ; fi e. if ( ! 4 < 3 ) ; then echo OK ; fi 241. If /bin/bat is a program that outputs hi and /usr/bin/bat is a program that outputs foo what is the output on your screen of this shell command sequence: PATH=/etc:/usr/bin:/bin ; bat a. foo followed by hi b. foo c. hi d. hi followed by mom e. bash: bat: command not found 242. Which command line copies all the files from directory a to directory b? a. cd a ; tar czf /tmp/i . ; cd ../b ; tar xvf /tmp/i b. cd a ; tar xf /tmp/i . ; cd ../b ; tar czvf /tmp/i c. cd a ; tar -rc /tmp/i . ; cd ../b ; tar -rx /tmp/i d. cd a ; tar czf /tmp/i . ; cd ../b ; tar xzf /tmp/i e. cd a ; tar -r /tmp/i . ; cd ../b ; tar -rvx /tmp/i 243. What is the output on your screen of this two-command sequence if run in a directory containing 765 files with names that are all the numbers from 1 to 765 inclusive: foo="*" ; echo $foo a. all the file names that start with an asterisk ('*') b. * c. $foo d. the file names 1 through 765 e. an asterisk ('*') and the file names 1 through 765 244. Which of these first lines will cause this executable file to be interpreted using the Bash shell? a. #!/bin/bash b. !/bin/bash c. !#/bin/bash -u d. #/bin/bash e. $!/bin/bash -u 245. In an empty directory, what is the output on your screen of this three- command sequence: touch aa .a ab .b .c ; x='.a* .b*' ; echo '$x' a. .a .b b. .a* .b* c. aa .a ab .b d. '.a* .b*' e. $x 246. What is in the file named file after this command sequence: echo a >x ; echo b >>x ; mv x y >file a. nothing - file is empty - no data b. a c. b d. no such file (nonexistent file) e. a followed by b 247. In an empty directory, what is the length of the longest file name created by the following two-command sequence: ok='1 12 123 1234' ; touch '$ok' a. 13 characters b. 3 characters c. 1 character d. 4 characters e. 2 characters 248. What is the output on your screen of the following sequence of commands: x=1 ; touch x ; test ! -z $x ; echo $? a. 1 b. the number 1 or 0 followed by another 1 or 0 on a new line c. 0 d. no output e. test: $x: integer expression expected 249. If a=1 and b=1, which command sequence correctly compares the two numbers as equal and prints OK? a. if test $b -eq $a ; then echo OK ; fi b. if test a == b ; then echo OK ; fi c. if [ b = a ] ; then echo OK ; fi d. if [ $a==$b ] ; then echo OK ; fi e. if [ a -eq b ] ; then echo OK ; fi 250. Which command line shows just the type and permissions of file foo? a. tr ' ' '\n' x ; ln x y ; echo 2 >>y ; head -1 x >y ; cat y a. 2 followed by 1 b. 2 c. empty file - no output on the screen d. 1 e. 1 followed by 2 272. Which command counts the number of Unix permission groups you are in? a. groups | wc b. wc groups c. id | wc d. echo groups | wc e. umask | wc 273. What is the output on your screen of the following sequence of commands: x=cow ; y=dog ; touch $y ; test -n $y ; echo $? a. 0 b. no output c. 1 d. test: $y: integer expression expected e. the number 0 or 1 followed by another 0 or 1 on a new line 274. 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 followed by 2 b. 1 c. empty file - no output on the screen d. 2 followed by 1 e. 2 275. If a=cow and b=dog then what is the output on your screen of the following sequence of commands: [ $a = dog -o $b = cow ] ; echo $? a. test: $a: integer expression expected b. 0 c. the number 1 or 0 followed by another 1 or 0 on a new line d. no output e. 1 276. 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. 10 blocks c. 2 blocks d. 8 blocks e. 4 blocks 277. 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. 7 b. 4 c. 3 d. 5 e. 6 278. Which of the following PATH statements makes the most sense? a. PATH=/bin:/usr/bin:/etc b. PATH=/bin:/usr/bin:/etc/passwd c. PATH=/bin:/bin/cat:/usr/bin d. PATH=/bin/ls:/etc:/usr/bin e. PATH=/bin/sh:/usr/bin:/etc:/bin Answer Key - NET2003 - Ian Allen - Winter 2005 - NET2003 Practice Test Office use only: 265 179 80 181 264 221 88 226 79 145 33 5 217 67 237 99 121 32 233 191 70 194 195 34 198 262 272 160 105 86 54 22 124 136 11 27 249 156 37 167 112 220 267 257 89 126 227 161 41 245 263 244 238 55 58 53 65 15 185 142 163 77 46 10 155 180 12 74 251 172 123 218 63 24 113 8 274 66 186 17 92 50 250 252 48 209 204 23 85 75 100 230 157 222 162 21 49 175 239 81 141 114 130 197 219 4 178 236 96 231 229 95 270 210 254 97 127 243 164 205 3 235 94 276 52 143 43 83 246 51 193 111 256 247 104 168 7 68 16 38 184 132 64 13 2 170 183 202 120 18 278 150 232 211 234 78 269 258 149 201 36 125 25 29 59 47 260 174 60 147 115 107 268 20 173 128 187 82 14 110 140 240 151 72 102 148 158 261 224 200 45 133 192 275 248 69 98 116 190 91 213 57 146 188 35 103 152 189 6 139 207 42 159 182 176 73 154 177 241 61 277 144 87 84 253 44 165 71 39 208 40 129 153 137 90 255 223 93 119 242 26 225 196 271 109 122 106 166 56 228 169 1 273 131 134 215 28 138 31 135 30 266 203 19 108 206 9 199 216 212 118 214 171 117 62 76 101 259 1. e 41. e 2. d 42. d 3. c 43. d 4. e 44. b 5. b 45. a 6. a 46. c 7. b 47. b 8. d 48. a 9. d 49. c 10. b 50. a 11. d 51. b 12. c 52. c 13. d 53. a 14. d 54. a 15. d 55. a 16. b 56. d 17. d 57. e 18. b 58. a 19. a 59. e 20. b 60. a 21. a 61. b 22. d 62. d 23. c 63. d 24. d 64. d 25. a 65. c 26. b 66. b 27. c 67. a 28. d 68. d 29. b 69. c 30. e 70. d 31. d 71. b 32. a 72. c 33. d 73. a 34. b 74. d 35. a 75. c 36. b 76. c 37. c 77. a 38. d 78. c 39. d 79. a 40. b 80. a 81. d 137. b 82. a 138. b 83. b 139. b 84. c 140. b 85. a 141. e 86. c 142. c 87. a 143. a 88. b 144. a 89. c 145. b 90. d 146. d 91. b 147. a 92. d 148. d 93. c 149. e 94. d 150. d 95. a 151. e 96. a 152. a 97. e 153. e 98. c 154. a 99. e 155. a 100. d 156. b 101. a 157. c 102. c 158. d 103. e 159. a 104. e 160. c 105. a 161. d 106. e 162. d 107. b 163. e 108. d 164. c 109. b 165. e 110. c 166. d 111. c 167. c 112. c 168. a 113. c 169. a 114. e 170. a 115. b 171. e 116. d 172. a 117. d 173. c 118. b 174. a 119. e 175. d 120. c 176. d 121. a 177. b 122. a 178. b 123. b 179. a 124. a 180. e 125. b 181. d 126. c 182. a 127. b 183. b 128. a 184. d 129. d 185. c 130. d 186. b 131. b 187. a 132. e 188. b 133. e 189. e 134. b 190. a 135. d 191. b 136. e 192. d 193. b 249. a 194. b 250. c 195. a 251. c 196. a 252. b 197. b 253. d 198. c 254. c 199. a 255. b 200. a 256. e 201. c 257. d 202. a 258. c 203. b 259. b 204. d 260. d 205. d 261. b 206. e 262. e 207. d 263. c 208. a 264. e 209. d 265. b 210. b 266. e 211. c 267. b 212. a 268. b 213. e 269. c 214. e 270. d 215. a 271. c 216. b 272. a 217. d 273. a 218. e 274. b 219. c 275. e 220. a 276. a 221. b 277. e 222. b 278. a 223. e 224. b Count of a: 67 24% 225. a Count of b: 65 23% 226. e Count of c: 47 17% 227. a Count of d: 59 21% 228. d Count of e: 40 14% 229. b 230. e With 5 choices: 278 231. a 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 232. b 16 17 18 19 20 21 22 23 24 25 26 27 233. c 28 29 30 31 32 33 34 35 36 37 38 39 234. c 40 41 42 43 44 45 46 47 48 49 50 51 235. b 52 53 54 55 56 57 58 59 60 61 62 63 236. b 64 65 66 67 68 69 70 71 72 73 74 75 237. a 76 77 78 79 80 81 82 83 84 85 86 87 238. e 88 89 90 91 92 93 94 95 96 97 98 99 239. a 100 101 102 103 104 105 106 107 108 240. b 109 110 111 112 113 114 115 116 117 241. b 118 119 120 121 122 123 124 125 126 242. d 127 128 129 130 131 132 133 134 135 243. d 136 137 138 139 140 141 142 143 144 244. a 145 146 147 148 149 150 151 152 153 245. e 154 155 156 157 158 159 160 161 162 246. a 163 164 165 166 167 168 169 170 171 247. b 172 173 174 175 176 177 178 179 180 248. c 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 Macro .cmd split no indent: 0 Macro .cmd split with indent: 119 Macro .ans splits: 0