Practice Test DAT2330 - Ian Allen - Winter 20-1- PRACTICE Evaluation: 158 Questions Name: _________________________ 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 - 158 Questions This is a practice test containing many practice questions. The real test will contain many questions similar to these. Knowing the concepts behind the questions is necessary; memorizing these answers won't help. The real test will have approximately one question per minute. The real test may have some questions unlike anything given here. (Office use only: 123 138 51 6 146 125 115 122 103 17 107 108 68 72 150 22 16 87 129 96 105 48 65 116 104 1 132 13 84 55 43 25 24 9 109 121 92 61 158 14 40 80 64 128 89 157 5 88 102 31 34 75 82 66 147 20 93 126 77 54 37 137 127 136 139 99 74 81 114 19 50 35 63 153 15 7 49 119 32 142 12 117 149 4 90 10 140 97 130 106 73 52 143 135 70 113 111 141 33 100 59 91 112 154 151 156 44 71 56 46 45 67 152 79 41 134 62 58 42 86 29 11 124 148 8 120 53 60 144 76 36 28 57 95 21 131 69 38 133 26 83 3 94 118 18 78 145 2 23 155 110 85 39 101 27 98 30 47) 1. Given the following bash shell command line: read hi my ok which user keyboard input line below will assign the text two to the shell variable named my? a. one,two,three b. hi=one my=two ok=three c. "one" "two" "three" d. 3 ] ; then echo OK ; fi c. if [ 4 -gr 3 ] ; then echo OK ; fi d. if [ ! 4 <= 3 ] ; then echo OK ; fi e. if [ 4 -gt 3 ] ; then echo OK ; fi 5. Which of the following bash PATH statements makes the most sense? a. PATH=/bin:/usr/bin:/etc/passwd b. PATH=/bin/ls:/etc:/usr/bin c. PATH=/bin:/usr/bin:/etc d. PATH=/bin/sh:/usr/bin:/etc:/bin e. PATH=/bin:/bin/cat:/usr/bin 6. Which bash command sequence below always outputs just the date only if the first argument is either a file or a directory? a. if [ "$1" -eq -f -o "$1" -eq -d ]; then date ; fi b. if [ -f -o -d "$1" ]; then date ; fi c. if [ -f || -d "$1" ]; then date ; fi d. if [ "-f $1" || "-d $1" ]; then date ; fi e. if [ -f "$1" -o -d "$1" ]; then date ; fi 7. If foo is a script containing the line TERM=linux ; export TERM, what is the output of the following sequence of bash commands: TERM=vt100 ; ./foo ; echo "$TERM" a. linux b. vt100 c. $TERM d. foo e. TERM 8. Given the following bash shell command line: read xx yy zz which user keyboard input line below will assign the text 22 to the shell variable named yy? a. 11 22 33 b. xx=11 yy=22 zz=33 c. 11,22,33 d. 11;22;33 e. 11:22:33 9. What is the bash shell output of this two command sequence: PATH=/bin/ls:/bin/head:/bin/sh ; head nosuchfile a. bash: /bin/ls: command not found b. bash: head: command not found c. head: nosuchfile: No such file or directory d. bash: /bin/sh: No such file or directory e. ls: /bin/head: command not found 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-3- PRACTICE 10. 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 -5 c. head -10 /etc/passwd | tail -5 /etc/passwd d. tail -10 /etc/passwd | head -15 /etc/passwd e. head -15 /etc/passwd | tail -5 /etc/passwd 11. If a bash shell script named foo contains the line: if [ "$1" = '$2' ] ; then echo SAME ; fi then which of the following command lines will produce SAME as output? a. ./foo $2 $2 b. ./foo bar bar c. ./foo "$1" '$2' d. ./foo "bar" 'bar' e. ./foo '$2' bar 12. What is the link count of directory dir after this set of successful commands? mkdir dir ; cd dir ; touch one ; mkdir two a. 3 b. 4 c. 2 d. 5 e. 1 13. What is the output of the following sequence of bash commands: a=cow ; touch $a ; test -z $a ; echo $? a. the number 1 or 0 followed by another 1 or 0 on a new line b. 0 c. test: $a: integer expression expected d. no output e. 1 14. What is the output of the following sequence of bash commands: a=1 ; b=2 ; test $a -ge $b ; echo $? a. no output b. 0 c. the number 1 or 0 followed by another 1 or 0 on a new line d. test: $a: integer expression expected e. 1 15. Which line below is most likely to be the beginning of an error message? a. echo 2>&1 "... " b. echo 1<&2 "... " c. echo 2>$1 "... " d. echo 1>&2 "... " e. echo 2<$1 "... " 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-4- PRACTICE 16. If variable foo might contain nothing (a null value - defined but empty), which bash command sequence correctly tests for this and prints OK? a. if [ "$foo" = * ] ; then echo OK ; fi b. if [ $foo -eq "" ] ; then echo OK ; fi c. if [ ''$foo'' = '''' ] ; then echo OK ; fi d. if [ "$foo" = "" ] ; then echo OK ; fi e. if [ $foo -eq : ] ; then echo OK ; fi 17. Which command sequence below outputs only lines 11-15 of the Unix password file? a. head -10 /etc/passwd | tail -15 /etc/passwd b. head -15 /etc/passwd | tail -5 /etc/passwd c. tail -15 /etc/passwd | head -10 d. head -15 /etc/passwd | tail -5 e. tail -10 /etc/passwd | head -15 /etc/passwd 18. What is the output of the following sequence of bash commands: cd /etc && echo "in $(pwd)" a. in 0pwd) b. in /etc c. no output d. in $(pwd) e. bash: cd: /etc: No such file or directory 19. What is the output of the following sequence of bash commands: false && echo "linux rocks $?" a. linux rocks 0 b. no output c. linux rocks 0 d. linux rocks 1 e. linux rocks 1 20. If the file foo contained the word mom, what would be the bash shell output of this two command sequence: PATH=/etc/passwd:/bin/ls:/bin/cat ; /bin/ls foo a. no output b. mom c. foo d. /bin/ls: foo: No such file or directory e. bash: /bin/ls: command not found 21. If /bin/pig is a program that outputs hi and /usr/bin/pig is a program that outputs foo what is the output of this shell command sequence: PATH=/etc:/usr/bin:/bin ; pig a. bash: pig: command not found b. hi c. foo followed by hi d. foo e. hi followed by mom 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-5- PRACTICE 22. Which of the following shell command lines displays all the names in the current directory that are exactly three letters (alphabetic) long (and nothing else)? a. echo [azAZ][azAZ][azAZ] b. echo [0-89][01-9][0-45-9] c. echo [a-mn-zA-YZ][ab-zAB-YZ][za-yZA-Y] d. echo [a,zA,Z][a,zA,Z][a,zA,Z] e. echo ??? 23. Given my directory dir and my file dir/bar owned by me, which permissions allow me to delete the file dir/bar from the directory, but not change the content (data) in the file? a. Permissions 100 on directory dir and 100 on file dir/bar. b. Permissions 300 on directory dir and 300 on file dir/bar. c. Permissions 100 on directory dir and 200 on file dir/bar. d. Permissions 500 on directory dir and 400 on file dir/bar. e. Permissions 300 on directory dir and 500 on file dir/bar. 24. If foo is a script containing the line TERM=vt100 ; export TERM, what is the output of the following sequence of bash commands: TERM=linux ; ./foo ; echo $TERM a. foo b. $TERM c. vt100 d. TERM e. linux 25. If /bin/foo is a program that outputs hi and /usr/bin/foo is a program that outputs mom what is the output of this shell command sequence: PATH=/etc:/usr/bin:/bin ; foo a. mom followed by hi b. hi followed by mom c. mom d. bash: foo: command not found e. hi 26. Which bash command sequence correctly searches for the chars and then prints OK if it is found inside the password file? a. if test chars /etc/passwd ; then echo OK ; fi b. if [ test chars /etc/passwd ] ; then echo OK ; fi c. if [ grep chars /etc/passwd ] ; then echo OK ; fi d. if grep chars /etc/passwd ; then echo OK ; fi e. if test chars = /etc/passwd ; then echo OK ; fi 27. What is the bash output of this command sequence: false && echo "Hello There" a. "Hello There" b. HelloThere c. Hello There d. no output e. Hello There 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-6- PRACTICE 28. 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 of this command: cat foo foo | cat | tail -5 | head -1 a. 8 b. 5 c. 6 d. 9 e. 7 29. What is the bash shell output of this two-command sequence if run in a directory containing 765 files with names that are all the numbers from 1 to 765 inclusive: foo="*" ; echo $foo a. * b. an asterisk ('*') and the file names 1 through 765 c. all the file names that start with an asterisk ('*') d. the file names 1 through 765 e. $foo 30. Which of these statements is true? a. Only single 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. The cat food command looks up the file name argument food in your $PATH. d. If /x is an empty directory, sort /x/* produces an error message. e. Typing ./script and bash script always give identical results. 31. If x=8 and y=9 then which of the following bash command lines outputs only the word foobar (and nothing else)? a. [x -ne y] || echo foobar b. [ x -ne y ] && echo foobar c. [!x = y] && echo foobar d. [x!=x] || echo foobar e. [ x = x ] && echo foobar 32. If variable bar might contain nothing (a null value - defined but empty), which bash command sequence correctly tests for this and prints YO? a. if [ $bar -eq "" ] ; then echo YO ; fi b. if [ $bar -eq : ] ; then echo YO ; fi c. if [ "$bar" = "" ] ; then echo YO ; fi d. if [ ''$bar'' = '''' ] ; then echo YO ; fi e. if [ "$bar" = * ] ; then echo YO ; fi 33. If variable mt might contain nothing (a null value - defined but empty), which bash command sequence correctly tests for this and prints OK? a. if [ $mt -eq : ] ; then echo OK ; fi b. if [ ''$mt'' = '''' ] ; then echo OK ; fi c. if [ "$mt" = "" ] ; then echo OK ; fi d. if [ "$mt" = * ] ; then echo OK ; fi e. if [ $mt -eq "" ] ; then echo OK ; fi 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-7- PRACTICE 34. If cow=5 and dog=5, which bash command sequence correctly compares the two numbers as equal and prints OK? a. if test cow -eq dog ; then echo OK ; fi b. if [ $cow==$dog ] ; then echo OK ; fi c. if [ cow = dog ] ; then echo OK ; fi d. if ( cow == dog ) ; then echo OK ; fi e. if test $cow -eq $dog ; then echo OK ; fi 35. 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. 3 b. 2 c. 1 d. 4 e. 5 36. If happy were a file of text containing 50 different lines, what would be the output of this exact command line: diff happy happy a. no output b. an error message because diff only allows one file name c. several lines, which are the lines that are different between the two files d. the contents of file happy would be displayed e. an error message because diff doesn't allow the same file name twice 37. How many arguments and options are there to the command: wc -l 3 ) ; then echo OK ; fi e. if [ 4 > 3 ] ; then echo OK ; fi 48. What is the output of the following sequence of bash commands: cd /bin && echo "cd $(pwd)" a. bash: cd: /bin: No such file or directory b. cd 0pwd) c. no output d. cd /bin e. cd $(pwd) 49. What is the bash shell output of this two command sequence: PATH=/bin/ls:/bin/cat:/bin/sh ; cat nosuchfile a. cat: nosuchfile: No such file or directory b. bash: cat: command not found c. ls: /bin/cat: command not found d. bash: /bin/ls: command not found e. bash: /bin/sh: No such file or directory 50. If x=cow and y=dog then what is the output of the following sequence of bash commands: [ $x = cow -a $y = cow ] ; echo $? a. test: $x: integer expression expected b. 1 c. the number 0 or 1 followed by another 0 or 1 on a new line d. 0 e. no output 51. If a=cow and b=dog then what is the output of the following sequence of bash commands linked by &&: [ $a = dog -o $b = dog ] && echo $? a. no output b. test: $a: integer expression expected c. the number 1 or 0 followed by another 1 or 0 on a new line d. 1 e. 0 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-10- PRACTICE 52. Given my directory dir and my file dir/foo owned by me, which permissions allow me to change or create new content (data) in the file dir/foo but not delete the file? a. Permissions 200 on directory dir and 200 on file dir/foo. b. Permissions 400 on directory dir and 400 on file dir/foo. c. Permissions 500 on directory dir and 600 on file dir/foo. d. Permissions 600 on directory dir and 700 on file dir/foo. e. Permissions 100 on directory dir and 100 on file dir/foo. 53. What is the bash shell output of this two-command sequence if run in a directory containing 123 files with names that are all the numbers from 1 to 123 inclusive: glob="*" ; echo "$glob" a. the file names 1 through 123, surrounded by quotes b. the file names 1 through 123 c. * d. "$glob" e. $glob 54. What is the output of the following sequence of bash commands: a=cow ; b=dog ; touch $a ; test -z $a ; echo $? a. 0 b. no output c. the number 1 or 0 followed by another 1 or 0 on a new line d. test: $a: integer expression expected e. 1 55. Which of these commands makes a file owned by me, also executable by me? a. umask 777 myfile b. chmod x+u myfile c. chmod u+x ./myfile d. chmod x=u ./myfile e. umask 111 myfile 56. 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. xx xy xz y* b. *x *y c. $a d. x* y* e. xx xy 57. How many arguments and options are there to the command: sort -r x ; echo b >>x ; mv x y >file a. a followed by b b. a c. no such file (nonexistent file) d. nothing - file is empty - no data e. b 60. What is the output of this command sequence: echo pig >one ; echo cow | head -2 one a. cow b. pig followed by cow c. cow followed by pig d. an error message e. pig 61. Which bash command line below allows programs in the current directory to execute without preceding the names with ./? a. $PATH=.:$HOME:/usr/bin b. PATH=/usr/bin:$HOME:. c. PATH=./$HOME:/usr/bin d. $PATH=/usr/bin:./$HOME e. PATH=/usr/bin/.:$HOME 62. Given this long listing: drwxr-xr-x 2048 bin bin 4096 Jan 2 14:22 /dir How many subdirectories lie immediately under /dir? a. 4094 b. 2046 c. 2048 d. there is not enough information shown to answer the question e. 4096 63. Which bash command sequence below always outputs just the date only if the first argument is either readable or executable? a. if [ "$1" -eq -r -o "$1" -eq -x ]; then date ; fi b. if [ -r || -x "$1" ]; then date ; fi c. if [ "-r $1" || "-x $1" ]; then date ; fi d. if [ -r -o -x "$1" ]; then date ; fi e. if [ -r "$1" -o -x "$1" ]; then date ; fi 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-12- PRACTICE 64. How many arguments are passed to the command by the shell on this command line: cow cow a. 2 b. 5 c. 6 d. 3 e. 4 65. What is the output of the following sequence of bash commands: wc='one two' ; test wc = wc a. 0 b. 1 2 8 wc c. 1 d. no output e. test: too many arguments 66. What is the output of this sequence of three shell commands: umask 457 ; mkdir newdir ; ls -ld newdir a. d-wx-w-rwx 2 me me 512 Oct 1 1:12 newdir b. dr-xr-xrwx 2 me me 512 Oct 1 1:12 newdir c. dr--r-xrwx 2 me me 512 Oct 1 1:12 newdir d. d-wx-w---- 2 me me 512 Oct 1 1:12 newdir e. d-w--w---- 2 me me 512 Oct 1 1:12 newdir 67. What is the output of the following sequence of bash commands: x=0 ; test $x ; echo $? a. the number 0 or 1 followed by another 0 or 1 on a new line b. 0 c. 1 d. no output e. test: $x: integer expression expected 68. What is the bash shell output of this two-command sequence if run in a directory containing 123 files with names that are all the numbers from 1 to 123 inclusive: bat="*" ; echo "$bat" a. "$bat" b. the file names 1 through 123 c. * d. $bat e. the file names 1 through 123, surrounded by quotes 69. If a=xxx and b=yyy then what is the output of the following sequence of bash commands: if $a = $b ; then echo $a ; fi a. bash: xxx: command not found b. xxx c. test: xxx: integer expression expected d. test: $a: integer expression expected e. no output 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-13- PRACTICE 70. In an empty directory, what is the shell output of these three commands: touch .1 .2 .3 11 12 ; a='.1* .2*' ; echo '$a' a. 11 .1 12 .2 b. $a c. '.1* .2*' d. .1* .2* e. .1 .2 71. Which of the following shell command lines displays the names in the current directory that are exactly three numeric digits long (and nothing else)? a. echo ??? b. echo [0-90-90-9] c. echo [1-3][1-3][1-3] d. echo [1-31-31-3] e. echo [0-9][0-9][0-9] 72. If a=cow and b=dog then what is the output of the following sequence of bash commands: if $a = $b ; then echo $a ; fi a. bash: cow: command not found b. no output c. test: cow: integer expression expected d. cow e. test: $a: integer expression expected 73. In an empty directory, what is the length of the longest file name created by the following bash shell two-command sequence: var='1 12 123 1234 12345' ; touch '$var' a. 1 character b. 4 characters c. 13 characters d. 2 characters e. 3 characters 74. Which Unix command sequence deletes a directory and everything inside it? a. rmdir -r dir b. rmdir -all dir c. rm -all dir d. deltree -all dir e. rm -r dir 75. 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 of this command: cat foo foo | sort -r | head -4 | tail -1 a. 6 b. 8 c. 5 d. 7 e. 9 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-14- PRACTICE 76. If a=9 and b=9, which bash command sequence correctly compares the two numbers as equal and prints OK? a. if ( a == b ) ; then echo OK ; fi b. if [ $a==$b ] ; then echo OK ; fi c. if [ $a -eq $b ] ; then echo OK ; fi d. if test a -eq b ; then echo OK ; fi e. if [ a = b ] ; then echo OK ; fi 77. Which of the following shell command lines displays all the names in the current directory that are exactly three letters (alphabetic) long (and nothing else)? a. echo [a,zA,Z][a,zA,Z][a,zA,Z] b. echo [azAZ][azAZ][azAZ] c. echo ??? d. echo [a-zA-Z][a-zA-Z][a-zA-Z] e. echo [a-zA-Za-zA-Za-zA-Z] 78. How can you ask the bash shell to complete commands or file names for you? a. Type [CONTROL]-[D] and the shell will present a menu of commands. b. Type [CONTROL]-[ALT]-[DEL] 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. You can type the first part of the command or file name and press the ALT key. e. Type [ALT]-[F2] the shell will present a menu of commands. 79. If a=cow and b=pig then what is the output of the following sequence of bash commands: [ $a = pig -o $b = pig ] ; echo $? a. no output b. 1 c. the number 1 or 0 followed by another 1 or 0 on a new line d. test: $a: integer expression expected e. 0 80. 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. no lines (empty file) b. 80 c. 120 d. 50 e. 70 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-15- PRACTICE 81. 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 of this command: cat foo foo | cat | tail -4 | head -1 a. 5 b. 8 c. 6 d. 7 e. 9 82. If foo is a script containing the line TERM=new ; export TERM, what is the output of the following sequence of bash commands that use foo: TERM=bar ; ./foo ; echo $TERM a. $TERM b. foo c. bar d. new e. TERM 83. Which command sequence below does not generate an error message from the last command in the sequence? a. mkdir foo foo/bar ; rmdir foo b. mkdir one one/two ; rmdir one/two c. mkdir foo ; ln foo bar d. date >foo ; cp foo/. bar e. cat /etc/passwd > mail idallen@ncf.ca 84. Which bash command sequence correctly searches for the string foo and then prints YES if it is found inside the group file? a. if test foo /etc/group ; then echo YES ; fi b. if test foo = /etc/group ; then echo YES ; fi c. if grep foo /etc/group ; then echo YES ; fi d. if [ grep foo /etc/group ] ; then echo YES ; fi e. if [ test foo /etc/group ] ; then echo YES ; fi 85. A shell script named foo is executed as follows: ./foo 1 2 "3 4" 5 Inside the script is the line: echo "$3" What is the output from this line? a. 3 4 b. "3 c. 1 2 3 d. $3 e. 2 3 4 86. 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 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-16- PRACTICE 87. In an empty directory, what is the bash shell output of this three-command sequence: touch aa .a ab .b .c ; x='.a* .b*' ; echo '$x' a. .a* .b* b. aa .a ab .b c. .a .b d. $x e. '.a* .b*' 88. If the file pig contained the word foo, what would be the bash shell output of this two command sequence: PATH=/etc/passwd:/bin/ls:/bin/cat ; /bin/ls pig a. foo b. bash: /bin/ls: command not found c. no output d. /bin/ls: pig: No such file or directory e. pig 89. What is the bash shell output of this command sequence: true && echo space junk $? a. space junk ? b. no output c. space junk 1 d. space junk 0 e. space junk ? 90. If a bash shell script named foo contains the line: if [ '$1' = "$2" ] ; then echo SAME ; fi then which of the following command lines will produce SAME as output? a. ./foo 'bar' "bar" b. ./foo bar '$1' c. ./foo bar 'bar' d. ./foo $1 $1 e. ./foo 1 "$1" 91. What is the output of the following sequence of bash commands: x=1 ; y=2 ; test $x -le $y ; echo $? a. 1 b. test: $x: integer expression expected c. no output d. the number 0 or 1 followed by another 0 or 1 on a new line e. 0 92. 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. 5 b. 1 c. 4 d. 3 e. 2 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-17- PRACTICE 93. 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. 200 b. 100 c. 60 d. 160 e. 40 94. How many arguments are passed to the command by the shell on this command line: pig pig pig a. 4 b. 2 c. 3 d. 5 e. 6 95. What is the output of the following sequence of bash commands: x=cow ; y=dog ; test -z $x ; echo $? a. 1 b. test: $x: integer expression expected c. 0 d. the number 0 or 1 followed by another 0 or 1 on a new line e. no output 96. If x=pig and y=dog then what is the output of the following sequence of bash commands: if $x = $y ; then echo $y ; fi a. test: $x: integer expression expected b. bash: pig: command not found c. dog d. test: pig: integer expression expected e. no output 97. 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 bar sees three arguments. c. The command bar sees only two arguments d. The command zoom sees two arguments. e. Error: The command name is missing from the command line. 98. What is the output of the following sequence of bash commands: date='October Monday' ; test date = date a. Mon Oct 27 17:01:38 EST 2003 b. no output c. 1 d. 0 e. test: too many arguments 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-18- PRACTICE 99. If a=pig and b=dog then what is the output of the following sequence of bash commands: [ $a = pig -a $b = pig ] ; echo $? a. 0 b. no output c. test: $a: integer expression expected d. the number 1 or 0 followed by another 1 or 0 on a new line e. 1 100. What is the output of this sequence of three shell commands: umask 674 ; touch newfile ; ls -l newfile a. --w--wxr-x 1 me me 0 Feb 20 07:55 newfile b. --------w- 1 me me 0 Feb 20 07:55 newfile c. -rw-rw-r-- 1 me me 0 Feb 20 07:55 newfile d. -rw-rwxr-- 1 me me 0 Feb 20 07:55 newfile e. ---x----wx 1 me me 0 Feb 20 07:55 newfile 101. What is the bash shell output of this two-command sequence: cd /etc/passwd && echo "in $(pwd)" a. in $(pwd) b. bash: cd: /etc/passwd: Not a directory c. no output d. in 0pwd) e. in /etc 102. A shell script named foo is executed as follows: ./foo a "b c d" e Inside the script is the line: echo "$2" What is the output from this line? a. b b. $2 c. "b d. b c d e. a bash error message: unbound (undefined) variable 103. Which of the following shell command lines displays only the names in the current directory that are exactly three numeric digits long? a. echo [0-9][0-9][0-9] b. echo ??? c. echo '0-9'0-9'0-9' d. echo '[0-9]''[0-9]''[0-9]' e. echo [1-3][1-3][1-3] 104. 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 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-19- PRACTICE 105. Which line below puts the count of the number of lines in the password file into the variable foo? a. foo=[ cat -l /etc/passwd ] b. foo=$( wc -l abc ; ls >abc abc ; wc abc a. 1 1 4 abc b. 1 1 3 abc c. no output d. 0 0 0 abc e. 1 1 2 abc 107. What is the output of the following sequence of bash commands: echo wc >wc ; wc wc >wc ; cat wc a. wc b. no output c. 1 1 3 wc d. 0 0 0 wc e. 1 1 2 wc 108. What is the output of the following sequence of bash commands: x=1 ; touch x ; test ! -z $x ; echo $? a. 0 b. no output c. 1 d. test: $x: integer expression expected e. the number 1 or 0 followed by another 1 or 0 on a new line 109. Which of these statements is true? a. Either single or double quotes will stop shell glob (wildcard) patterns from expanding. b. If /q is an empty directory, echo /q/.* produces an error message. c. Typing ./script and bash script always give identical results. d. The ls dir command looks up the directory argument dir in your $PATH. e. If /p is an empty directory, ls /p/.* produces an error message. 110. What is the output of the following sequence of bash commands: echo wc >wc ; wc wc >wc ; head wc a. 1 1 2 wc b. 1 1 3 wc c. no output d. wc e. 0 0 0 wc 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-20- PRACTICE 111. What is the output of the following sequence of bash commands: echo wc >wc ; wc wc >wc ; sort wc a. 0 0 0 wc b. wc c. 1 1 3 wc d. no output e. 1 1 2 wc 112. What is the output of the following sequence of bash commands: x=cow ; y=dog ; touch $x ; test -z $x ; echo $? a. no output b. 0 c. 1 d. the number 0 or 1 followed by another 0 or 1 on a new line e. test: $x: integer expression expected 113. Which command line displays the contents of the Unix passwd file one page at a time? a. cat /etc/passwd >less b. /etc/passwd | less c. less | /etc/passwd d. less less 114. Which command line below does not show any lines from inside the file dog? a. ls dog b. head dog c. more dog d. tail dog e. less dog 115. If pig=12 and cat=99 then which of the following bash command lines outputs only the word hi (and nothing else)? a. [!pig = cat] && echo hi b. [pig -eq 12] || echo hi c. [ pig -ne cat ] && echo hi d. [pig!=pig] || echo hi e. [ pig = pig ] && echo hi 116. How many arguments are passed to the command by the shell on this command line: bar bar bar a. 5 b. 3 c. 4 d. 2 e. 6 117. In an empty directory, what is the length of the longest file name created by the following bash shell two-command sequence: ok='1 12 123 1234' ; touch '$ok' a. 4 characters b. 1 character c. 2 characters d. 3 characters e. 13 characters 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-21- PRACTICE 118. What is the bash shell output of this two-command sequence: cd /home/alleni || echo "In $(pwd)" a. In /home/alleni b. In $(pwd) c. "In $(pwd)" d. In 0pwd) e. no output 119. If a=1 and b=2 then which of the following bash command lines outputs only the word hi (and nothing else)? a. [ a = a ] && echo hi b. [a!=a] || echo hi c. [a -ne b] || echo hi d. [ a -ne b ] && echo hi e. [!a = b] && echo hi 120. If bar is an executable script containing the line cow=pig then what is the bash output of this sequence of three commands: cow=cat ; ./bar ; echo "the '$cow' ate" a. the $cow ate b. the 'cat' ate c. the 'pig' ate d. the '$cow' ate e. the 'cow' ate 121. If a=cow and b=dog then what is the output of the following sequence of bash commands: [ $a = cow -a $b = cow ] ; echo $? a. the number 1 or 0 followed by another 1 or 0 on a new line b. test: $a: integer expression expected c. 0 d. 1 e. no output 122. 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 123. Given the following bash shell command line: read a b c, which user keyboard input line below will assign the text b to the shell variable named b? a. a,b,c b. a;b;c c. a=a b=b c=c d. a:b:c e. a b c 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-22- PRACTICE 124. Which of these first lines will cause this executable file to be interpreted using the Bash shell? a. !#/bin/bash -u b. #!/bin/bash c. !/bin/bash d. #/bin/bash e. /bin/bash -u 125. If x=5 and y=5, which bash command sequence correctly compares the two numbers as equal and prints OK? a. if test x -eq y ; then echo OK ; fi b. if [ x = y ] ; then echo OK ; fi c. if test $x -eq $y ; then echo OK ; fi d. if [ $x==$y ] ; then echo OK ; fi e. if ( x == y ) ; then echo OK ; fi 126. If foo were a file of text containing 50 different lines, what would be the output of this exact command line: diff foo foo a. no output b. several lines, which are the lines that are different between the two files c. an error message because diff only allows one file name d. the contents of file foo would be displayed e. an error message because diff doesn't allow the same file name twice 127. What is the output of this command sequence: echo dog >one ; echo cow | head -2 one a. an error message b. dog c. dog followed by cow d. cow followed by dog e. cow 128. What is the bash shell output of this two-command sequence: cd /bin && echo "echo $(pwd)" a. echo /bin b. echo $(pwd) c. echo 0pwd) d. no output e. /bin 129. If directory /dir contains these three four-character file names: .123, .124, .???, then what is the output of the following bash shell command line: echo /dir/???? a. no output b. echo: /dir/????: No such file or directory c. /dir/.123 /dir/.124 d. /dir/???? e. /dir/.123 /dir/.124 /dir/.??? 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-23- PRACTICE 130. Given my directory dir and my file dir/bar owned by me, which permissions allow me to change or create new content (data) in the file dir/bar but not delete the file? a. Permissions 400 on directory dir and 400 on file dir/bar. b. Permissions 200 on directory dir and 200 on file dir/bar. c. Permissions 600 on directory dir and 700 on file dir/bar. d. Permissions 100 on directory dir and 100 on file dir/bar. e. Permissions 500 on directory dir and 600 on file dir/bar. 131. Which bash command line below allows programs in the current directory to execute without preceding the names with ./? a. $PATH=/bin:./$HOME b. PATH=/bin:$HOME:. c. PATH = ./$HOME:/bin d. PATH = /bin:$HOME:. e. $PATH=.:$HOME:/bin 132. If a=cow and b=dog then what is the output of the following sequence of bash commands: [ $a = dog -o $b = cow ] ; echo $? a. 0 b. the number 1 or 0 followed by another 1 or 0 on a new line c. no output d. 1 e. test: $a: integer expression expected 133. What is the bash shell output of this two-command sequence: cd /home/alleni && echo "In $(pwd)" a. In $(pwd) b. In 0pwd) c. no output d. "In $(pwd)" e. In /home/alleni 134. How many arguments and options are there to the command: cal -yj 1752 a. Two command line arguments, one of which contains two options. b. Two arguments, one of which is a single option and the other is a pathname. c. Three arguments, one of which contains options and one is a pathname. d. A single numeric option and a three-letter file name. e. Two arguments, neither of which is an option. 135. In an empty directory, what is the shell output of these three commands: touch xx .x xy .y xz ; x='x* y*' ; echo "$x" a. *x *y b. $x c. x* y* d. xx xy e. xx xy xz y* 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-24- PRACTICE 136. What is the bash shell output of this command sequence: true && echo Hello There $? a. Hello There 1 b. Hello There 0 c. no output d. Hello There ? e. Hello There ? 137. What is the output of the following sequence of bash commands: x=0 ; y=1 ; touch $x ; test ! -z $x ; echo $? a. the number 1 or 0 followed by another 1 or 0 on a new line b. test: $x: integer expression expected c. 1 d. no output e. 0 138. Which of the command lines below can generate a non-empty file? a. ls /a/b >/a/b b. grep -v /a/b /a/b >/a/b c. sort -r /a/b >/a/b d. tr abc ABC /a/b e. tail -5 /a/b >/a/b 139. What is the bash shell output of this command sequence: false && echo "linux rocks $?" a. linux rocks 1 b. no output c. linux rocks 0 d. linux rocks 1 e. linux rocks 0 140. 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 ../home/me/../etc/passwd ./me/./foo b. cp me/../../etc/passwd me/foo c. cp ../../etc/passwd /me/foo d. cp ../etc/passwd ../me/foo e. cp ./me/../etc/passwd ../home/me/foo 141. What is the bash shell output of this two-command sequence if run in a directory containing 888 files with names that are all the numbers from 1 to 888 inclusive: cow="*" ; echo '$cow' a. the file names 1 through 888, surrounded by quotes b. the file names 1 through 888 c. * d. '$cow' e. $cow 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-25- PRACTICE 142. Which bash command sequence correctly searches for the chars and then prints OK if it is found inside the password file? a. grep chars /etc/passwd || echo OK b. grep chars /etc/passwd && echo OK e. grep chars >/etc/passwd || echo OK 143. How many arguments and options are there to the command: ls -lid /p a. Two arguments, one of which is a single option name and the other is a pathname. b. Two arguments: A file name starting with a dash and a /p switch option argument. c. Two arguments, neither of which is an option. d. Two command line arguments, one of which contains three options. e. Three arguments, one of which contains options and one is a pathname. 144. 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. Type [CONTROL]-[ALT]-[DEL] 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. You can type the first part of the command or file name and press the ALT key. e. Type [ALT]-[F2] the shell will present a menu of commands. 145. 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. .1 .2 e. $b 146. What is in the file named file after this command sequence: echo a >c ; echo b >>c ; mv c d >file a. no such file (nonexistent file) b. nothing - file is empty - no data c. a followed by b d. a e. b 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-26- PRACTICE 147. 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/1* d. rm dir/?1 e. rm dir/?? 148. Which bash command sequence correctly searches for the chars and then prints OK if it is found inside the password file? a. if test chars /etc/passwd ; then echo OK ; fi b. if test chars = /etc/passwd ; then echo OK ; fi c. if [ test chars /etc/passwd ] ; then echo OK ; fi d. if [ grep chars /etc/passwd ] ; then echo OK ; fi e. if grep chars foo file bar haven a. The command foo sees three arguments. b. The command file sees three arguments. c. The command foo sees only two arguments d. Error: The command name is missing from the command line. e. The command file sees two arguments. 152. If bar is an executable script containing the line foo=dog then what is the bash output of this sequence of three commands: foo=cat ; ./bar ; echo "the '$foo' ate" a. the 'dog' ate b. the $foo ate c. the '$foo' ate d. the 'cat' ate e. the 'foo' ate 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-27- PRACTICE 153. Which of the command lines below can generate a non-empty file? a. grep -v /out /out >/out b. ls /out >/out c. sort -r /out >/out d. tr abc ABC /out e. tail -5 /out >/out 154. What is the output of this sequence of three shell commands: umask 762 ; touch newfile ; ls -l newfile a. -rw-rw--w- 1 me me 0 Oct 1 1:12 newfile b. --------wx 1 me me 0 Oct 1 1:12 newfile c. -------r-- 1 me me 0 Oct 1 1:12 newfile d. ------xr-x 1 me me 0 Oct 1 1:12 newfile e. -rwxrw--w- 1 me me 0 Oct 1 1:12 newfile 155. 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 ../home/xx/../etc/passwd ./xx/./foo b. cp xx/../etc/passwd ../home/xx/foo c. cp ../../etc/passwd /xx/foo d. cp ../etc/passwd ../xx/foo e. cp xx/../../etc/passwd xx/foo 156. What is the output of this sequence of three shell commands: umask 547 ; mkdir newdir ; ls -ld newdir a. d-w--wx--- 1 me me 0 Feb 20 07:55 newdir b. dr-xr--rwx 1 me me 0 Feb 20 07:55 newdir c. dr--r--rw- 1 me me 0 Feb 20 07:55 newdir d. d-w--wxrwx 1 me me 0 Feb 20 07:55 newdir e. d-w--w---- 1 me me 0 Feb 20 07:55 newdir 157. If x=cow and y=dog then what is the output of the following sequence of bash commands: [ $x = dog -o $y = cow ] ; echo $? a. test: $x: integer expression expected b. the number 0 or 1 followed by another 0 or 1 on a new line c. no output d. 1 e. 0 158. What is the output of the following sequence of bash commands: echo hi >wc ; wc wc >hi ; cat hi a. 0 0 0 wc b. 1 1 2 wc c. 1 1 3 wc d. hi e. no output 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-28- PRACTICE Answer Key - DAT2330 - Ian Allen - Winter 2004 - DAT2330 Practice Test - 0% Office use only: 123 138 51 6 146 125 115 122 103 17 107 108 68 72 150 22 16 87 129 96 105 48 65 116 104 1 132 13 84 55 43 25 24 9 109 121 92 61 158 14 40 80 64 128 89 157 5 88 102 31 34 75 82 66 147 20 93 126 77 54 37 137 127 136 139 99 74 81 114 19 50 35 63 153 15 7 49 119 32 142 12 117 149 4 90 10 140 97 130 106 73 52 143 135 70 113 111 141 33 100 59 91 112 154 151 156 44 71 56 46 45 67 152 79 41 134 62 58 42 86 29 11 124 148 8 120 53 60 144 76 36 28 57 95 21 131 69 38 133 26 83 3 94 118 18 78 145 2 23 155 110 85 39 101 27 98 30 47 1. e 45. b 2. a 46. c 3. b 47. b 4. e 48. d 5. c 49. b 6. e 50. b 7. b 51. e 8. a 52. c 9. b 53. c 10. a 54. e 11. e 55. c 12. a 56. d 13. e 57. e 14. e 58. b 15. d 59. d 16. d 60. e 17. d 61. b 18. b 62. b 19. b 63. e 20. c 64. e 21. d 65. d 22. c 66. d 23. e 67. b 24. e 68. c 25. c 69. a 26. d 70. b 27. d 71. e 28. b 72. a 29. d 73. b 30. d 74. e 31. e 75. b 32. c 76. c 33. c 77. d 34. e 78. c 35. e 79. e 36. a 80. e 37. c 81. c 38. c 82. c 39. c 83. b 40. b 84. c 41. d 85. a 42. e 86. a 43. e 87. d 44. a 88. e 158 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Winter 20-29- PRACTICE 89. d 145. e 90. b 146. b 91. e 147. b 92. c 148. e 93. c 149. a 94. a 150. c 95. a 151. e 96. b 152. d 97. d 153. b 98. b 154. c 99. e 155. e 100. b 156. a 101. b 157. d 102. d 158. c 103. a 104. a Count of a: 27 17% 105. b Count of b: 35 22% 106. a Count of c: 29 18% 107. d Count of d: 28 18% 108. a Count of e: 39 25% 109. a 110. e With 5 choices: 158 111. a 1 2 3 4 5 6 7 8 9 10 11 12 13 112. c 14 15 16 17 18 19 20 21 22 23 113. d 24 25 26 27 28 29 30 31 32 33 114. a 34 35 36 37 38 39 40 41 42 43 115. e 44 45 46 47 48 49 50 51 52 53 116. a 54 55 56 57 58 59 60 61 62 63 117. d 64 65 66 67 68 69 70 71 72 73 118. e 74 75 76 77 78 79 80 81 82 83 119. a 84 85 86 87 88 89 90 91 92 93 120. b 94 95 96 97 98 99 100 101 102 121. d 103 104 105 106 107 108 109 122. e 110 111 112 113 114 115 116 123. e 117 118 119 120 121 122 123 124. b 124 125 126 127 128 129 130 125. c 131 132 133 134 135 136 137 126. a 138 139 140 141 142 143 144 127. b 145 146 147 148 149 150 151 128. a 152 153 154 155 156 157 158 129. d 130. e Macro .cmd splits: 60 131. b Macro .ans splits: 0 132. d 133. e 134. a 135. c 136. b 137. e 138. a 139. b 140. b 141. e 142. c 143. d 144. c 158 Questions DAT2330 Practice Test - 0% PRACTICE