Practice Test #1 Questions - answers at end 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 - 177 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. The answers to this test are in the Answer Key on the last page(s). 1. What is the output on your screen of this shell command line in an empty directory? touch 1 2 3 .a .ab .abc ; echo [.]* a. no output on screen b. . .. .a .ab .abc c. an error message from echo saying [.]* does not exist d. [.]* e. .a .ab .abc 2. What would you see if you typed this command: cat /users a. The contents of your directory named users b. The contents of your subdirectory named users c. The contents of the file users located in the root directory d. The contents of the file users located in the parent directory e. The contents of the file users located in your home directory 3. If directory /a/b contains these four three-character file names: .aa, .ab, .a?, .a*, then what is the output on your screen of the following bash shell command line: echo /a/b/??? a. no output on screen b. /a/b/.a? c. /a/b/??? d. /a/b/.aa /a/b/.ab e. /a/b/.aa /a/b/.ab /a/b/.a? /a/b/.a* 4. If file a contains 20 lines, and file b contains 30 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. 100 b. no lines (empty file) c. 60 d. 50 e. 30 5. Which command shows the name of the current computer: a. users b. hostname c. ifconfig d. who e. w 6. In an empty directory, what appears on your screen after this bash command line? touch a ; ls | wc -l a. 0 b. no output on screen c. 3 d. 1 e. 2 7. 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. 8. What appears on your screen after this bash shell command line? echo xx >z ; ls z > wc a. 2 b. no output on screen c. 3 d. 1 1 2 e. 1 1 3 9. What is the output on your screen of the following sequence of commands: echo hi >wc ; wc wc >hi ; cat hi a. hi b. 0 0 0 wc c. 1 1 3 wc d. no output on screen e. 1 1 2 wc 10. If my current directory is /usr, which of these pathnames is equivalent to the pathname /usr/x/y/z? a. x/./y/z b. ./usr/x/y/z c. /x/y/z d. ../usr/y/z e. ../x/y/z 11. What is in the file out after this command sequence: echo hi >x ; echo ho >>x ; cp x y >out a. hi followed by ho b. ho c. no such file (nonexistent) d. hi e. nothing - empty file - no data 12. If /etc/passwd is a file name, which pathname always leads to the same file? a. /../etc/passwd b. /etc/passwd/../.. c. ./etc/passwd d. /etc/passwd/. e. /etc/../../passwd 13. 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 | tail -4 | head -1 a. 1 b. 4 c. 8 d. no output on screen e. 6 14. 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. 2 c. none d. 1 e. 3 15. If cow is a sub-directory that contains only the file dog, what happens after this command: mv cow/dog cow/././cat a. the command fails because the name cat does not exist b. there is a second copy of the file dog in the file named cat c. the command fails because the name cow/././cat does not exist d. the directory cow now contains only a file named cat e. the directory cow is now empty 16. In an empty directory, how many arguments are passed to the rm command in this bash command line? touch a a1 a2 ba ca ; rm a* a. 2 b. 1 c. 3 d. 4 e. none 17. If my current directory is /etc, which of these pathnames is equivalent to the file name /etc/passwd? a. ../passwd b. ./etc/passwd c. ./passwd d. /passwd e. ../etc/passwd/. 18. Which of these statements is true? a. Unix commands can be entered in upper-case or lower-case letters; they are equivalent. b. To indicate End-of-File (no more input), type [CONTROL]-[E]. c. Unix commands must be entered in lower-case letters. d. To erase an entire line of typing, type [CONTROL]-[E]. e. You can only login to Unix once per userid; you cannot be logged in to the same machine twice. 19. Given an existing file of yours named wc, what is the output on your screen of this sequence of three shell commands: echo hi >wc ; sort wc >wc ; cat wc a. 0 0 0 wc b. no output on screen c. 1 1 2 wc d. 1 1 3 wc e. 2 2 4 wc 20. What appears on your screen after this bash shell command line? echo hi | wc -c a. no output on screen b. 1 c. 3 d. 2 e. 0 21. 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. ../home/b/c d. ../home/a/b/c e. /a/b/c 22. What appears on your screen after this bash shell command line? echo hi >ls ; cat ls > wc a. no output on screen b. ls c. 1 1 3 d. 1 1 2 e. hi 23. What is the output on your screen of this shell command line in an empty directory? touch .1 .2 .3 4 5 6 ; echo .* a. . .. .1 .2 .3 b. .* c. an error message from echo saying .* does not exist d. .1 .2 .3 4 5 6 e. 4 5 6 24. 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 [0-9][0-9][0-9] b. echo ??? c. echo [1-3][1-3][1-3] d. echo [?][?][?] e. echo [3][3][3] 25. What is in file cow after running this bash shell command line? echo one two >cow three a. no output (empty file) b. one two cow three c. echo one two d. one two e. one two three 26. In the output of the command ls -a, the one-character name . signifies what? a. A name with an unprintable character. b. A current file. c. A name that is hidden. d. The current directory. e. The parent directory. 27. If I am in my home directory named /home/idallen and empty is an empty sub- directory, what is true after this command line: touch ./pig ; mv ./empty/../pig ../idallen/cow a. the directory empty now contains only a file named cow b. the command fails because path ./empty/../pig does not exist c. there is a second copy of the file pig in the file named cow d. the directory empty/.. now has a file named cow in it e. the command fails because path ../idallen/cow does not exist 28. Which command pipeline outputs the count of the number of userids containing the string allen that are currently logged in? a. grep allen | wc | who b. who | grep allen | wc c. grep allen | who | wc d. who | wc allen | grep e. who | grep | allen wc 29. Which command line displays all the non-hidden names in the current directory that contain the letter x (and no others)? a. echo ?x? b. echo x* c. echo *x d. echo *x* e. echo [x] 30. If file twenty contains 20 lines, and file thirty contains 30 lines, then how many lines are output on your screen by this command: tail thirty | cat twenty a. 20 b. no lines (no output) c. 30 d. 50 e. 21 31. What is the output on your screen of this successful command sequence? cd /tmp ; mkdir foo ; mkdir bar ; pwd a. /bar b. /tmp/foo c. /tmp/bar d. /tmp/foo/bar e. /tmp 32. If directory cow contains only these four three-character file names: .AA, .A1, .BB, .B., then what is the output on your screen of this command line: echo cow/* a. cow/* b. cow/.B. c. cow/.AA cow/.A1 cow/.BB cow/.B. d. no output on screen e. cow/.AA cow/.A1 cow/.BB 33. Which command line lists all possible utilities available for compiling programs? a. man * | grep compile b. man -k compile c. grep compile /etc/* d. grep /etc/* compile e. man compile 34. Which command pipeline outputs the count of the number of pathnames (including all subdirectories) that lie under the /etc directory? a. man /etc ; wc b. dir /etc | count c. ls /etc ; wc d. find /etc | wc e. ls /etc | wc 35. When doing an ls -a, the output pathname that is a double dot (..) signifies what? a. A hidden file. b. The root directory. c. The current directory. d. The parent directory. e. A file or directory with double links. 36. What is the output on your screen of this shell command line in an empty directory? touch 1 .1 23 .23 456 ; echo [12]* a. [12]* b. 1 .1 23 .23 c. 1 23 d. an error message from echo saying [ab]* does not exist e. 1 .1 23 .23 456 37. What is in the file cow after this command line: echo a >a ; echo b >b ; mv a b >cow a. nothing - empty file - no data b. a c. no such file (nonexistent) d. a followed by b e. b 38. If file x contains 10 lines, and file y contains 20 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. 40 b. no lines (empty file) c. 50 d. 45 e. 60 39. When doing an ls -a, the output pathname that is a double dot (..) signifies what? a. The root directory. b. A hidden file. c. The current directory. d. A pathname with double links. e. The parent directory. 40. Given an existing file of yours named /a/b/x, what is the output on your screen 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. 1 1 2 /a/b/x d. no output on screen e. 0 0 0 /a/b/x 41. What is the output on your screen of this shell command line in an empty directory? touch x .a .ab .cde .fghi ; echo .??* a. .??* b. an error message from echo saying .??* does not exist c. .ab .cde .fghi d. . .. .a .ab .cde .fghi e. .cde .fghi 42. What is the output on your screen of this successful command line? cd /home/myhome ; mkdir foo ; mkdir bar ; pwd a. /home/myhome/foo b. /home/myhome c. /bar d. /home/myhome/foo/bar e. /home/myhome/bar 43. 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. 7 b. 7 7 7 c. 1 1 1 d. 8 e. 9 44. What is the output of this sequence of three shell commands: echo x >abc ; ls >abc abc ; wc abc a. 0 0 0 abc b. 1 1 2 abc c. 1 1 4 abc d. 1 1 3 abc e. no output on screen 45. What is the output on your screen of this shell command line in an empty directory? cat * a. . b. an error message from cat saying * does not exist c. no output on screen d. * e. . .. 46. Which of the following shell command lines displays only the names in the current directory that are exactly three alphabetic letters long? a. echo [a-zA-Z][a-zA-Z][a-zA-Z] b. echo *** c. echo [0-3][0-3][0-3] d. echo [?][?][?] e. echo ??? 47. How many lines are in file out after this bash shell command line? echo hi >dog >cat >out a. no such file (file does not exist) b. nothing - empty file - no data c. 2 d. 1 e. 3 48. How many lines are in the file bar after this command sequence: echo hi >x ; echo ho >>x ; cat x x >bar a. nothing - empty file - no data b. 2 c. 4 d. 1 e. 6 49. In an empty directory, what appears on your screen after this bash command line? touch a ; ls >wc -l a. 1 b. 3 c. 0 d. no output on screen e. 2 50. 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-C] b. [CTRL-L] c. [CTRL-U] d. [CTRL-R] e. [CTRL-D] 51. In an empty directory, how many words are in file cow after this bash shell command line? touch dog dog cat ; ls >cow a. 4 b. no output (empty file) c. 1 d. 2 e. 3 52. 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. 8 c. 7 d. 1 1 1 e. 7 7 7 53. 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. :dp d. DDp e. ddp 54. In an empty directory, how many arguments are passed to the cat command in this bash command line? touch a1 a2 ac ba .a ; cat a* a. 1 b. 3 c. none d. 4 e. 2 55. Which of the command lines below can generate a non-empty file? a. cat /a/b /a/b /a/b >/a/b b. wc -l /a/b >/a/b c. head -5 /a/b >/a/b d. sort /a/b >/a/b e. tail /a/b >/a/b 56. What is the output on your screen of this shell command line in an empty directory? touch .a .b .c ; echo .* a. .* b. .a .b .c c. an error message from echo saying .* does not exist d. . .. .a .b .c e. no output on screen 57. What is the output on your screen of this shell command line in an empty directory? touch .a .b .c ; echo .??* a. .??* b. .a .b .c c. an error message from echo saying .??* does not exist d. . .. .a .b .c e. no output on screen 58. Which command line below never shows any lines from inside the file cow? a. wc -l cow b. head -1 cow c. tail -8 cow d. sort -r cow e. grep pattern cow 59. 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-C] b. [CTRL-L] c. [CTRL-U] d. [CTRL-R] e. [CTRL-D] 60. Which command line below does not show any lines from inside the file dog? a. head -3 dog b. less dog c. ls dog d. sort -r dog e. tail -8 dog 61. How many lines are in the file out after this command sequence: echo hi >out ; echo ho >out ; cat out out >out a. 6 b. nothing - empty file - no data c. 2 d. 3 e. 1 62. What is the output on your screen of this command sequence: echo dog >one ; echo cow | head -2 one a. dog b. cow followed by dog c. cow d. an error message e. dog followed by cow 63. What is in file out after running this bash shell command line? echo a >out b c a. echo a b. b c c. a b c d. no output on screen e. a 64. 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. 6 b. 7 c. 8 d. 5 e. 9 65. 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 xx/../../etc/passwd xx/foo c. cp ../home/xx/../etc/passwd ./xx/./foo d. cp xx/../etc/passwd ../home/xx/foo e. cp ../etc/passwd ../xx/foo 66. What command shows all the lines in file foo that contain the string group? a. grep group foo b. grep group ; foo c. cat foo ; grep group d. grep foo group e. cat foo | wc group 67. What is in file two after running this command line? echo one >two three four a. one three four b. three four c. one d. echo one e. empty file (no data) 68. 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. 4 b. 5 c. 6 d. no output (empty file) e. 3 69. Which command line lists all possible utilities available for compiling programs? a. man * | grep compile b. grep /etc/* compile c. man compile d. grep compile /etc/* e. apropos compile 70. If /bin/bash is a file name, which pathname always leads to the same file? a. ./../bin/bash b. /bin/../bash c. /../bin/./bash d. /bin/bash/. e. /bin/bin/../bash 71. What is in file out after running this bash shell command line? echo 2 3 >out 3 0 a. 2 3 b. 2 3 3 0 c. no output (empty file) d. 2 3 >out 3 0 e. 2 3 0 72. 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 ./me/../etc/passwd ../home/me/foo c. cp ../etc/passwd ../me/foo d. cp me/../../etc/passwd me/foo e. cp ../home/me/../etc/passwd ./me/./foo 73. Which of these commands always returns you to your account home directory? a. cd b. cd /home c. cd .. d. cd /home/.. e. cd home 74. Which command sequence below outputs only lines 10-15 of the Unix password file? a. head -15 /etc/passwd | tail -5 /etc/passwd b. head -10 /etc/passwd | tail -15 /etc/passwd c. tail -10 /etc/passwd | head -15 /etc/passwd d. head -15 /etc/passwd | tail -6 e. tail -15 /etc/passwd | head -10 75. 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: cat nine nine | sort -r | head -4 | tail -1 a. 5 b. 7 c. 9 d. 8 e. 6 76. What is the output on your screen of this shell command line in an empty directory? touch .a .b .c ; echo [.]* a. . .. .a .b .c b. .a .b .c c. an error message from echo saying [.]* does not exist d. [.]* e. no output on screen 77. What is the output on your screen of this shell command line in an empty directory? echo * a. * b. .. c. . .. d. no output on screen e. . 78. What appears on your screen after this bash shell command line? echo hi >a ; ls a > wc a. no output on screen b. 2 c. 1 1 3 d. 3 e. 1 1 2 79. In the output of the command ls -a, a dot that begins a name signifies what? a. The current directory. b. A current file. c. A name that is hidden. d. The parent directory. e. A name with an unprintable character. 80. If file foo 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 on your screen of this command: sort -r foo foo | tail -4 | head -1 a. 96 96 b. 96 c. 02 d. 98 e. 04 04 81. What is the possible output on your screen of this command line: echo wc >date ; sort date >date ; cat date a. 1 6 29 date b. 1 6 28 date c. Wed Jan 26 13:00:00 EST 2005 d. no output on screen e. wc 82. 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-D] b. [CTRL-R] c. [CTRL-L] d. [CTRL-C] e. [CTRL-U] 83. If /etc/passwd is a file name, which pathname always leads to the same file? a. /etc/./etc/../passwd b. ../etc/passwd c. /etc/../etc/passwd d. /etc/passwd/. e. ./etc/passwd 84. In an empty directory, how many words are in file pig after this command line? touch pig pig ; ls >pig a. 4 b. 2 c. 1 d. empty file (no data) e. 3 85. In an empty directory, how many arguments are passed to the wc command in this command line? date >o1 ; touch a1 b2 out >o1 ; wc o* a. 4 b. 2 c. 1 d. 5 e. 3 86. What appears on your screen after this bash shell command line? echo cow | wc a. 3 1 1 b. 1 3 1 c. 1 1 4 d. 1 1 3 e. no output on screen 87. If /etc/passwd is a file name, which pathname always leads to the same file? a. /etc/passwd/./. b. /./../etc/./passwd c. ././etc/passwd d. /etc/passwd/../.. e. /etc/../../passwd 88. What is the output of this sequence of this command sequence: echo hi >hi ; head hi >hi ; wc hi a. 1 1 3 hi b. 1 1 2 hi c. no output on screen d. 2 2 4 hi e. 0 0 0 hi 89. Which command line takes the list of users currently logged in to the machine and displays just the one line containing the userid that sorts first in the alphabet? a. sort | who | head -1 b. sort who | tail -1 c. head -1 who | sort d. who | sort -r | tail -1 e. head -1 sort who 90. In an empty directory, how many arguments are passed to the cat command in this bash command line? touch a1 a2 ba ca ; cat a* a. 3 b. 2 c. 1 d. none e. 4 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: cat nine nine | tail -5 | head -1 a. 9 b. 6 c. 8 d. 7 e. 5 92. What is in the file named file after this command sequence: echo a >c ; echo b >>c ; mv c d >file a. b b. a c. nothing - file is empty - no data d. a followed by b e. no such file (nonexistent file) 93. Which of the following statements is true about this shell command line: >/a/b/c cat /a/b/d a. The command is always invalid. b. The command /a/b/c sees two arguments. c. The command cat sees two arguments. d. The command cat sees only one argument. e. The command /a/b/c sees only one argument 94. If I am in my home directory named /home/ian and mt is an empty sub- directory, what is true after this command line: touch ../ian/cat ; cp ./mt/../cat ./mt/../dog a. there is a second copy of the file named who in the file dog b. the command fails because the path ./mt/../cat does not exist c. the directory mt now contains two files d. the directory mt is still empty e. the directory mt now has a file named dog in it 95. 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-R] b. [CTRL-U] c. [CTRL-C] d. [CTRL-L] e. [CTRL-D] 96. What command shows all the lines in file /etc/group that contain the string idallen? a. cat /etc/group | wc idallen b. grep idallen /etc/group c. grep /etc/group idallen d. cat /etc/group > grep idallen e. grep idallen >/etc/group 97. What is the output on your screen of this shell command line in an empty directory? touch 1 2 3 .a .b .c ; echo .??* a. an error message from echo saying .??* does not exist b. .??* c. . .. .a .b .c d. . .. 1 2 3 .a .b .c e. .a .b .c 98. 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-L] c. [CTRL-U] d. [CTRL-C] e. [CTRL-R] 99. Which of the command lines below can generate a non-empty file? a. grep pattern file >file b. cat file >file c. sort -r file >file d. ls -l file >file e. head -1 file >file 100. What text is output by this bash shell command sequence: echo dog >out ; echo cat | sort out a. out b. cat followed by dog c. dog d. cat e. dog followed by cat 101. If file /a/b contains 99 lines, each of which is the two-digit line number of the line in the file (01 through 99), what is the output on your screen of this command: sort /a/b /a/b | tail -4 | head -1 a. 98 b. 04 04 c. 96 d. 01 01 e. 96 96 102. If I am in my home directory named /home/myhome and dir is an empty sub- directory, what is true after this command line: touch new ; mv ./dir/../new ../myhome/old a. there is a second copy of the file new in the file named old b. the directory dir now contains only a file named old c. the command fails because the path ./dir/../new does not exist d. the parent directory of dir now has a file named old in it e. the command fails because the path ../myhome/old does not exist 103. 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. 80 b. 70 c. 120 d. 50 e. no lines (empty file) 104. What is in the file x after this command sequence: echo foo >a ; rm b ; echo bar >>b ; cp a b >x a. no such file (nonexistent) b. nothing - empty file - no data c. bar d. foo followed by bar e. foo 105. Which command line displays the contents of the Unix passwd file one page at a time? a. less /etc/passwd b. /etc/passwd cat less c. cat less | /etc/passwd d. /etc/passwd | less e. cat /etc/passwd less 106. If file x contains 10 lines, and file y contains 20 lines, then how many lines are in file cat after this command line: sort x y >z ; tail -5 x >x ; sort x y z >cat a. 40 b. 55 c. 50 d. no lines (empty file) e. 60 107. 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-C] b. [CTRL-L] c. [CTRL-U] d. [CTRL-D] e. [CTRL-R] 108. If file /a contains 30 lines, and file /b contains 50 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. 160 b. 30 c. 80 d. 50 e. no lines (empty file) 109. What appears on your screen after this bash shell command line? echo hi | wc a. 1 2 1 b. 2 1 1 c. 1 1 2 d. 1 1 3 e. no output on screen 110. What appears on your screen after this bash shell command line? echo hi >a ; cp a b | wc -c a. 3 b. 2 c. no output on screen d. 1 e. 0 111. How many lines are in the file bar after this command line: echo hi >x ; echo ho >>x ; cat x >bar a. 1 b. 4 c. 6 d. 2 e. nothing - empty file - no data 112. What can you do to get back (redo) the last command you typed to the bash (Linux) shell? a. Type [CONTROL]-[BACKSPACE] b. Type [ALT]-[F2] c. Use the "UpArrow" key. d. Type [CONTROL]-[ALT]-[UP] e. Use the "PageUp" key. 113. 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. 2 b. 1 c. 3 d. 4 e. none 114. 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 directory foo now contains only a file named double c. the directory foo is now empty d. there is a second copy of the file single in the file named double e. the command fails because the name foo/../double does not exist 115. In an empty directory, how many arguments are passed to the rm command in this bash command line? touch 2a a a1 ba ca .a ; rm a* a. 2 b. 1 c. 4 d. 3 e. none 116. 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. no output on screen c. /dir/???? d. /dir/.123 /dir/.124 e. /dir/.123 /dir/.124 /dir/.??? 117. What appears on your screen after this bash shell command line? echo hi >a ; ls a | wc -c a. 4 b. 2 c. no output on screen d. 3 e. 1 118. If file twenty contains 20 lines, and file thirty contains 30 lines, then how many lines are output on your screen by this command: tail twenty | cat thirty a. 20 b. 30 c. 50 d. 40 e. no output on screen 119. What appears on your screen after this bash shell command line? echo hi >out ; wc -c out a. 5 out b. 2 out c. no output on screen d. 4 out e. 3 out 120. What is the output on your screen of this successful command sequence? cd /home/dir ; mkdir one ; mkdir two ; pwd a. /two b. /home/dir/one c. /home/dir/two d. /home/dir e. /home/dir/one/two 121. What is the output on your screen of this shell command line in an empty directory? touch a .a bc .bc def ; echo [ab]* a. no output on screen b. a bc c. a .a bc .bc d. an error message from echo saying [ab]* does not exist e. [ab]* 122. What is the output on your screen of this successful command sequence? cd /home/foo ; touch dir ; mkdir bar ; pwd a. /home/foo/bar b. /home/foo/dir/bar c. /bar d. /home/foo/dir e. /home/foo 123. Which of these statements is true? a. To indicate End-of-File (no more input) to a program, type [CONTROL]-[D]. b. The file command creates a new, empty file in the current directory c. To interrupt a Unix process from the keyboard, type [CONTROL]-[D]. d. To erase an entire line of typing, type [ALT]-[DELETE]. e. Command apropos is an exact synonym for command man. 124. If my current working directory is /home, and my home directory is /home/me, which 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 ../etc/passwd ./me/foo d. cp ./me/../etc/passwd ../home/me/foo e. cp ../home/me/../etc/passwd ./me/./foo 125. 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 -5 | head -1 a. 1 1 b. 5 5 c. 7 d. 9 e. 1 126. What appears on your screen after this command line? echo hi >ls ; cat ls >wc a. no output on screen b. hi c. ls d. 1 1 2 e. 1 1 3 127. If file /a contains 30 lines, and file /b contains 50 lines, then how many lines are output on your screen by this command: cat /a | sort /b a. 50 b. 20 c. 30 d. 80 e. no lines (empty file) 128. What is the output on your screen of this command sequence: echo bat >one ; echo sky | head -2 one a. bat b. sky followed by bat c. bat followed by sky d. sky e. an error message 129. Which command sequence below outputs only lines 5-10 of the file named foo? a. head -15 foo | tail -5 b. tail -10 foo | head -6 c. head -10 foo | tail -6 d. head -5 foo | tail -10 e. tail -15 foo | head -5 130. If file ten contains 10 lines, and file twenty contains 20 lines, then how many lines are output on your screen by this command: cat twenty | sort ten a. 10 b. no lines (no output) c. 20 d. 30 e. 60 131. 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 command fails because the path x/../../me does not exist b. the directory x now contains only a file named y c. there is a second copy of the file fil in the file named y d. the command fails because the path x/./fil does not exist e. the directory x is still empty 132. Which of these command lines will make file cow contain all of the content of file one followed by all of the content of file two? a. mv one two >cow b. echo one two >cow c. cp one >cow two >cow d. cp one two >cow e. cat one two >cow 133. What command can you use to remove a directory that isn't empty? a. mv -r dir b. rmdir -r dir c. rm -r dir d. deldir -r dir e. del -r dir 134. 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 [ALT]-[F2] the shell will present a menu of commands. c. Type [CONTROL]-[D] and the shell will present a menu of commands. d. Type [CONTROL]-[ALT]-[DEL] 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. 135. What would you see if you typed this command: cat /users a. The contents of the file users located in the root directory b. The contents of the file users located in your home directory c. The contents of your directory named users d. The contents of the file users located in the parent directory e. The contents of your subdirectory named users 136. What command shows all the lines in file foo that contain the string bar? a. grep bar foo b. grep foo bar c. grep cat foo bar d. cat foo > grep bar e. grep bar >foo 137. If file /a contains 40 lines, and file /b contains 60 lines, then how many lines are output on your screen by this command: sort /a /b | cat /a | cat /b a. 200 b. 100 c. 40 d. 160 e. 60 138. If /bin/bash is a file name, which pathname always leads to the same file? a. ./bin/bash b. /bin/bash/.. c. /../../bin/bash d. /bin/bash/. e. /bin/../bash 139. Which Unix command sequence deletes a directory and everything inside it? a. rm -r dir b. deltree -all dir c. rmdir -all dir d. rmdir -r dir e. rm -all dir 140. What is the output on your screen of this shell command line in an empty directory? touch .12 .345 .6789 ; echo .??* a. . .. .12 .345 .6789 b. .??* c. no output on screen d. an error message from echo saying .??* does not exist e. .12 .345 .6789 141. What command shows all the lines in file /etc/group that contain the string idallen? a. cat /etc/group | wc idallen b. grep /etc/group idallen c. grep idallen ; /etc/group d. cat /etc/group ; grep idallen e. grep idallen /etc/group 142. What appears on your screen after this bash shell command line? echo hi >a ; echo a | wc -c a. no output on screen b. 4 c. 2 d. 3 e. 1 143. What appears on your screen after this bash shell command line? mkdir foo ; rmdir foo | wc -c a. 4 b. 1 c. no output on screen d. 3 e. 0 144. How many command arguments does the shell pass to this echo command: echo one two three >four five a. Three arguments. b. Two arguments. c. Four arguments. d. Six arguments. e. Five arguments. 145. What is the output on your screen of the following sequence of commands: echo wc >wc ; wc wc >wc ; cat wc a. wc b. 0 0 0 wc c. 1 1 2 wc d. no output on screen e. 1 1 3 wc 146. How many lines are in file out after this command line? echo hi >dog >out >cat a. no such file (file does not exist) b. 2 c. 1 d. nothing - empty file - no data e. 3 147. What appears on your screen after this bash shell command line? echo hi >a ; cat a | wc -c a. 3 b. 2 c. 1 d. no output on screen e. 4 148. How many command arguments does the shell pass to this echo command: echo 1 2 3 4 >5 a. 5 b. 4 c. 3 d. 6 e. 7 149. What appears on your screen after this command line? mkdir xx ; rmdir xx | wc -c a. 2 b. 0 c. 1 d. 3 e. no output on screen 150. If /bin/bash is a file name, which pathname always leads to the same file? a. /bin/bash/. b. ./bin/bash c. /bin/bin/../bash d. /bin/../bash e. /bin/../bin/bash 151. 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. one followed by two c. two d. two followed by one e. one 152. Which of the following statements is true about this shell command line: >bar zoom bar haven a. Error: The command name is missing from the command line. b. The command zoom sees two arguments. c. The command bar sees three arguments. d. The command bar sees only two arguments e. The command zoom sees three arguments. 153. What text is output by this bash shell command sequence: echo cow >foo ; echo dog | head -1 foo a. dog followed by cow b. cow followed by dog c. foo d. dog e. cow 154. In an empty directory, how many words are in file out after this bash shell command line? touch a ; ls >out a. 3 b. 1 c. 4 d. 2 e. no output (empty file) 155. What would you see if you typed this command: cat /foo a. The contents of the file foo located in the parent directory b. The contents of your subdirectory named foo c. The contents of your directory named foo d. The contents of the file foo located in the root directory e. The contents of the file foo located in your home directory 156. What appears on your screen after this bash shell command line? echo hi >out | wc -c a. no output on screen b. 3 c. 0 d. 2 e. 1 157. 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. 8 c. 9 d. 7 e. 5 158. How many lines are in the file out after this command sequence: echo hi >x ; echo ho >>x ; cat x x x >out a. 1 b. 2 c. 3 d. 6 e. nothing - empty file - no data 159. Which command pipeline outputs the count of the number of manual page titles that contain the keyword "sort"? a. wc man sort b. man sort | wc c. man -k sort | wc d. man sort ; wc e. wc -k sort 160. 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. 8 b. 6 c. 9 d. 5 e. 7 161. How do I change "foo" to "bar" on lines 25 to 30 in the vim editor? a. :25s/foo/bar/*5 b. :25-30 change "foo","bar" c. :25,30 change "foo" "bar" d. :25c foo bar *5 e. :25,30s/foo/bar/ 162. 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. nothing - empty file - no data c. no such file (nonexistent) d. hi e. ho 163. What is true about this bash shell command line? date >ls ; ls -ls ls >wc a. The ls command receives the output of date on standard input. b. The wc command counts the output of the ls command. c. The file wc has one line in it. d. The ls command is executed more than once. e. The shell finds and executes three different commands. 164. What is the output of this sequence of three shell commands: echo hi >wc ; ls wc >wc ; wc wc a. 1 1 3 wc b. 1 1 2 wc c. no output on screen d. 0 0 0 wc e. 2 2 4 wc 165. 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. mv in1 in2 >out b. cat in1 in2 >out c. cp in1 >out in2 >out d. cp in1 in2 >out e. echo in1 in2 >out 166. What is the output on your screen of this command sequence: echo foo >file ; echo bar | sort file a. foo b. bar followed by foo c. bar d. foo followed by bar e. an error message 167. 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 >foo ; cp b >>foo b. mv a b >foo c. cat a >foo ; cat b >>foo d. echo a b >foo e. cp a b >foo 168. How many lines are in the file out after this command sequence: echo hi >x ; echo ho >x ; cat x x x >out a. 1 b. 3 c. 2 d. 6 e. nothing - empty file - no data 169. 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-L] c. [CTRL-C] d. [CTRL-U] e. [CTRL-D] 170. 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. 1 1 c. 6 d. 4 4 e. 8 171. What is the output on your screen of this shell command line in an empty directory? ls * a. * b. . c. . .. d. no output on screen e. an error message from ls saying * does not exist 172. 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. 7 b. 8 c. 5 d. 9 e. 6 173. What is the output on your screen of this shell command line in an empty directory? echo * a. an error message from echo saying * does not exist b. . .. c. no output on screen d. . e. * 174. 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 175. Which command pipeline outputs the count of the number of pathnames that lie under the current directory and recursively under all its subdirectories? a. ls / | wc b. ls . | wc c. dir / | wc d. file . | wc e. find . | wc 176. Given an existing file of yours named /a/x, what is the output on your screen of this sequence of three shell commands: echo hi >/a/x ; sort /a/x >/a/x ; wc /a/x a. 1 1 3 /a/x b. 2 2 4 /a/x c. 1 1 2 /a/x d. 0 0 0 /a/x e. no output on screen 177. If my current directory is /bin, which of these pathnames is equivalent to the file name /bin/ls? a. /root/bin/ls b. ./bin/ls c. ls/. d. ../bin/ls/. e. ../../bin/ls Answer Key - NET2003 - Ian Allen - Winter 2007 - NET2003 Practice Test 1. d 57. a 2. c 58. a 3. c 59. a 4. d 60. c 5. b 61. b 6. d 62. a 7. a 63. c 8. b 64. c 9. c 65. b 10. a 66. a 11. e 67. a 12. a 68. a 13. c 69. e 14. e 70. c 15. d 71. b 16. c 72. d 17. c 73. a 18. c 74. d 19. b 75. d 20. c 76. d 21. d 77. a 22. a 78. a 23. a 79. c 24. a 80. c 25. e 81. d 26. d 82. a 27. d 83. c 28. b 84. c 29. d 85. b 30. a 86. c 31. e 87. b 32. a 88. e 33. b 89. d 34. d 90. b 35. d 91. e 36. c 92. c 37. a 93. d 38. a 94. d 39. e 95. e 40. e 96. b 41. c 97. b 42. b 98. a 43. e 99. d 44. c 100. c 45. b 101. a 46. a 102. d 47. d 103. b 48. c 104. b 49. d 105. a 50. e 106. c 51. e 107. a 52. a 108. c 53. e 109. d 54. b 110. e 55. b 111. d 56. d 112. c 113. a 173. e 114. c 174. d 115. a 175. e 116. c 176. d 117. b 177. e 118. b 119. e Count of a: 43 24% 120. d Count of b: 29 16% 121. b Count of c: 40 23% 122. e Count of d: 33 19% 123. a Count of e: 32 18% 124. c 125. c With 5 choices: 177 126. a 127. a Macro .cmd split with indent: 69 128. a 129. c 130. a 131. e 132. e 133. c 134. a 135. a 136. a 137. e 138. c 139. a 140. e 141. e 142. c 143. e 144. c 145. b 146. d 147. a 148. b 149. b 150. e 151. e 152. b 153. e 154. d 155. d 156. c 157. a 158. d 159. c 160. d 161. e 162. b 163. c 164. a 165. b 166. a 167. c 168. b 169. c 170. e 171. e 172. a