Unix Term Test #1 DAT2330 - Ian Allen - Fall 2003-1- 45 minutes Evaluation: 42 Questions Name: _________________________ Important Instructions 1. Read all instructions and both sides of all pages. 2. Manage your time when answering questions on this test. Answer the questions you know, first. (Office use only: 5 11 12 42 26 34 7 13 15 35 33 14 17 36 40 9 18 41 25 37 32 31 24 1 28 10 29 30 6 20 4 8 19 38 23 27 16 3 22 2 39 21) 1. Which command sequence outputs inode/filename pairs for names in the current directory, sorted by inode number? a. ls -ia | sort -n b. ls -node * > sort -n c. ls -i * > sort d. sort ls -ia e. ls ./* | sort -node 2. Which command below removes only this four-character file name containing a special character (and no others): ?abc a. rm ""?abc"" b. rm -r ?abc c. rm "?abc" d. rm /?abc e. rm ''?abc'' 3. Which command below removes only this four-character file name containing a special character (and no others): xyz? a. rm xyz/? b. rm -r xyz? c. rm xyz\? d. rm xyz//? e. rm xyz\\? 4. What is in file cow after running this bash shell command line? echo one two >cow three a. one two cow three b. one two three c. one two d. echo one two e. no output (empty file) 5. When doing an ls -a, the output pathname that is a double dot (..) signifies what? a. The root directory. b. The current directory. c. A hidden file. d. A file or directory with double links. e. The parent directory. 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Fall 2003-2- 45 minutes 6. If your terminal type is xterm, what is the output of this bash shell command line? echo '$TERM' a. xterm b. '$TERM' c. 'xterm' d. $TERM e. no output 7. How many lines are in the file out after this command sequence: echo hi >x ; echo ho >>x ; cat x x x >out a. 2 b. 6 c. nothing - empty file - no data d. 1 e. 3 8. 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-L] c. [CTRL-U] d. [CTRL-D] e. [CTRL-C] 9. 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 directory empty now contains only a file named dog b. the directory empty/.. now has a file named dog in it c. the command fails because the path ../alleni/dog does not exist d. the command fails because the path empty/../cat does not exist e. there is a second copy of the file cat in the file named dog 10. What appears on your screen after this bash shell command line? echo xx >z ; ls z > wc a. 2 b. 1 1 2 c. 1 1 3 d. 3 e. no output 11. 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. foo/.x1 foo/.x2 foo/.z3 foo/.z. b. foo/.x1 foo/.x2 foo/.z3 c. no output d. foo/??? e. foo/.z. 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Fall 2003-3- 45 minutes 12. 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-D] b. [CTRL-R] c. [CTRL-L] d. [CTRL-U] e. [CTRL-C] 13. How many arguments does the shell pass to this echo command: echo " 1 2 "three ' 4 ' five"6" a. One argument. b. Four arguments. c. Three arguments. d. Five arguments. e. Nine arguments. 14. 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. 1 b. 2 c. 3 d. none e. 4 15. In an empty directory, what appears on your screen after this bash command line? ls out 2>/dev/null a. out not found b. /dev/null not found c. no output d. out 2 not found e. out 16. Which of the command lines below can generate a non-empty file? a. tail -3 file >file b. wc -wc file >file c. cat file file file >file d. sort -r file >file e. head -5 file >file 17. 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 size of this directory. c. The number 456 is the size of this directory. d. The number 123 is the octal permissions of this directory. e. The number 123 is the inode number of this directory. 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Fall 2003-4- 45 minutes 18. In an empty directory, how many words are in file cow after this bash shell command line? touch dog dog cat ; ls >cow a. 3 b. no output (empty file) c. 4 d. 2 e. 1 19. 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 ./? 20. What is the correct syntax to redirect both standard output and standard error into the same output file? a. command >out 2>1 b. command >out 2>out c. command 2>&1 >out d. command >out 2>&1 e. command 2>1 >out 21. 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. 21 b. 50 c. no lines (no output) d. 20 e. 30 22. 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. 100 b. 50 c. 60 d. no lines (empty file) e. 30 23. 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]-[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 ALT key. d. Push key F1 and the system will present a menu of commands. e. You can type the first part of the command or file name and press the TAB key. 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Fall 2003-5- 45 minutes 24. What is the output of this shell command line in an empty directory? ls * a. . b. . .. c. * d. no output e. an error message from ls saying * does not exist 25. Which command sequence below outputs only lines 11-15 of the 99-line file named cat? a. tail -10 cat | head -15 cat b. head -15 cat | tail -5 cat c. head -15 cat | tail -5 d. head -10 cat | tail -15 cat e. tail -15 cat | head -10 26. In the output of the command ls -a, a dot that begins a name signifies what? a. A current file. b. The parent directory. c. A name with an unprintable character. d. The current directory. e. A name that is hidden. 27. 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. 8 b. 6 c. 1 1 d. 4 4 e. 6 6 28. 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 ??? c. echo [1-3][1-3][1-3] d. echo [0-9][0-9][0-9] e. echo [3][3][3] 29. What is in the file out after this command sequence: echo hi >x ; echo ho >>x ; cp x y >out a. nothing - empty file - no data b. hi c. hi followed by ho d. ho e. no such file (nonexistent) 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Fall 2003-6- 45 minutes 30. If my current directory is /etc, which of these pathnames is equivalent to the file name /etc/passwd? a. /passwd b. ../etc/passwd/. c. ./etc/passwd d. ../passwd e. ./passwd 31. What command shows all the lines in file foo that contain the string bar? a. grep bar >foo b. grep cat foo bar c. cat foo > grep bar d. grep foo bar e. grep bar foo 32. Which command line lists all possible utilities available for sorting files? a. man -k sort b. grep /etc/passwd sort c. man sort d. man | grep sort e. grep sort /etc/passwd 33. 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. cp in1 >out in2 >out b. cat in1 in2 >out c. mv in1 in2 >out d. cp in1 in2 >out e. echo in1 in2 >out 34. In an empty directory, what is in file out after this bash command line? ls nosuchfile | wc -l >out a. 10 b. 11 c. 1 d. no output (empty file) e. 0 35. How many arguments and options are there to the command: wc -wc /sort a. Two options, no arguments. b. Two arguments, no options. c. Two arguments, one of which is a single option and the other is a pathname. d. A three-letter file name and a /sort switch option argument. e. Two command line arguments, one of which contains two bundled options. 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Fall 2003-7- 45 minutes 36. What command can you use to remove a directory that isn't empty? a. del -r dir b. mv -r dir c. deldir -r dir d. rmdir -r dir e. rm -r dir 37. How many command arguments does the shell pass to this echo command: echo 'It's a bird! No! It's a plane!' a. Five arguments. b. Four arguments. c. Three arguments. d. One argument. e. Two arguments. 38. What can you do to get back (redo) the last command you typed to the bash (Linux) shell? a. Type [CONTROL]-[BACKSPACE] b. Use the "UpArrow" key. c. Use the "PageUp" key. d. Type [ALT]-[F2] e. Type [CONTROL]-[ALT]-[DEL] 39. 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/bash/. e. /bin/bin/../bash 40. Which command line below does not show any lines from inside the file dog? a. head -3 dog b. less dog c. sort -r dog d. tail -8 dog e. ls dog 41. What text is output by this bash shell command sequence: echo dog >out ; echo cat | sort out a. cat b. dog c. dog followed by cat d. out e. cat followed by dog 42. What is the output of this successful command sequence? cd /home/dir ; mkdir one ; mkdir two ; pwd a. /home/dir/one b. /home/dir/one/two c. /home/dir d. /two e. /home/dir/two 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Fall 2003-8- 45 minutes Answer Key - DAT2330 - Ian Allen - Fall 2003 - DAT2330 Test #1 - Unix - 15% Office use only: 5 11 12 42 26 34 7 13 15 35 33 14 17 36 40 9 18 41 25 37 32 31 24 1 28 10 29 30 6 20 4 8 19 38 23 27 16 3 22 2 39 21 1. a With 5 choices: 42 2. c 1 2 3 4 5 6 7 8 9 10 11 12 13 3. c 14 15 16 17 18 19 20 21 22 23 4. b 24 25 26 27 28 29 30 31 32 33 5. e 34 35 36 37 38 39 40 41 42 6. d 7. b Macro .cmd splits: 9 8. e Macro .ans splits: 0 9. b 10. e 11. d 12. a 13. c 14. b 15. c 16. b 17. c 18. a 19. b 20. d 21. d 22. b 23. e 24. e 25. c 26. e 27. a 28. d 29. a 30. e 31. e 32. a 33. b 34. e 35. e 36. e 37. a 38. b 39. a 40. e 41. b 42. c Count of a: 8 19% Count of b: 10 24% Count of c: 7 17% Count of d: 5 12% Count of e: 12 29% 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes