Test #1 Multiple Choice 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 - 42 Questions - 6 of 10% (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) 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. How can you ask the bash (Linux) shell to complete commands or file names for you? *a. Type the first part of the command or file name and press the [TAB] key. b. Type the first part of the command or file name and press the [ALT] key. c. Type the first part of the command or file name and press the [ALT]-[F1] key. d. Type the first part of the command or file name and press the [CTRL]-[D] key. e. Type the first part of the command or file name and press the [CTRL]-[C] key. 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 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 12. What is the output 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 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 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. no output (empty file) 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. Which of these statements is true? *a. Unix commands must be entered in lower-case letters. b. Unix commands can be entered in upper-case or lower-case letters; they are equivalent. c. You can only login to Unix once per userid; you cannot be logged in to the same machine twice. d. To erase an entire line of typing, type [CTRL]-[D]. e. To indicate End-of-File (no more input), type [CTRL]-[C]. 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 10-15 of the 16-line file named cow? *a. head -15 cow | tail -6 b. tail -16 cow | head -10 c. head -16 cow | tail -5 cow d. head -15 | tail -6 cow e. tail -10 cow | head -6 cow 22. What is in the file cow after this command line: echo a >b ; echo b >a ; mv b a >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 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 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. no output (empty file) 26. What is the possible output on your screen of this command line: echo wc >date ; sort date >date ; cat date *a. no output b. wc c. 1 6 28 date d. 1 6 29 date e. Mon Sep 27 15:58:34 EDT 2004 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 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 30. What is the output 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 31. 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 ??? 32. 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 lines (no output) 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. no output 34. What command shows all the lines in file /etc/group that contain the string idallen? *a. grep idallen /etc/group b. grep /etc/group idallen c. cat /etc/group > grep idallen d. cat /etc/group | wc idallen e. grep idallen >/etc/group 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. 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 37. 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. 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 39. What appears on your screen after this command line? echo hi >ls ; cat ls > wc *a. no output 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. *x* b. ?x? c. [x] d. *x e. x* Answer Key - DAT2330 - Ian Allen - Fall 2004 - DAT2330 Unix Test #1 - 10% 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 1. a Macro .ans splits: 0 2. a 3. a 4. a 5. a 6. a 7. a 8. a 9. a 10. a 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 Count of a: 42 100% With 5 choices: 42 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 Macro .cmd splits: 11