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 - 145 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: 113 43 89 95 33 124 77 116 72 106 22 52 69 122 62 91 87 58 127 18 143 107 45 59 38 86 125 79 81 2 130 128 9 101 30 6 70 102 12 7 64 51 71 114 104 115 82 40 88 100 75 111 31 24 134 120 27 49 42 4 19 65 53 139 98 119 36 80 3 123 8 41 20 78 84 138 96 121 67 35 92 48 74 23 144 46 126 90 15 50 10 29 56 63 109 142 85 103 137 21 25 117 112 129 39 28 61 13 97 60 54 26 93 140 108 17 99 73 14 110 118 66 47 132 32 76 135 11 5 141 16 131 83 34 105 94 44 136 57 68 37 55 145 133 1) 1. What is in file out after running this bash shell command line? echo 2 3 >out 3 0 a. 2 3 0 b. 2 3 c. 2 3 >out 3 0 d. no output (empty file) e. 2 3 3 0 2. What appears on your screen after this bash shell command line? mkdir foo ; rmdir foo | wc -c a. no output b. 4 c. 1 d. 3 e. 0 3. In an empty directory, how many words are in file cow after this bash shell command line? touch dog dog cat ; ls >cow a. no output (empty file) b. 4 c. 2 d. 1 e. 3 4. What is the output of this sequence of three shell commands: echo hi >hi ; head hi >hi ; wc hi a. no output b. 2 2 4 hi c. 1 1 2 hi d. 0 0 0 hi e. 1 1 3 hi 5. What is the output of this bash shell command line in an empty directory? echo '$SHELL' a. '/bin/bash' b. no output c. '$SHELL' d. $SHELL e. /bin/bash 6. Which of these command sequences will make file3 contain all of the content of file1 followed by all of the content of file2? a. cp file1 file2 >file3 b. cp file1 >file3 file2 >file3 c. mv file1 file2 >file3 d. echo file1 file2 >file3 e. cat file1 file2 >file3 7. 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. 4 c. none d. 3 e. 1 8. What text is output by this bash shell command sequence: echo cow >foo ; echo dog | head -1 foo a. cow followed by dog b. dog followed by cow c. dog d. foo e. cow 9. What is in the file bar after this command sequence: echo hi >x ; echo ho >x ; mv x y >bar a. nothing - empty file - no data b. no such file (nonexistent) c. hi d. hi followed by ho e. ho 10. What is the output of this successful command sequence? cd /home/dir ; mkdir one ; mkdir two ; pwd a. /two b. /home/dir/two c. /home/dir/one d. /home/dir/one/two e. /home/dir 11. How many arguments does the shell pass to this echo command: echo " 1 2 "three ' 4 ' five"6" a. Five arguments. b. Three arguments. c. Nine arguments. d. Four arguments. e. One argument. 12. 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/? 13. How many lines are in the file out after this command sequence: echo hi >x ; echo ho >>x ; cat x x x >out a. nothing - empty file - no data b. 2 c. 1 d. 3 e. 6 14. 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 15. 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. no output (empty file) c. 3 d. 1 e. 2 16. In an empty directory, how many words are in file out after this bash shell command line? touch a ; ls >out a. 1 b. no output (empty file) c. 2 d. 3 e. 4 17. 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 in2 >out d. echo in1 in2 >out e. cp in1 >out in2 >out 18. 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 19. How many arguments does the shell pass to this echo command: echo "cow "y " bat 'man x' " pig'a "hop' a b a. Five arguments. b. Four arguments. c. Eleven arguments. d. Seven arguments. e. Six arguments. 20. 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-U] c. [CTRL-C] d. [CTRL-R] e. [CTRL-L] 21. What command can you use to remove a directory that isn't empty? a. deldir -r dir b. rmdir -r dir c. del -r dir d. mv -r dir e. rm -r dir 22. What is the output of this successful command sequence? cd /tmp ; mkdir foo ; mkdir bar ; pwd a. /tmp/foo b. /tmp/foo/bar c. /bar d. /tmp/bar e. /tmp 23. In an empty directory, what appears on your screen after this bash command line? touch a ; ls >wc -l a. no output b. 2 c. 0 d. 3 e. 1 24. 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? 25. What appears on your screen after this bash shell command line? echo hi >a ; ls a > wc a. no output b. 1 1 2 c. 2 d. 3 e. 1 1 3 26. 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/??? b. no output c. /a/b/.aa /a/b/.ab d. /a/b/.aa /a/b/.ab /a/b/.a? /a/b/.a* e. /a/b/.a? 27. 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. foo c. nothing - empty file - no data d. bar e. foo followed by bar 28. 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/a* b. rm /a/* c. rm /a* d. rm /a/a\* e. rm /a/a? 29. Which command sequence below outputs only lines 11-15 of the 99-line file named cat? a. head -15 cat | tail -5 cat b. head -10 cat | tail -15 cat c. head -15 cat | tail -5 d. tail -15 cat | head -10 e. tail -10 cat | head -15 cat 30. Which command sequence outputs inode/filename pairs for names in the current directory, sorted by inode number? a. ls -node * > sort -n b. ls ./* | sort -node c. sort -n | ls -ai d. ls -ai | sort -n e. ls -i * > sort -n 31. In the output of the command ls -ai, the one-character name . signifies what? a. A name that is hidden. b. The current directory. c. A current file. d. A name with an unprintable character. e. The parent directory. 32. 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 33. Which of the command lines below can generate a non-empty file? a. tail /a/b >/a/b b. sort /a/b >/a/b c. wc -l /a/b >/a/b d. cat /a/b /a/b /a/b >/a/b e. head -5 /a/b >/a/b 34. 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. 160 b. no lines (empty file) c. 80 d. 30 e. 50 35. What is the output of this shell command line in an empty directory? echo * a. no output b. * c. . d. . .. e. .. 36. 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/.. 37. 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. 4 e. nothing - empty file - no data 38. If my current directory is /etc, which of these pathnames is equivalent to the file name /etc/passwd? a. ../etc/passwd/. b. /passwd c. ./etc/passwd d. ../passwd e. ./passwd 39. Which command line below does not show any lines from inside the file dog? a. ls dog b. tail dog c. less dog d. head dog e. more dog 40. If /bin/bash is a file name, which of the following pathnames always leads to the same file? a. /bin/../bin/bash b. /bin/bash/. c. /bin/../bash d. /bin/bin/../bash e. ./bin/bash 41. Which command line lists all possible utilities available for editing files? a. man edit b. which edit c. finger edit d. whereis edit e. man -k edit 42. How many command arguments does the shell pass to this echo command: echo 'It's a bird! It's a plane!' a. Two arguments. b. One argument. c. Three arguments. d. Four arguments. e. Five arguments. 43. What is in the file out after this command sequence: echo hi >x ; echo ho >>x ; cp x y >out a. ho b. hi c. hi followed by ho d. no such file (nonexistent) e. nothing - empty file - no data 44. What is in file cow after running this bash shell command line? echo one two >cow three a. echo one two b. one two three c. one two cow three d. one two e. no output (empty file) 45. If my current directory is /home, which of these pathnames is equivalent to the pathname /home/a/b/c? a. /a/b/c b. ../a/b/c c. ../home/b/c d. ./home/a/b/c e. ./a/b/c 46. What text is output by this bash shell command sequence: echo dog >out ; echo cat | sort out a. dog b. cat c. dog followed by cat d. out e. cat followed by dog 47. Which command sequence below outputs only lines 10-15 of the 16-line file named hex? a. head -10 hex | tail -15 hex b. tail -16 hex | head -10 c. head -15 hex | tail -6 d. head -16 hex | tail -5 hex e. tail -10 hex | head -16 hex 48. What appears on your screen after this bash shell command line? echo hi | wc -c a. 3 b. 1 c. 2 d. no output e. 0 49. 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. echo a b >foo b. cat a >foo ; cat b >>foo c. cp a >foo ; cp b >>foo d. mv a b >foo e. cp a b >foo 50. 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. 50 b. no lines (empty file) c. 40 d. 45 e. 60 51. How many arguments and options are there to the command: wc -wc /sort a. Two arguments, one of which is a single option and the other is a pathname. b. Two command line arguments, one of which contains two bundled options. c. Two arguments, no options. d. A three-letter file name and a /sort switch option argument. e. Two options, no arguments. 52. 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. 20 b. 60 c. 10 d. no lines (no output) e. 30 53. What is the output of this shell command line in an empty directory? echo * a. . .. b. an error message from echo saying * does not exist c. . d. no output e. * 54. 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. Four arguments. c. Three arguments. d. Five arguments. e. Six arguments. 55. What is true about this bash shell command line? date >ls ; ls -ls ls >wc a. The file wc has one line in it. b. The wc command counts the output of the ls command. c. The ls command receives the output of date on standard input. d. The ls command is executed more than once. e. The shell finds and executes three different commands. 56. 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 contains two files c. the directory mt is still empty d. the command fails because the path ./mt/../cat does not exist e. the directory mt now has a file named dog in it 57. 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 size in bytes of this directory. b. The number 123 is the count of links (names) this directory has. c. The number 456 is the inode number of this directory. d. The number 456 is the size of this directory. e. The number 456 is the octal permissions of this directory. 58. 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. 98 b. 04 04 c. 96 96 d. 01 01 e. 96 59. What appears on your screen after this bash shell command line? echo xx >z ; ls z > wc a. 1 1 3 b. 1 1 2 c. 2 d. no output e. 3 60. How can you ask the bash (Linux) shell to complete commands or file names for you? a. Type [ALT]-[F2] the shell will present a menu of commands. b. Type [CONTROL]-[D] and the shell will present a menu of commands. c. You can type the first part of the command or file name and press the ALT key. 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 TAB key. 61. 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-U] b. [CTRL-D] c. [CTRL-R] d. [CTRL-L] e. [CTRL-C] 62. Which command line lists all possible utilities available for sorting files? a. man sort b. man | grep sort c. grep sort /etc/passwd d. grep /etc/passwd sort e. man -k sort 63. 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 64. Which one of the following commands will leave file1 non- empty? a. tail file1 > file1 b. cat file1 > file1 c. sort file1 > file1 d. head file1 > file1 e. wc file1 > file1 65. 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 directory sub/.. now has a file named cat in it c. there is a second copy of the file fil in the file named cat d. the directory sub now contains only a file named cat e. the command fails because the path ../myhome/cat does not exist 66. 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. there is a second copy of the file cat in the file named dog c. the directory empty now contains only a file named dog d. the command fails because the path empty/../cat does not exist e. the directory empty/.. now has a file named dog in it 67. What appears on your screen after this bash shell command line? echo hi >a ; echo a | wc -c a. no output b. 1 c. 2 d. 4 e. 3 68. 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? d. rm /a/a[*] e. rm /a/a? 69. Which command sequence outputs inode/filename pairs for names in the working directory, sorted by inode number? a. ls | sort -i b. echo * | sort -n c. ls -ia | sort -n d. ls -node | sort -n e. echo -i * > sort 70. 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. no lines (empty file) b. 20 c. 30 d. 50 e. 80 71. Which of the command lines below can generate a non-empty file? a. ls -i /a/b >/a/b b. sort -r /a/b >/a/b c. grep /a/b /a/b >/a/b d. tail -5 /a/b >/a/b e. cat /a/b >/a/b 72. What appears on your screen after this bash shell command line? echo hi >out ; wc -c out a. 4 out b. 5 out c. no output d. 2 out e. 3 out 73. 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-C] b. [CTRL-U] c. [CTRL-R] d. [CTRL-D] e. [CTRL-L] 74. 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. 3 b. 4 c. 1 d. 2 e. none 75. 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/??? c. foo/.x1 foo/.x2 foo/.z3 foo/.z. d. foo/.x1 foo/.x2 foo/.z3 e. foo/.z. 76. In the output of the command ls -a, a dot that begins a name signifies what? a. The current directory. b. A name that is hidden. c. A current file. d. The parent directory. e. A name with an unprintable character. 77. What is the output of this sequence of three shell commands: echo hi >wc ; ls wc >wc ; wc wc a. 1 1 2 wc b. 2 2 4 wc c. 1 1 3 wc d. no output e. 0 0 0 wc 78. What command shows all the lines in file /etc/group that contain the string idallen? a. cat /etc/group | wc idallen b. cat /etc/group > grep idallen c. grep idallen >/etc/group d. grep /etc/group idallen e. grep idallen /etc/group 79. Which of these statements is true? a. To erase an entire line of typing, type [CONTROL]-[E]. 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 indicate End-of-File (no more input), type [CONTROL]-[E]. e. You can only login to Unix once per userid; you cannot be logged in to the same machine twice. 80. What appears on your screen after this bash shell command line? echo hi >a ; ls a | wc -c a. no output b. 1 c. 2 d. 3 e. 4 81. Given an existing file of yours named /a/x, what is the output 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 82. 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 of this command: sort nine nine nine | tail -3 | head -1 a. 7 b. 1 1 1 c. 7 7 7 d. 9 e. 8 83. 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. A three-letter file name and a /cat switch option argument. 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. 84. How many arguments does the shell pass to this echo command: echo " 1 2 " three ' 4 ' five"6" a. One argument. b. Three arguments. c. Four arguments. d. Five arguments. e. Nine arguments. 85. 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]-[BACKSPACE] c. Use the "PageUp" key. d. Use the "UpArrow" key. e. Type [CONTROL]-[ALT]-[DEL] 86. In an empty directory, what appears on your screen after this bash command line? touch a ; ls | wc -l a. no output b. 0 c. 1 d. 2 e. 3 87. How many arguments does the shell pass to this echo command: echo 'And it's not hard, it's just logical.' a. Seven arguments. b. Three arguments. c. Six arguments. d. Four arguments. e. Five arguments. 88. 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. no output (empty file) b. 6 c. 5 d. 4 e. 3 89. 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-L] b. [CTRL-R] c. [CTRL-U] d. [CTRL-D] e. [CTRL-C] 90. How many command arguments does the shell pass to this echo command: echo 'It's a bird! No! It's a plane!' a. Three arguments. b. Four arguments. c. Two arguments. d. Five arguments. e. One argument. 91. Which of the command lines below can generate a non-empty file? a. sort -r file >file b. cat file file file >file c. tail -3 file >file d. head -5 file >file e. wc -wc file >file 92. 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 inode number of this directory. b. The number 512 is the size of this directory. c. The number 712 is the count of links (names) this directory has. d. The number 512 is the count of links (names) this directory has. e. The number 712 is the inode number of this directory. 93. 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?"" 94. How many lines are in file out after this bash shell command line? echo hi >dog >out >cat a. 1 b. no such file (file does not exist) c. no output (empty file) d. 2 e. 3 95. 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] 96. What would you see if you typed this command: cat /users a. The contents of the file users located in your home directory b. The contents of your directory named users c. The contents of the file users located in the parent directory d. The contents of your subdirectory named users e. The contents of the file users located in the root directory 97. 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. no output b. foo/.11 foo/.12 foo/... c. foo/.11 foo/.12 d. foo/??? e. foo/... 98. 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. ../../bin/ls d. ../bin/ls/. e. ls/. 99. Which Unix command sequence deletes a directory and everything inside it? a. deltree -all dir b. rmdir -all dir c. rm -all dir d. rm -r dir e. rmdir -r dir 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-R] b. [CTRL-C] c. [CTRL-D] d. [CTRL-U] e. [CTRL-L] 101. How many arguments does the shell pass to this echo command: echo ' one two ' three ' four ' 5'6' a. Six arguments. b. Five arguments. c. Nine arguments. d. Four arguments. e. One argument. 102. If foo is a sub-directory that contains only the file single, what happens after this command: mv ./foo/single foo/../double a. the directory foo now contains only a file named double b. the command fails because the name double does not exist c. the directory foo is now empty d. the command fails because the name foo/../double does not exist e. there is a second copy of the file single in the file named double 103. What is in file out after running this bash shell command line? echo a >out b c a. a b. a b c c. no output d. b c e. echo a 104. 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 "*" 105. What appears on your screen after this bash shell command line? echo hi >out | wc -c a. 3 b. 1 c. 2 d. 0 e. no output 106. 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 456 is the count of links (names) this directory has. 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 123 is the size of this directory. e. The number 456 is the size of this directory. 107. 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 108. Which command line below does not show any lines from inside the file dog? a. sort -r dog b. ls dog c. tail -8 dog d. head -3 dog e. less dog 109. 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/./fil does not exist b. the directory x now contains only a file named y c. the directory x is still empty d. there is a second copy of the file fil in the file named y e. the command fails because the path x/../../me does not exist 110. 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 111. 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\* 112. 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 512 is the size of this directory. c. The number 256 is the size of this directory. d. The number 512 is the count of links (names) this directory has. e. The number 256 is the inode number of this directory. 113. 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. 0 0 0 /a/b/x b. 1 1 2 /a/b/x c. 1 1 3 /a/b/x d. no output e. 1 1 1 /a/b/x 114. Which of the following pathnames always leads to the same file named: /etc/passwd? a. ./etc/passwd b. /etc/./etc/../passwd c. ../etc/passwd d. /etc/passwd/. e. /etc/../etc/passwd 115. Which of the following shell command lines displays only the names in the current directory that are exactly three alphabetic letters long? a. echo [0-3][0-3][0-3] b. echo [?][?][?] c. echo [a-zA-Z][a-zA-Z][a-zA-Z] d. echo *** e. echo ??? 116. 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-L] b. [CTRL-R] c. [CTRL-C] d. [CTRL-U] e. [CTRL-D] 117. 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 118. 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. A three-letter file name and an /etc switch option. c. Two command line arguments, one of which contains two bundled options. d. Two options, no arguments. e. Two arguments, no options. 119. Which command line below does not show any lines from inside the file out? a. wc out b. more out c. sort -n out d. tail out e. head -99 out 120. 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. 30 b. 50 c. 21 d. 20 e. no lines (no output) 121. 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. the directory cow now contains only a file named cat 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 122. Which command line lists all possible utilities available for compiling programs? a. grep /etc/* compile b. man * | grep compile c. apropos compile d. grep compile /etc/* e. man compile 123. 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 of this command: sort nine nine | tail -4 | head -1 a. 6 b. 1 1 c. 4 4 d. 8 e. 6 6 124. If your PATH variable contains /bin:/usr/bin, what is the output of this bash shell command line? echo '$PATH' a. $PATH b. /bin:/usr/bin c. '$PATH' d. /bin e. '/bin' 125. What is the output of this shell command line in an empty directory? ls * a. * b. . c. an error message from ls saying * does not exist d. no output e. . .. 126. How many arguments and options are there to the command: ls -li foobar a. Two arguments, no options. b. One argument, no options. c. Two options, no arguments. d. Two arguments, one of which is a single option and the other is a pathname. e. Two command line arguments, one of which contains two bundled options. 127. Which of the following statements is true about this shell command line: >/a/b/c cat /a/b/d a. The command /a/b/c sees only one argument b. The command is always invalid. c. The command cat sees only one argument. d. The command cat sees two arguments. e. The command /a/b/c sees two arguments. 128. Which of the command lines below can generate a non-empty file? a. touch file >file b. ls -ls file >file c. head -1 file >file d. grep pattern file >file e. sort -r file file >file 129. 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 ALT key. b. Type [CONTROL]-[C] and the shell will present a menu of commands. c. You can type the first part of the command or file name and press the TAB key. d. Push key F1 and the system will present a menu of commands. e. Type [CONTROL]-[D] and the shell will present a menu of commands. 130. Which command line displays the contents of the Unix passwd file one page at a time? a. /etc/passwd >more b. more /etc/passwd c. /etc/passwd | more d. cat /etc/passwd >more e. more | /etc/passwd 131. 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-C] c. [CTRL-R] d. [CTRL-U] e. [CTRL-D] 132. If your terminal type is xterm, what is the output of this bash shell command line? echo '$TERM' a. '$TERM' b. no output c. 'xterm' d. xterm e. $TERM 133. Which command sequence below outputs only lines 10-15 of the Unix password file? a. head -15 /etc/passwd | tail -6 b. tail -15 /etc/passwd | head -10 c. tail -10 /etc/passwd | head -15 /etc/passwd d. head -10 /etc/passwd | tail -15 /etc/passwd e. head -15 /etc/passwd | tail -5 /etc/passwd 134. What appears on your screen after this bash shell command line? echo hi >a ; cat a | wc -c a. 3 b. 4 c. 1 d. 2 e. no output 135. What is the output of this successful command sequence? cd /home/foo ; touch dir ; mkdir bar ; pwd a. /home/foo/dir b. /home/foo/bar c. /bar d. /home/foo e. /home/foo/dir/bar 136. 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. 1 1 3 wc b. no output c. 0 0 0 wc d. 1 1 2 wc e. 2 2 4 wc 137. What appears on your screen after this bash shell command line? echo hi >ls ; cat ls > wc a. ls b. 1 1 2 c. hi d. 1 1 3 e. no output 138. 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. 4 c. 1 d. 8 e. no output 139. 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 140. 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 telnet to ACADUNIX from outside the College, use the name acadunix.algonquin. d. To erase an entire line of typing, type [ALT]-[DELETE]. e. To interrupt a Unix process from the keyboard, type [CONTROL]-[D]. 141. What appears on your screen after this bash shell command line? echo hi >a ; cp a b | wc -c a. 2 b. 0 c. 1 d. 3 e. no output 142. 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" 143. 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 parent directory. d. The current directory. e. A file or directory with double links. 144. What is the output of this command sequence: echo foo >file ; echo bar | sort file a. bar followed by foo b. foo followed by bar c. foo d. bar e. an error message 145. Which command sequence outputs inode/filename pairs for names in the current directory, sorted by inode number? a. ls -node * > sort -n b. ls -ia | sort -n c. ls ./* | sort -node d. ls -i * > sort e. sort ls -ia Answer Key - DAT2330 - Ian Allen - Fall 2004 - DAT2330 Practice Test - 0% Office use only: 113 43 89 95 33 124 77 116 72 106 22 52 69 122 62 91 87 58 127 18 143 107 45 59 38 86 125 79 81 2 130 128 9 101 30 6 70 102 12 7 64 51 71 114 104 115 82 40 88 100 75 111 31 24 134 120 27 49 42 4 19 65 53 139 98 119 36 80 3 123 8 41 20 78 84 138 96 121 67 35 92 48 74 23 144 46 126 90 15 50 10 29 56 63 109 142 85 103 137 21 25 117 112 129 39 28 61 13 97 60 54 26 93 140 108 17 99 73 14 110 118 66 47 132 32 76 135 11 5 141 16 131 83 34 105 94 44 136 57 68 37 55 145 133 1 1. e 45. e 2. e 46. a 3. e 47. c 4. d 48. a 5. d 49. b 6. e 50. c 7. a 51. b 8. e 52. c 9. a 53. e 10. e 54. c 11. b 55. a 12. c 56. c 13. e 57. a 14. a 58. a 15. d 59. d 16. c 60. e 17. b 61. e 18. b 62. e 19. a 63. a 20. a 64. e 21. e 65. b 22. e 66. e 23. a 67. c 24. c 68. b 25. a 69. c 26. a 70. d 27. c 71. a 28. d 72. e 29. c 73. a 30. d 74. a 31. b 75. b 32. a 76. b 33. c 77. c 34. c 78. e 35. b 79. c 36. b 80. c 37. d 81. d 38. e 82. d 39. a 83. a 40. a 84. c 41. e 85. d 42. d 86. c 43. e 87. d 44. b 88. d 89. d 145. b 90. d 91. e Count of a: 27 19% 92. d Count of b: 25 17% 93. c Count of c: 34 23% 94. c Count of d: 28 19% 95. b Count of e: 31 21% 96. e 97. d With 5 choices: 145 98. c 1 2 3 4 5 6 7 8 9 10 11 12 13 99. d 14 15 16 17 18 19 20 21 22 23 100. b 24 25 26 27 28 29 30 31 32 33 101. d 34 35 36 37 38 39 40 41 42 43 102. c 44 45 46 47 48 49 50 51 52 53 103. b 54 55 56 57 58 59 60 61 62 63 104. c 64 65 66 67 68 69 70 71 72 73 105. d 74 75 76 77 78 79 80 81 82 83 106. e 84 85 86 87 88 89 90 91 92 93 107. b 94 95 96 97 98 99 100 101 102 108. b 103 104 105 106 107 108 109 109. c 110 111 112 113 114 115 116 110. d 117 118 119 120 121 122 123 111. e 124 125 126 127 128 129 130 112. b 131 132 133 134 135 136 137 113. a 138 139 140 141 142 143 144 114. e 145 115. c 116. e Macro .cmd splits: 43 117. d Macro .ans splits: 0 118. c 119. a 120. d 121. b 122. c 123. d 124. a 125. c 126. e 127. c 128. b 129. c 130. b 131. e 132. e 133. a 134. a 135. d 136. b 137. e 138. d 139. c 140. a 141. b 142. d 143. c 144. c