Test #1 Multiple Choice Important Instructions 1. Read all the instructions and both sides (back and front) of all pages. 2. Manage your time when answering questions on this test. Answer the questions you know, first. _________________________________________________________________ Multiple Choice - 45 Questions - 15 of 15% (Office use only: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45) 1. Which command line outputs inode/filename pairs for names in the current directory, sorted by inode number? *a. ls -i -a | sort -n b. ls -a | sort -i c. sort -n | ls -ai d. sort ls -ia e. ls -ia > sort -n 2. Select the correct bash shell order of command line processing: *a. quotes, redirection, variables, globs b. quotes, variables, redirection, globs c. quotes, variables, globs, redirection d. quotes, globs, variables, redirection e. redirection, quotes, globs, variables 3. 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 4. If you type the command grep pattern which key sequence will send an EOF and take you immediately back to the command prompt? *a. [CTRL-D] b. [CTRL-C] c. [CTRL-L] d. [CTRL-U] e. [CTRL-R] 5. If you type the command sleep 60 which key sequence will interrupt it and take you immediately back to the command prompt? *a. [CTRL-C] b. [CTRL-D] c. [CTRL-L] d. [CTRL-U] e. [CTRL-R] 6. Which of the command lines below can generate a non-empty file? *a. ls -l file >file b. cat file >file c. grep pattern file >file d. head -1 file >file e. sort -r file >file 7. Which command line below never shows any lines from inside the file cow? *a. wc -l cow b. head -1 cow c. grep pattern cow d. sort -r cow e. tail -8 cow 8. How many command arguments does the shell pass to this echo command: echo 'It's "1 2" isn't it? I can't decide. *a. Four arguments. b. Five arguments. c. Six arguments. d. Two arguments. e. Three arguments. 9. How many command arguments does the shell pass to this echo command: echo one two three >four five *a. Four arguments. b. Five arguments. c. Six arguments. d. Two arguments. e. Three arguments. 10. Which statement is true, given this long directory listing from ls: drwxr-x--x 256 ian user 512 May 30 12:35 dir *a. The number 512 is the size of this directory. b. The number 512 is the count of links (names) this directory has. c. The number 256 is the inode number of this directory. d. The number 256 is the octal permissions of this directory. e. The number 256 is the size of this directory. 11. What is the output on your screen of this shell command line in an empty directory? echo * *a. * b. an error message from echo saying * does not exist c. . .. d. . e. no output on screen 12. What is the output on your screen of this shell command line in an empty directory? ls * *a. an error message from ls saying * does not exist b. * c. . .. d. . e. no output on screen 13. 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. 7 b. 1 c. 9 d. 5 5 e. 1 1 14. How many lines are in file out after this command line? echo hi >dog >out >cat *a. empty file (no data) b. 1 c. 3 d. 2 e. no such file (file does not exist) 15. Which command line lists all possible utilities available for compiling programs? *a. man -k compile b. man compile c. grep compile /etc/* d. grep /etc/* compile e. man * | grep compile 16. Given this long listing: drwxr-xr-x 296 me me 448 Dec 4 9:12 /dir How many subdirectories lie immediately under /dir? *a. 294 b. 296 c. 446 d. 448 e. there is not enough information shown to answer the question 17. How many lines are in the file bar after this command line: echo hi >x ; echo ho >>x ; cat x >bar *a. 2 b. 4 c. 6 d. 1 e. nothing - empty file - no data 18. How many arguments and options are there to the command: wc -wc /sort *a. Two command line arguments, one of which contains two bundled options. b. Two arguments, one of which is a single option and the other is a pathname. c. A three-letter file name and a /sort switch option argument. d. Two arguments, no options. e. Two options, no arguments. 19. 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. 2 b. 3 c. 4 d. 5 e. 1 20. If directory /a contains these seven two-character file names: aa, ab, ac, ad, a*, a?, ??, then which shell command below will remove only the single name a? from the directory? *a. rm '/a/a?' b. rm /a/?\? c. rm /a/a? d. rm "/a?" e. rm /a\? 21. Which command line below outputs only lines 20-25 of the 36-line file named cow? *a. head -25 cow | tail -6 b. head -25 cow | tail -5 c. head -25 cow | tail -6 cow d. head -25 | tail -6 cow e. tail -6 | head -25 cow 22. 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 followed by b c. a d. b e. no such file (nonexistent) 23. 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/.AA cow/.A1 cow/.BB cow/.B. c. cow/.AA cow/.A1 cow/.BB d. cow/.B. e. no output on screen 24. 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. cat one two >cow b. cp one two >cow c. cp one >cow two >cow d. mv one two >cow e. echo one two >cow 25. In an empty directory, how many words are in file pig after this command line? touch pig pig ; ls >pig *a. 1 b. 3 c. 2 d. 4 e. empty file (no data) 26. What is the possible output on your screen of this command line: echo wc >date ; sort date >date ; cat date *a. no output on screen b. wc c. 1 6 28 date d. 1 6 29 date e. Wed Jan 26 13:00:00 EST 2005 27. 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. the parent directory of dir now has a file named old in it b. the directory dir now contains only a file named old c. there is a second copy of the file new in the file named old d. the command fails because the path ./dir/../new does not exist e. the command fails because the path ../myhome/old does not exist 28. If file x contains ten lines, and file y contains twenty 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. 50 b. 55 c. 60 d. 40 e. no lines (empty file) 29. If file twenty contains twenty lines, and file thirty contains thirty lines, then how many lines are output by this command: tail twenty | cat thirty *a. 30 b. 50 c. 20 d. 40 e. no output on screen 30. If my current directory is /usr, which of these pathnames is equivalent to the pathname /usr/x/y/z? *a. x/./y/z b. /x/y/z c. ./usr/x/y/z d. ../x/y/z e. ../usr/y/z 31. What is the output on your screen of this successful command line? cd /home/myhome ; mkdir foo ; mkdir bar ; pwd *a. /home/myhome b. /home/myhome/foo c. /home/myhome/bar d. /home/myhome/foo/bar e. /bar 32. Which command line 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 [1-3][1-3][1-3] c. echo [3][3][3] d. echo [?][?][?] e. echo ??? 33. What is in file two after running this command line? echo one >two three four *a. one three four b. one c. echo one d. three four e. empty file (no data) 34. What command shows all the lines in file foo that contain the string bar? *a. grep bar foo b. grep grep bar e. find foo bar 35. In the output of the command ls -i -a, a dot that begins a pathname signifies what? *a. A name that is hidden. b. The parent directory. c. The current directory. d. A name with an unprintable character. e. An inode (index) numbered file. 36. When doing an ls -a, the output pathname that is a double dot (..) signifies what? *a. The parent directory. b. A hidden file. c. The current directory. d. The root directory. e. A pathname with double links. 37. Which Unix command line deletes a directory and everything inside it? *a. rm -r dir b. rm -all dir c. rmdir -r dir d. rmdir -all dir e. deltree -all dir 38. What appears on your screen after this command line? mkdir xx ; rmdir xx | wc -c *a. 0 b. 1 c. 2 d. 3 e. no output on screen 39. What appears on your screen after this command line? echo hi >ls ; cat ls >wc *a. no output on screen b. 1 1 2 c. 1 1 3 d. ls e. hi 40. Which of these commands always returns you to your account home directory? *a. cd b. cd /home c. cd home d. cd .. e. cd /home/.. 41. In an empty directory, how many files are created by this command: touch a "b c" ' ' d e *a. 5 b. 6 c. 7 d. 3 e. 4 42. 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* 43. What is the output on your screen of the following command sequence if run in a directory containing 123 files with names that are all the numbers from 1 to 123 inclusive: glob="*" ; echo "$glob" *a. * b. $glob c. "$glob" d. the file names 1 through 123 e. the file names 1 through 123, surrounded by quotes 44. What is the link count of file bar after this set of successful commands? rm bar ; date >bar ; ln bar foo cp bar z ; ln z x ; ln foo y ; ln z a *a. 3 b. 1 c. 2 d. 4 e. 5 45. If file bar occupies one disk block, how many disk blocks are in use after this sequence of commands: cp bar one ; ln one two ; cp bar two ; ln bar foo *a. 2 blocks b. 3 blocks c. 4 blocks d. 5 blocks e. 1 block Answer Key - NET2003 - Ian Allen - Winter 2005 - NET2003 Unix Test #1 - 15% Office use only: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 1. a With 5 choices: 45 2. a 1 2 3 4 5 6 7 8 9 10 11 12 13 3. a 14 15 16 17 18 19 20 21 22 23 4. a 24 25 26 27 28 29 30 31 32 33 5. a 34 35 36 37 38 39 40 41 42 43 6. a 44 45 7. a 8. a Macro .cmd split no indent: 0 9. a Macro .cmd split with indent: 13 10. a Macro .ans splits: 0 11. a 12. a 13. a 14. a 15. a 16. a 17. a 18. a 19. a 20. a 21. a 22. a 23. a 24. a 25. a 26. a 27. a 28. a 29. a 30. a 31. a 32. a 33. a 34. a 35. a 36. a 37. a 38. a 39. a 40. a 41. a 42. a 43. a 44. a 45. a Count of a: 45 100%