Practice Test #1 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 - 203 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: 45 13 203 91 166 153 121 6 73 66 127 184 86 63 8 11 189 35 99 79 14 58 100 186 198 124 151 195 164 4 142 156 51 144 202 71 81 141 55 168 157 108 133 161 150 175 56 135 78 193 70 39 15 146 88 109 120 158 106 67 167 31 104 201 123 96 42 170 199 194 200 132 50 116 48 143 182 179 95 54 29 77 19 126 154 183 85 152 98 177 9 181 37 46 160 59 30 38 25 24 52 27 5 139 173 75 115 176 162 10 111 2 131 188 83 185 114 62 22 93 44 149 60 57 34 17 171 89 72 105 26 140 92 12 1 33 43 53 64 136 192 82 21 32 18 125 174 87 36 190 41 165 80 102 90 191 74 145 61 20 40 197 47 94 97 196 110 178 16 101 122 107 68 76 180 129 119 137 113 169 112 128 7 134 49 163 3 118 103 69 130 187 155 28 172 159 117 23 147 138 84 148 65) 1. What is the output of this shell command line in an empty directory? ls * a. . b. no output c. * d. . .. e. an error message from ls saying * does not exist 2. Which command sequence outputs inode/filename pairs for names in the working directory, sorted by inode number? a. ls | sort -i b. ls -node | sort -n c. ls -ia | sort -n d. echo -i * > sort e. echo * | sort -n 3. Select the correct bash shell order of command line processing: a. quotes, redirection, variables, globs b. quotes, variables, globs, redirection c. quotes, variables, redirection, globs d. redirection, quotes, globs, variables e. quotes, globs, variables, redirection 4. Which of these statements is true? a. You can only login to Unix once per userid; you cannot be logged in to the same machine twice. b. Unix commands can be entered in upper-case or lower-case letters; they are equivalent. c. Unix commands must be entered in lower-case letters. d. To erase an entire line of typing, type [CONTROL]-[E]. e. To indicate End-of-File (no more input), type [CONTROL]-[E]. 5. What is the output of this command sequence: echo bat >one ; echo sky | head -2 one a. an error message b. sky followed by bat c. bat followed by sky d. bat e. sky 6. What is in file cow after running this bash shell command line? echo one two >cow three a. one two three b. no output (empty file) c. one two cow three d. one two e. echo one two 7. In an empty directory, how many words are in file cow after this bash shell command line? touch dog dog cat ; ls >cow a. 2 b. 1 c. no output (empty file) d. 4 e. 3 8. If file foo contains nine lines, each of which is the one-digit line number of the line in the file (1 through 9), what is the output on your screen of this command: cat foo foo | cat | tail -5 | head -1 a. 5 b. 6 c. 7 d. 9 e. 8 9. Which command below sorts only this five-character file name containing a special character (and no others): xx?xx a. sort xx/?xx b. sort xx?xx c. sort ''xx?xx'' d. sort ""xx?xx"" e. sort "xx?xx" 10. Which command below removes only this four-character file name containing a special character (and no others): cat? a. rm ''cat?'' b. rm ""cat?"" c. rm "cat?" d. rm cat/? e. rm \cat? 11. What is true about this output from ls -il foo bar? 871 -r-------- 2 bin bin 3 Nov 12 12:55 foo 871 -r-------- 2 bin bin 3 Nov 12 12:55 bar a. foo and bar are two of three names for this file b. foo and bar are names for different files c. foo and bar are names for the same file d. this output is not possible e. foo and bar each have three names (six names total) 12. Who is the owner of file bar after you execute this sequence of commands in your home directory: ln /etc/passwd foo ; ln foo one ln one two ; ln two bar a. you cannot execute the given commands; no file will be created b. the file is owned by passwd c. the file is owned by root d. you own the file bar e. the file is owned by home 13. Which command line lists all possible utilities available for sorting files? a. grep sort /etc/passwd b. man -k sort c. man sort d. man | grep sort e. grep /etc/passwd sort 14. How many command arguments does the shell pass to this echo command: echo 'It's a bird! It's a plane!' a. Four arguments. b. Two arguments. c. Three arguments. d. One argument. e. Five arguments. 15. If file foo contains nine lines, each of which is the one-digit line number of the line in the file (1 through 9), what is the output on your screen of this command: cat foo foo | sort -r | head -4 | tail -1 a. 5 b. 7 c. 9 d. 6 e. 8 16. Which command sequence outputs inode/filename pairs for names in the current directory, sorted by inode number? a. ls -ia | sort -n b. ls ./* | sort -node c. ls -node * > sort -n d. ls -i * > sort e. sort ls -ia 17. Which command sequence below does not generate an error message from the last command in the sequence? a. date >foo ; cp foo/. bar b. mkdir foo ; sleep foo c. mkdir foo foo/bar ; rmdir foo d. mkdir one one/two ; rmdir one/two e. cat /etc/passwd > mail idallen@ncf.ca 18. If my current working directory is /home, and my home directory is /home/xx, which of the of the following commands copies the Unix password file into my home directory under the name foo? a. cp ../../etc/passwd /xx/foo b. cp ../etc/passwd ../xx/foo c. cp xx/../../etc/passwd xx/foo d. cp ../home/xx/../etc/passwd ./xx/./foo e. cp xx/../etc/passwd ../home/xx/foo 19. How many arguments and options are there to the command: ls -li foobar a. Two command line arguments, one of which contains two bundled options. b. One argument, no options. c. Two arguments, no options. d. Two arguments, one of which is a single option and the other is a pathname. e. Two options, no arguments. 20. What is the output on your screen of the following sequence of commands: echo wc >wc ; wc wc >wc ; cat wc a. wc b. 1 1 2 wc c. no output d. 1 1 3 wc e. 0 0 0 wc 21. Which Unix command sequence deletes a directory and everything inside it? a. deltree -all dir b. rm -r dir c. rmdir -all dir d. erase -r dir e. erase dir 22. Which command line displays the contents of the Unix passwd file one page at a time? a. less less c. less | /etc/passwd d. /etc/passwd | less e. cat /etc/passwd >less 23. How many arguments and options are there to the command: wc -l /a/x ; sort /a/x >/a/x ; wc /a/x a. no output b. 0 0 0 /a/x c. 1 1 2 /a/x d. 1 1 3 /a/x e. 2 2 4 /a/x 27. What is in file out after running this bash shell command line? echo a >out b c a. no output b. b c c. echo a d. a e. a b c 28. 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]-[UP] c. Type [CONTROL]-[BACKSPACE] d. Use the "PageUp" key. e. Use the "UpArrow" key. 29. What command shows all the lines in file /etc/group that contain the string idallen? a. grep idallen >/etc/group b. cat /etc/group | wc idallen c. grep idallen /etc/group d. grep /etc/group idallen e. cat /etc/group > grep idallen 30. If /bin/bash is a file name, which of the following pathnames always leads to the same file? a. /bin/../bash b. /bin/bin/../bash c. /bin/bash/. d. /bin/../bin/bash e. ./bin/bash 31. What is the output of this successful command sequence? cd /home/dir ; mkdir one ; mkdir two ; pwd a. /home/dir/one b. /home/dir c. /home/dir/one/two d. /home/dir/two e. /two 32. What text is output by this bash shell command sequence: echo cow >foo ; echo dog | head -1 foo a. cow followed by dog b. foo c. dog d. dog followed by cow e. cow 33. What appears on your screen after this bash shell command line? echo hi >a ; ls a > wc a. 3 b. 1 1 2 c. 2 d. no output e. 1 1 3 34. Which of the following shell command lines displays only the names in the current directory that are exactly three alphabetic letters long? a. echo *** b. echo [?][?][?] c. echo ??? d. echo [a-zA-Z][a-zA-Z][a-zA-Z] e. echo [0-3][0-3][0-3] 35. Given this long listing: drwxr-xr-x 448 me me 296 Dec 4 9:12 /dir How many subdirectories lie immediately under /dir? a. 446 b. 294 c. 448 d. 296 e. there is not enough information shown to answer the question 36. Which command below removes only this four-character file name containing a special character (and no others): xyz? a. rm xyz\? b. rm xyz\\? c. rm xyz//? d. rm xyz/? e. rm -r xyz? 37. What appears on your screen after this sequence of commands: echo one >x ; ln x y ; echo two >>y ; sort x >y ; cat y a. one b. one followed by two c. two d. empty file - no output on the screen e. two followed by one 38. What is the output of this successful command sequence? cd /home/foo ; touch dir ; mkdir bar ; pwd a. /home/foo b. /home/foo/dir/bar c. /home/foo/bar d. /home/foo/dir e. /bar 39. What appears on your screen after this bash shell command line? echo xx >z ; ls z > wc a. no output b. 1 1 2 c. 2 d. 3 e. 1 1 3 40. How many arguments does the shell pass to this echo command: echo ' one two ' three ' four ' 5'6' a. Four arguments. b. Six arguments. c. One argument. d. Five arguments. e. Nine arguments. 41. In an empty directory, what is the shell output of these three commands: touch .1 .2 .3 11 12 ; b='.1* .2*' ; echo '$b' a. .1 .2 b. 11 .1 12 .2 c. .1* .2* d. $b e. '.1* .2*' 42. What is in the file bar after this command sequence: echo hi >x ; echo ho >x ; mv x y >bar a. hi followed by ho b. ho c. hi d. nothing - empty file - no data e. no such file (nonexistent) 43. If I am in my home directory named /home/myhome and sub is an empty sub- directory, what is true after this command line: touch ./fil ; mv sub/../fil ../myhome/cat a. the command fails because the path sub/../fil does not exist b. the command fails because the path ../myhome/cat does not exist c. there is a second copy of the file fil in the file named cat d. the directory sub/.. now has a file named cat in it e. the directory sub now contains only a file named cat 44. If I am in my home directory named /home/alleni and empty is an empty sub- directory, what is true after this command line: date >./cat ; mv empty/../cat ../alleni/dog a. the command fails because the path ../alleni/dog does not exist b. the command fails because the path empty/../cat does not exist c. the directory empty now contains only a file named dog d. there is a second copy of the file cat in the file named dog e. the directory empty/.. now has a file named dog in it 45. Which of the following statements is true about this shell command line: >/a/b/c cat /a/b/d a. The command cat sees two arguments. b. The command cat sees only one argument. c. The command is always invalid. d. The command /a/b/c sees only one argument e. The command /a/b/c sees two arguments. 46. What will appear on your screen if you execute this sequence of commands: echo 1 >x ; ln x y ; echo 2 >y ; chmod 077 y ; cat x a. 2 b. 1 c. 1 followed by 2 d. an error message e. no output on screen 47. What appears on your screen after this bash shell command line? mkdir foo ; rmdir foo | wc -c a. 0 b. 4 c. 3 d. no output e. 1 48. What is the link count of directory dir after this set of successful commands? mkdir dir ; cd dir ; touch foo ; mkdir a b c a. 1 b. 2 c. 5 d. 3 e. 4 49. What is true about this output from ls -il foo bar? 861 -rw-r--r-- 2 root root 3 Jan 24 01:03 foo 861 -rwxr-xr-x 2 bin bin 3 Nov 12 12:55 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. this output is not possible e. foo and bar each have three names (six names total) 50. Which of the following pathnames always leads to the same file named: /etc/passwd? a. /etc/./etc/../passwd b. ../etc/passwd c. /etc/passwd/. d. /etc/../etc/passwd e. ./etc/passwd 51. Which command below removes only this four-character file name containing a special character (and no others): *dog a. rm .\/*dog b. rm ?dog c. rm /*dog d. rm \\*dog e. rm ./\*dog 52. Which of the following is true, given this long directory listing from ls: drwxr-x--x 256 ian user 512 May 30 12:35 dir a. The number 256 is the octal permissions of this directory. b. The number 256 is the size of this directory. c. The number 512 is the count of links (names) this directory has. d. The number 256 is the inode number of this directory. e. The number 512 is the size of this directory. 53. Which Unix command sequence deletes a directory and everything inside it? a. rm -r dir b. rmdir -all dir c. deltree -all dir d. rm -all dir e. rmdir -r dir 54. If file twenty contains twenty lines, and file thirty contains thirty lines, then how many lines are output by this command: tail thirty | cat twenty a. 50 b. 30 c. 20 d. no lines (no output) e. 21 55. In an empty directory, what is the length of the longest file name created by the following shell two-command sequence: var='a ab abc abcd abcde' ; touch "$var" a. 5 characters b. 19 characters c. 4 characters d. 15 characters e. 3 characters 56. How many arguments are passed to the command by the shell on this command line: bar bar bar a. 4 b. 7 c. 5 d. 6 e. 3 57. If file a contains twenty lines, and file b contains thirty lines, then how many lines are in file out after this sequence of bash shell commands: cat a b >c ; head c >c ; sort a b c >out a. 60 b. 100 c. no lines (empty file) d. 50 e. 30 58. In an empty directory, what is the shell output of these three commands: touch xx .x xy .y xz ; a='x* y*' ; echo "$a" a. *x *y b. x* y* c. xx xy xz y* d. $a e. xx xy 59. Which command sequence below outputs only lines 10-15 of the 16-line file named hex? a. head -15 hex | tail -6 b. tail -16 hex | head -10 c. head -16 hex | tail -5 hex d. head -10 hex | tail -15 hex e. tail -10 hex | head -16 hex 60. Which command below removes only this four-character file name containing a special character (and no others): abc* a. rm abc\\* b. rm abc* c. rm abc//* d. rm abc\* e. rm abc/* 61. What is the output of this command sequence: echo foo >file ; echo bar | sort file a. foo b. foo followed by bar c. bar followed by foo d. bar e. an error message 62. Which command line below does not show any lines from inside the file dog? a. less dog b. sort -r dog c. tail -8 dog d. ls dog e. head -3 dog 63. If directory /a contains these seven two-character file names: aa, ab, ac, ad, a?, a*, a., then which shell command below will remove only the single name a? from the directory? a. rm /a/a\? b. rm /a/a? c. rm /a/a[*] d. rm /a/a* e. rm /a? 64. 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. * b. $glob c. "$glob" d. the file names 1 through 123 e. the file names 1 through 123, surrounded by quotes 65. In an empty directory, how many words are in file out after this bash shell command line? touch a ; ls >out a. 2 b. 3 c. 4 d. no output (empty file) e. 1 66. How many arguments and options are there to the command: ls -al /etc a. Two arguments, one of which is a single option and the other is a pathname. b. Two options, no arguments. c. Two arguments, no options. d. A three-letter file name and an /etc switch option. e. Two command line arguments, one of which contains two bundled options. 67. Which of the following is true, given this long directory listing from ls: drwxr-x--x 512 ian user 712 May 30 12:35 dir a. The number 512 is the size of this directory. b. The number 712 is the inode number of this directory. c. The number 512 is the count of links (names) this directory has. d. The number 712 is the count of links (names) this directory has. e. The number 512 is the inode number of this directory. 68. If file x contains ten lines, and file y contains twenty lines, then how many lines are in file cat after this sequence of bash shell commands: sort x y >z ; tail -5 y >y ; sort x y z >cat a. 45 b. no lines (empty file) c. 50 d. 40 e. 60 69. When doing an ls -a, the output pathname that is a double dot (..) signifies what? a. The current directory. b. The root directory. c. A hidden file. d. The parent directory. e. A file or directory with double links. 70. What command can you use to remove a directory that isn't empty? a. deldir -r dir b. rm -r dir c. mv -r dir d. del -r dir e. rmdir -r dir 71. How many arguments does the shell pass to this echo command: echo "cow "y " bat 'man x' " pig'a "hop' a b a. Six arguments. b. Five arguments. c. Seven arguments. d. Eleven arguments. e. Four arguments. 72. If I am in my home directory named /home/me and x is an empty sub- directory, what is true after this command line: touch ./x/fil ; mv x/./fil x/../../me/./y a. the directory x is still empty b. the directory x now contains only a file named y c. the command fails because the path x/../../me does not exist d. there is a second copy of the file fil in the file named y e. the command fails because the path x/./fil does not exist 73. What appears on your screen after this bash shell command line? echo hi >a ; cp a b | wc -c a. 3 b. 2 c. 0 d. no output e. 1 74. Which of these command sequences will make file out contain all of the content of file in1 followed by all of the content of file in2? a. cat in1 in2 >out b. cp in1 >out in2 >out c. mv in1 in2 >out d. cp in1 in2 >out e. echo in1 in2 >out 75. What appears on your screen after this bash shell command line? echo hi >a ; ls a | wc -c a. 2 b. 4 c. 3 d. no output e. 1 76. What is the output of this successful command sequence? cd /tmp ; mkdir foo ; mkdir bar ; pwd a. /tmp b. /bar c. /tmp/foo d. /tmp/bar e. /tmp/foo/bar 77. If file foo contains nine lines, each of which is the number of the line in the file, what is the output of this command: cat foo foo | sort | tail -4 | head -1 a. 6 b. 8 c. 4 d. no output e. 1 78. What is the resulting link count of empty directory dir after this set of successful commands? cd dir ; touch foo ; ln foo one ; ln foo two a. 5 b. 2 c. 1 d. 3 e. 4 79. How many lines are in the file bar after this command sequence: echo hi >x ; echo ho >>x ; cat x x >bar a. 1 b. 2 c. 6 d. nothing - empty file - no data e. 4 80. What appears on your screen after this bash shell command line? echo hi >out ; wc -c out a. 5 out b. 3 out c. no output d. 2 out e. 4 out 81. Which of the command lines below can generate a non-empty file? a. grep pattern file >file b. sort -r file file >file c. ls -ls file >file d. touch file >file e. head -1 file >file 82. What is true about this output from ls -ild foo bar? 816 -rwxr-xr-x 2 root root 3 Jan 24 01:03 foo 816 drwxr-xr-x 2 root root 3 Jan 24 01:03 bar a. foo and bar are two of three names for this file b. foo and bar are names for different files c. foo and bar each have three names (six names total) d. foo and bar are names for the same file e. this output is not possible 83. If you type the command cat which of the following key sequences will send an EOF and take you immediately back to the command prompt? a. [CTRL-D] b. [CTRL-U] c. [CTRL-C] d. [CTRL-L] e. [CTRL-R] 84. Given an existing file of yours named wc, what is the output of this sequence of three shell commands: echo hi >wc ; sort wc >wc ; cat wc a. no output b. 1 1 3 wc c. 1 1 2 wc d. 0 0 0 wc e. 2 2 4 wc 85. If file /a/b contains ninety-nine lines, each of which is the two-digit line number of the line in the file (01 through 99), what is the output of this command: sort /a/b /a/b | tail -4 | head -1 a. 96 b. 04 04 c. 96 96 d. 98 e. 01 01 86. What will appear on your screen if you execute this sequence of commands in your home directory: ln /etc/passwd foo ; ln foo bar echo hi >bar ; cat bar a. an error message and then hi b. the conents of the password file followed by hi c. an error message and then the contents of the password file d. bar e. hi 87. Which command line lists all possible utilities available for editing files? a. man -k edit b. man edit c. which edit d. finger edit e. whereis edit 88. What is in file out after running this bash shell command line? echo 2 3 >out 3 0 a. 2 3 b. 2 3 >out 3 0 c. 2 3 0 d. 2 3 3 0 e. no output (empty file) 89. How many arguments and options are there to the command: wc -wc /sort a. Two options, no arguments. b. A three-letter file name and a /sort switch option argument. c. Two command line arguments, one of which contains two bundled options. d. Two arguments, no options. e. Two arguments, one of which is a single option and the other is a pathname. 90. In the output of the command ls -a, a dot that begins a name signifies what? a. The current directory. b. The parent directory. c. A current file. d. A name with an unprintable character. e. A name that is hidden. 91. If file nine contains nine lines, each of which is the one-digit line number of the line in the file (1 through 9), what is the output on your screen of this command: sort nine nine | tail -4 | head -1 a. 6 6 b. 4 4 c. 8 d. 6 e. 1 1 92. If your PATH variable contains /bin:/usr/bin, what is the output of this bash shell command line? echo '$PATH' a. /bin:/usr/bin b. '$PATH' c. '/bin' d. /bin e. $PATH 93. How many arguments does the shell pass to this echo command: echo " 1 2 " three ' 4 ' five"6" a. One argument. b. Four arguments. c. Five arguments. d. Three arguments. e. Nine arguments. 94. What is the output of this bash shell command line in an empty directory? echo '$SHELL' a. /bin/bash b. $SHELL c. '$SHELL' d. '/bin/bash' e. no output 95. If cow is a sub-directory that contains only the file dog, what happens after this command: mv cow/dog cow/././cat a. the directory cow now contains only a file named cat b. the command fails because the name cat does not exist c. the command fails because the name cow/././cat does not exist d. the directory cow is now empty e. there is a second copy of the file dog in the file named cat 96. Which command line displays the contents of the Unix passwd file one page at a time? a. cat /etc/passwd >more b. more /etc/passwd c. /etc/passwd >more d. more | /etc/passwd e. /etc/passwd | more 97. Which command line below does not show any lines from inside the file dog? a. head dog b. ls dog c. tail dog d. less dog e. more dog 98. How many arguments does the shell pass to this echo command: echo " one '2 three' 4 "five 6 ' 7 "8 ' >out a. Two arguments. b. Six arguments. c. Four arguments. d. Three arguments. e. Five arguments. 99. Which of the command lines below can generate a non-empty file? a. ls -i /a/b >/a/b b. tail -5 /a/b >/a/b c. grep /a/b /a/b >/a/b d. cat /a/b >/a/b e. sort -r /a/b >/a/b 100. If you type the command sort verybigfile >out which of the following key sequences will interrupt it and take you immediately back to the command prompt? a. [CTRL-L] b. [CTRL-D] c. [CTRL-R] d. [CTRL-U] e. [CTRL-C] 101. What appears on your screen after this bash shell command line? echo hi >out | wc -c a. 0 b. 3 c. no output d. 2 e. 1 102. Which of the command lines below can generate a non-empty file? a. grep -v /out /out >/out b. sort -r /out >/out c. ls /out >/out d. tail -5 /out >/out e. head /out 103. If file foo contains nine lines, each of which is the one-digit line number of the line in the file (1 through 9), what is the output on your screen of this command: cat foo foo | cat | tail -4 | head -1 a. 6 b. 7 c. 5 d. 9 e. 8 104. If my current directory is /bin, which of these pathnames is equivalent to the file name /bin/ls? a. ./bin/ls b. ../bin/ls/. c. ../../bin/ls d. ls/. e. /root/bin/ls 105. What is in the file named file after this command sequence: echo a >c ; echo b >>c ; mv c d >file a. nothing - file is empty - no data b. a c. a followed by b d. no such file (nonexistent file) e. b 106. How many lines are in file out after this bash shell command line? echo hi >dog >out >cat a. 1 b. 2 c. 3 d. no output (empty file) e. no such file (file does not exist) 107. If directory /a/b contains these four three-character file names: .aa, .ab, .a?, .a*, then what is the output of the following bash shell command line: echo /a/b/??? a. /a/b/.aa /a/b/.ab b. /a/b/??? c. no output d. /a/b/.a? e. /a/b/.aa /a/b/.ab /a/b/.a? /a/b/.a* 108. In the output of the command ls -ai, the one-character name . signifies what? a. A name that is hidden. b. A name with an unprintable character. c. A current file. d. The current directory. e. The parent directory. 109. If I am in my home directory named /home/ian and mt is an empty sub- directory, what is true after this command line: who >../ian/cat ; cp ./mt/../cat ./mt/../dog a. there is a second copy of the file named who in the file dog b. the directory mt now has a file named dog in it c. the command fails because the path ./mt/../cat does not exist d. the directory mt is still empty e. the directory mt now contains two files 110. If file nine contains nine lines, each of which is the one-digit line number of the line in the file (1 through 9), what is the output on your screen of this command: sort nine nine nine | tail -3 | head -1 a. 9 b. 7 7 7 c. 1 1 1 d. 7 e. 8 111. How many arguments are passed to the command by the shell on this command line: pig pig pig a. 5 b. 6 c. 7 d. 8 e. 9 112. If /etc/passwd is a file name, which of the following pathnames always leads to the same file? a. ./etc/passwd b. /etc/passwd/../.. c. /etc/../../passwd d. /etc/passwd/. e. /../etc/passwd 113. What is the output of this sequence of three shell commands: echo hi >hi ; head hi >hi ; wc hi a. 2 2 4 hi b. 1 1 2 hi c. 1 1 3 hi d. no output e. 0 0 0 hi 114. Which command sequence below outputs only lines 10-15 of the Unix password file? a. head -15 /etc/passwd | tail -6 b. head -15 /etc/passwd | tail -5 /etc/passwd c. head -10 /etc/passwd | tail -15 /etc/passwd d. tail -15 /etc/passwd | head -10 e. tail -10 /etc/passwd | head -15 /etc/passwd 115. What appears on your screen after this sequence of commands: echo one >x ; ln x y ; echo two >>y ; sort x a. empty file - no output on the screen b. one followed by two c. two followed by one d. two e. one 116. What is true about this bash shell command line? date >ls ; ls -ls ls >wc a. The ls command is executed more than once. b. The ls command receives the output of date on standard input. c. The wc command counts the output of the ls command. d. The file wc has one line in it. e. The shell finds and executes three different commands. 117. If directory foo contains only these three three-character file names: .11, .12, ..., then what is the output of the following bash shell command line: echo foo/??? a. foo/... b. no output c. foo/.11 foo/.12 d. foo/.11 foo/.12 foo/... e. foo/??? 118. How many command arguments does the shell pass to this echo command: echo 'It's a bird! No! It's a plane!' a. One argument. b. Two arguments. c. Three arguments. d. Five arguments. e. Four arguments. 119. If you type the command sleep 60 which of the following key sequences will interrupt it and take you immediately back to the command prompt? a. [CTRL-D] b. [CTRL-U] c. [CTRL-R] d. [CTRL-L] e. [CTRL-C] 120. Which of these statements is true? a. Only double quotes are strong enough to stop shell glob (wildcard) patterns from expanding. b. If /y is an empty directory, echo /y/* produces an error message. c. If /x is an empty directory, sort /x/* produces an error message. d. Only single quotes are strong enough to stop shell glob (wildcard) patterns from expanding. e. Only backslashes are strong enough to stop shell glob (wildcard) patterns from expanding. 121. What is the output of this shell command line in an empty directory? echo * a. an error message from echo saying * does not exist b. * c. . d. . .. e. no output 122. Which of the following statements is true about this shell command line: >bar zoom bar haven a. The command zoom sees three arguments. b. The command zoom sees two arguments. c. The command bar sees only two arguments d. The command bar sees three arguments. e. Error: The command name is missing from the command line. 123. In an empty directory, what appears on your screen after this bash command line? touch a ; ls >wc -l a. 2 b. 1 c. 0 d. no output e. 3 124. What appears on your screen after this bash shell command line? echo hi >ls ; cat ls > wc a. 1 1 2 b. 1 1 3 c. hi d. ls e. no output 125. If my current working directory is /home, and my home directory is /home/me, which of the of the following commands copies the Unix password file into my home directory under the name foo? a. cp ../../etc/passwd /me/foo b. cp ../etc/passwd ../me/foo c. cp me/../../etc/passwd me/foo d. cp ./me/../etc/passwd ../home/me/foo e. cp ../home/me/../etc/passwd ./me/./foo 126. How can you ask the bash (Linux) shell to complete commands or file names for you? a. You can type the first part of the command or file name and press the TAB key. b. Type [CONTROL]-[C] and the shell will present a menu of commands. c. Push key F1 and the system will present a menu of commands. d. Type [CONTROL]-[D] and the shell will present a menu of commands. e. You can type the first part of the command or file name and press the ALT key. 127. Which command below is the best way to find a line containing a question mark (?) in the file /etc/passwd? a. grep ? >/etc/passwd b. grep ? /etc/passwd c. grep ./? /etc/passwd d. grep /etc/passwd ./? e. grep '?' /etc/passwd 128. In an empty directory, what is the length of the longest file name created by the following two-command sequence: var='a ab abc abcd abcde' ; touch $var a. 15 characters b. 4 characters c. 3 characters d. 5 characters e. 19 characters 129. Which command below removes only this four-character file name containing a special character (and no others): ?abc a. rm ""?abc"" b. rm /?abc c. rm -r ?abc d. rm "?abc" e. rm ''?abc'' 130. Which command sequence below outputs only lines 11-15 of the 99-line file named cat? a. head -10 cat | tail -15 cat b. head -15 cat | tail -5 cat c. tail -15 cat | head -10 d. head -15 cat | tail -5 e. tail -10 cat | head -15 cat 131. Which of the command lines below can generate a non-empty file? a. head -5 /a/b >/a/b b. cat /a/b /a/b /a/b >/a/b c. wc -l /a/b >/a/b d. sort /a/b >/a/b e. tail /a/b >/a/b 132. If my current directory is /home, which of these pathnames is equivalent to the pathname /home/a/b/c? a. ./home/a/b/c b. /a/b/c c. ./a/b/c d. ../a/b/c e. ../home/b/c 133. Which of these statements is true? a. The file command creates a new, empty file in the current directory b. To indicate End-of-File (no more input) to a program, type [CONTROL]-[D]. c. To erase an entire line of typing, type [ALT]-[DELETE]. d. To interrupt a Unix process from the keyboard, type [CONTROL]-[D]. e. To telnet to ACADUNIX from outside the College, use the name acadunix.algonquin. 134. Which command sequence outputs inode/filename pairs for names in the current directory, sorted by inode number? a. ls -node * > sort -n b. ls -ai | sort -n c. ls ./* | sort -node d. sort -n | ls -ai e. ls -i * > sort -n 135. If /etc/passwd is a file name, which of the following pathnames always leads to the same file? a. /etc/../../passwd b. ././etc/passwd c. /./../etc/./passwd d. /etc/passwd/./. e. /etc/passwd/../.. 136. Which command line below does not show any lines from inside the file out? a. tail out b. head -99 out c. sort -n out d. wc out e. more out 137. What is the output of this shell command line in an empty directory? echo * a. . .. b. .. c. no output d. * e. . 138. What appears on your screen after this bash shell command line? echo hi | wc -c a. 1 b. no output c. 3 d. 2 e. 0 139. Which command below removes only this five-character file name containing a special character (and no others): date? a. rm date\\? b. rm ./date\? c. rm date\* d. rm date/? e. rm ./date? 140. What is the link count of directory dir after this set of successful commands? mkdir dir ; touch foo ; cd dir ; ln ../foo bar a. 2 b. 5 c. 1 d. 3 e. 4 141. If file foo occupies one disk block, 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. 5 blocks b. 4 blocks c. 1 block d. 2 blocks e. 3 blocks 142. What appears on your screen after this sequence of commands: echo one >x ; cp x y ; echo two >>y ; sort x >y ; cat y a. empty file - no output on the screen b. two followed by one c. one d. two e. one followed by two 143. If you type the command grep pattern which of the following key sequences will send an EOF and take you immediately back to the command prompt? a. [CTRL-D] b. [CTRL-C] c. [CTRL-R] d. [CTRL-U] e. [CTRL-L] 144. Which command line below does not show any lines from inside the file bat? a. ls bat b. head bat c. more bat d. tail bat e. less bat 145. If you type the command sort which of the following key sequences will send an EOF and take you immediately back to the command prompt? a. [CTRL-C] b. [CTRL-D] c. [CTRL-L] d. [CTRL-U] e. [CTRL-R] 146. Given an existing file of yours named /a/b/x, what is the output of this sequence of three shell commands: echo hi >/a/b/x ; wc /a/b/x >/a/b/x ; cat /a/b/x a. 1 1 3 /a/b/x b. 1 1 1 /a/b/x c. no output d. 0 0 0 /a/b/x e. 1 1 2 /a/b/x 147. What is in the file x after this command sequence: echo foo >a ; rm b ; echo bar >>b ; cp a b >x a. foo b. no such file (nonexistent) c. bar d. foo followed by bar e. nothing - empty file - no data 148. Which command line lists all possible utilities available for compiling programs? a. grep /etc/* compile b. man compile c. apropos compile d. grep compile /etc/* e. man * | grep compile 149. How many arguments does the shell pass to this echo command: echo " 1 2 "three ' 4 ' five"6" a. Five arguments. b. Nine arguments. c. Four arguments. d. Three arguments. e. One argument. 150. Which one of the following commands will leave file1 non-empty? a. wc file1 > file1 b. tail file1 > file1 c. cat file1 > file1 d. head file1 > file1 e. sort file1 > file1 151. Which of the following is true, given this long directory listing from ls: drwxr-x--x 123 ian user 456 May 30 12:35 dir a. The number 123 is the size of this directory. b. The number 123 is the inode number of this directory. c. The number 123 is the octal permissions of this directory. d. The number 456 is the size of this directory. e. The number 456 is the count of links (names) this directory has. 152. What command shows all the lines in file foo that contain the string bar? a. grep bar foo b. grep cat foo bar c. grep bar >foo d. grep foo bar e. cat foo > grep bar 153. What is the output on your screen of the following sequence of commands: echo hi >wc ; wc wc >hi ; cat hi a. 1 1 2 wc b. no output c. 1 1 3 wc d. 0 0 0 wc e. hi 154. In an empty directory, how many arguments are passed to the rm command in this bash command line? date >a1 ; touch a2 ba ca >all ; rm a* a. 4 b. 3 c. 2 d. 1 e. none 155. In an empty directory, what is the length of the longest file name created by the following sequence: var='a ab abc abcd abcde' ; touch '$var' a. 4 characters b. 5 characters c. 3 characters d. 19 characters e. 15 characters 156. Which of the following VI/VIM key sequences will move the entire line on which the cursor resides to after the line that follows it (i.e. it would move line 5 to be line 6 and line 6 would become line 5)? a. ddP b. ddp c. DDp d. :dp e. DDP 157. How many lines are in file out after this bash shell command line? echo hi >dog >cat >out a. 2 b. no such file (file does not exist) c. 1 d. no output (empty file) e. 3 158. Which of the following shell command lines displays all the names in the current directory that are exactly three digits long (and no others)? a. echo [?][?][?] b. echo [0-9][0-9][0-9] c. echo [1-3][1-3][1-3] d. echo ??? e. echo [3][3][3] 159. In an empty directory, what appears on your screen after this bash command line? touch a ; ls | wc -l a. 3 b. 1 c. 2 d. no output e. 0 160. If you type the command head which of the following key sequences will send an EOF and take you immediately back to the command prompt? a. [CTRL-L] b. [CTRL-D] c. [CTRL-U] d. [CTRL-C] e. [CTRL-R] 161. Which of the following is true, given this long directory listing from ls: drwxr-x--x 456 ian user 123 May 30 12:35 dir a. The number 123 is the count of links (names) this directory has. b. The number 456 is the octal permissions of this directory. c. The number 123 is the size in bytes of this directory. d. The number 456 is the size of this directory. e. The number 456 is the inode number of this directory. 162. Which of these command sequences will make file3 contain all of the content of file1 followed by all of the content of file2? a. mv file1 file2 >file3 b. cp file1 file2 >file3 c. cp file1 >file3 file2 >file3 d. echo file1 file2 >file3 e. cat file1 file2 >file3 163. What appears on your screen after this bash shell command line? echo hi >a ; cat a | wc -c a. 2 b. 4 c. 1 d. no output e. 3 164. How many lines are in the file out after this command sequence: echo hi >x ; echo ho >>x ; cat x x x >out a. 3 b. nothing - empty file - no data c. 2 d. 6 e. 1 165. How many arguments and options are there to the command: ls -ls /cat a. Two command line arguments, one of which contains two bundled options. b. Two options, no arguments. c. Two arguments, one of which is a single option and the other is a pathname. d. Two arguments, no options. e. A three-letter file name and a /cat switch option argument. 166. 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. 4 b. 3 c. 2 d. 1 e. 5 167. How many arguments are passed to the command by the shell on this command line: bat bat bat a. 6 b. 4 c. 3 d. 7 e. 5 168. What is the output on your screen of this command sequence: echo dog >one ; echo cow | head -2 one a. dog followed by cow b. cow followed by dog c. dog d. cow e. an error message 169. How can you ask the bash (Linux) shell to complete commands or file names for you? a. Type [CONTROL]-[D] and the shell will present a menu of commands. b. You can type the first part of the command or file name and press the TAB key. c. Type [CONTROL]-[ALT]-[DEL] and the shell will present a menu of commands. d. Type [ALT]-[F2] the shell will present a menu of commands. e. You can type the first part of the command or file name and press the ALT key. 170. In an empty directory, how many arguments are passed to the cat command in this bash command line? date >a1 ; touch a2 ba ca ; cat a* a. 1 b. 3 c. none d. 2 e. 4 171. In an empty directory, how many words are in file out after this bash shell command line? touch 1 2 3 2 1 ; ls >out a. 6 b. 3 c. 5 d. 4 e. no output (empty file) 172. What is in the file out after this command sequence: echo hi >x ; echo ho >>x ; cp x y >out a. nothing - empty file - no data b. hi followed by ho c. no such file (nonexistent) d. ho e. hi 173. Which command below removes only this four-character file name containing a special character (and no others): *xyz a. rm *"xyz" b. rm ''*xyz c. rm "*xyz" d. rm ''*xyz'' e. rm *xyz 174. What is true about this output from ls -il foo bar? 816 -rw-r--r-- 2 root root 3 Jan 24 01:03 foo 817 -rw-r--r-- 2 root root 3 Jan 24 01:03 bar a. this output is not possible b. foo and bar are two of three names for this file c. foo and bar each have three names (six names total) d. foo and bar are names for different files e. foo and bar are names for the same file 175. If your terminal type is xterm, what is the output of this bash shell command line? echo '$TERM' a. xterm b. 'xterm' c. no output d. $TERM e. '$TERM' 176. What is the output of this sequence of three shell commands: echo x >abc ; ls >abc abc ; wc abc a. 1 1 3 abc b. 1 1 2 abc c. 0 0 0 abc d. 1 1 4 abc e. no output 177. If file /a contains 20 lines, and file /b contains 30 lines, then how many lines are in file /c after this sequence of shell commands: sort /a /b >/c ; cat /a >>/b ; sort /c /b /a >/c a. 70 b. 120 c. 50 d. 80 e. no lines (empty file) 178. What is the link count of directory dir after this set of successful commands? mkdir a ; mkdir a/b ; mkdir a/c ; mkdir a/b/c a. 3 b. 4 c. 1 d. 2 e. 5 179. If directory foo contains only these four three-character file names: .x1, .x2, .z3, .z., then what is the output of the following bash shell command line: echo foo/??? a. no output b. foo/.x1 foo/.x2 foo/.z3 foo/.z. c. foo/??? d. foo/.z. e. foo/.x1 foo/.x2 foo/.z3 180. How many arguments does the shell pass to this echo command: echo 'And it's not hard, it's just logical.' a. Six arguments. b. Five arguments. c. Four arguments. d. Three arguments. e. Seven arguments. 181. How many arguments are passed to the command by the shell on this command line: cow cow a. 4 b. 7 c. 6 d. 5 e. 3 182. What is true about this output from ls -il foo bar? 871 -r-------- 3 bin bin 2 Apr 22 10:15 foo 872 -r-------- 3 bin bin 2 Apr 22 10:15 bar a. foo and bar are two of three names for this file b. foo and bar each have two names (four names total) c. foo and bar each have three names (six names total) d. this output is not possible e. foo and bar are names for the same file 183. If file foo contains nine lines, each of which is the one-digit line number of the line in the file (1 through 9), what is the output on your screen of this command: cat foo foo | sort -r | head -5 | tail -1 a. 9 b. 5 c. 8 d. 7 e. 6 184. What is the link count of directory dir after this set of successful commands? mkdir dir ; mkdir dir/foo ; touch dir/bar a. 5 b. 4 c. 2 d. 1 e. 3 185. What appears on your screen after this bash shell command line? echo hi >a ; echo a | wc -c a. 3 b. 4 c. 2 d. 1 e. no output 186. If file /a contains 40 lines, and file /b contains 60 lines, then how many lines are output by this command: sort /a /b | cat /a | cat /b a. 160 b. 100 c. 40 d. 60 e. 200 187. If /bin/bash is a file name, which of the following pathnames always leads to the same file? a. ./bin/bash b. /bin/bash/.. c. /bin/../bash d. /../../bin/bash e. /bin/bash/. 188. If file /a contains thirty lines, and file /b contains fifty lines, then how many lines are in file /c after this sequence of shell commands: cat /a /b >/c ; sort /c >/c ; sort /c /a /b >/c a. 50 b. 160 c. no lines (empty file) d. 80 e. 30 189. If directory /a contains these seven two-character file names: aa, ab, ac, ad, a?, a*, a., then which shell command below will remove only the single name a* from the directory (and no others)? a. rm /a* b. rm /a/* c. rm /a/a? d. rm /a/a\* e. rm /a/a* 190. Which command below removes only this five-character file name containing a special character (and no others): yy?yy a. rm yy\\?yy b. rm yy?yy c. rm yy/?yy d. rm yy//?yy e. rm yy\?yy 191. What is the output of this sequence of three shell commands: echo hi >wc ; ls wc >wc ; wc wc a. no output b. 1 1 2 wc c. 1 1 3 wc d. 2 2 4 wc e. 0 0 0 wc 192. If directory dir contains only these five two-character file names: a?, 11, ?1, 1*, .1, then which shell command below will remove only the single two- character name ?1 from the directory? a. rm dir/?1 b. rm dir/?? c. rm dir/\?? d. rm dir/*1 e. rm dir/1* 193. What text is output by this bash shell command sequence: echo dog >out ; echo cat | sort out a. dog b. dog followed by cat c. out d. cat followed by dog e. cat 194. Which of the command lines below can generate a non-empty file? a. tail -3 file >file b. cat file file file >file c. sort -r file >file d. wc -wc file >file e. head -5 file >file 195. Which command below is the best way to find a line containing an asterisk (*) in the file named foo? a. grep foo [*] b. grep '*' foo c. grep * foo d. grep ./* foo e. grep foo "*" 196. If foo is a sub-directory that contains only the file single, what happens after this command: mv ./foo/single foo/../double a. the command fails because the name double does not exist b. the command fails because the name foo/../double does not exist c. the directory foo now contains only a file named double d. the directory foo is now empty e. there is a second copy of the file single in the file named double 197. Which of these command sequences will make file foo contain all of the content of file a followed by all of the content of file b? a. cp a b >foo b. echo a b >foo c. mv a b >foo d. cp a >foo ; cp b >>foo e. cat a >foo ; cat b >>foo 198. If you type the command echo 'missing quote which of the following key sequences will interrupt it and take you immediately back to the command prompt? a. [CTRL-R] b. [CTRL-C] c. [CTRL-D] d. [CTRL-U] e. [CTRL-L] 199. If file ten contains ten lines, and file twenty contains twenty lines, then how many lines are output by this command: cat twenty | sort ten a. 10 b. 60 c. no lines (no output) d. 20 e. 30 200. If my current directory is /etc, which of these pathnames is equivalent to the file name /etc/passwd? a. ./passwd b. ../passwd c. /passwd d. ../etc/passwd/. e. ./etc/passwd 201. What will appear on your screen after this sequence of commands: echo one >x ; ln x y ; echo two >y echo ten >x ; cat y a. one followed by two and ten b. one c. no output on screen d. two e. ten 202. If file /a contains thirty lines, and file /b contains fifty lines, then how many lines are output by this command: cat /a | sort /b a. 30 b. 80 c. 50 d. 20 e. no lines (empty file) 203. Which command below removes only this five-character file name containing a special character (and no others): *test a. rm ./\\*test b. rm "*test" c. rm ./*test d. rm ''*test'' e. rm \\*test Answer Key - NET2003 - Ian Allen - Winter 2005 - NET2003 Practice Test Office use only: 45 13 203 91 166 153 121 6 73 66 127 184 86 63 8 11 189 35 99 79 14 58 100 186 198 124 151 195 164 4 142 156 51 144 202 71 81 141 55 168 157 108 133 161 150 175 56 135 78 193 70 39 15 146 88 109 120 158 106 67 167 31 104 201 123 96 42 170 199 194 200 132 50 116 48 143 182 179 95 54 29 77 19 126 154 183 85 152 98 177 9 181 37 46 160 59 30 38 25 24 52 27 5 139 173 75 115 176 162 10 111 2 131 188 83 185 114 62 22 93 44 149 60 57 34 17 171 89 72 105 26 140 92 12 1 33 43 53 64 136 192 82 21 32 18 125 174 87 36 190 41 165 80 102 90 191 74 145 61 20 40 197 47 94 97 196 110 178 16 101 122 107 68 76 180 129 119 137 113 169 112 128 7 134 49 163 3 118 103 69 130 187 155 28 172 159 117 23 147 138 84 148 65 1. e 45. b 2. c 46. d 3. a 47. a 4. c 48. c 5. d 49. d 6. a 50. d 7. e 51. e 8. a 52. e 9. e 53. a 10. c 54. c 11. c 55. b 12. c 56. c 13. b 57. d 14. a 58. b 15. e 59. a 16. a 60. d 17. d 61. a 18. c 62. d 19. a 63. a 20. e 64. a 21. b 65. a 22. a 66. e 23. d 67. c 24. e 68. d 25. a 69. d 26. b 70. b 27. e 71. b 28. e 72. a 29. c 73. c 30. d 74. a 31. b 75. a 32. e 76. a 33. d 77. b 34. d 78. b 35. a 79. e 36. a 80. b 37. d 81. c 38. a 82. e 39. a 83. a 40. a 84. a 41. d 85. d 42. d 86. c 43. d 87. a 44. e 88. d 89. c 145. b 90. e 146. d 91. c 147. e 92. e 148. c 93. b 149. d 94. b 150. a 95. a 151. d 96. b 152. a 97. b 153. c 98. d 154. b 99. a 155. a 100. e 156. b 101. a 157. c 102. c 158. b 103. a 159. b 104. c 160. b 105. a 161. c 106. d 162. e 107. b 163. e 108. d 164. d 109. d 165. a 110. a 166. a 111. b 167. b 112. e 168. c 113. e 169. b 114. a 170. d 115. b 171. d 116. d 172. a 117. e 173. c 118. d 174. d 119. e 175. d 120. c 176. d 121. b 177. a 122. b 178. b 123. d 179. c 124. e 180. c 125. c 181. e 126. a 182. c 127. e 183. d 128. d 184. e 129. d 185. c 130. d 186. d 131. c 187. d 132. c 188. d 133. b 189. d 134. b 190. e 135. c 191. c 136. d 192. c 137. d 193. a 138. c 194. d 139. b 195. b 140. a 196. d 141. e 197. e 142. c 198. b 143. a 199. a 144. a 200. a 201. e 202. c 203. b Count of a: 48 24% Count of b: 36 18% Count of c: 38 19% Count of d: 48 24% Count of e: 33 16% With 5 choices: 203 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 Macro .cmd split no indent: 0 Macro .cmd split with indent: 80 Macro .ans splits: 0