Midterm Exam - Spring 2011

Midterm Exam - Spring 2011 - 4%0 CSZ351 UNIX Programming...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 4%0 CSZ351 UNIX Programming Spring 2011 Midterm Exam Name: Section: Lin 2; Midterm Exam C82351 — UNIX Programming Spring 201 l . Part A: Multiple Choice Questions (2 pts. each) Circle the single correct answer for each question. 1. The command to move a file to another directory, and delete the original, is: )2( move / 2. Which command is used to combine column of data? ,a4 combine )2. merge / ,d. join 3. The command to alter the permission settings of a file is: a. chgrp b. chown " @ chmod / d. set 4. Which of the following commands displays the current working directory? a. rmdir b. cd © pwd / d. HOMEDIR=’pwd’ 5. The difference between > and >> when redirecting output is: /a./ > means to append and >> means to overwrite. > means to overwrite and >> means to append. / ,e.’ They both have the same meaning. (d? > is for the korn shell, and >> is for the c shell. 6. The wildcard character which matches a single character is: Ia.” 33 «K & @ ? d. * 7. The command syntax to display the file ‘sampletxt’ one page at a time is: man sampletxt > more ' )5 K cat sampletxt < more 914 V cat sampletxt I more / tree sampletxt ‘ (382351 — UNIX Programming Spring 2011 Midterm Exam 8. Which of the following commands details the contents of the current directory? ls b. cat 0. top / (1. man 9. The total number of arguments given to shell script is denoted by: a. $1 b. $$ c $0 I / @$# 10. The command to extract the last specified lines from a file is head: ‘3 False « / 1 1. The command, ls —a, /a(( lists only the files beginning with ‘.’ b. lists files and sizes in blocks ‘ c. list files recursively / @3 list files including the invisible files 12. Which of the following commands displays a file, removing all but one copy of successive repeated lines?- diff / /e.’ sort /d.( cut 13. The find command works on the current working directOry only: 14. Which of the following commands is a simple calculator? a. calc b. calculator _ / e be d. maple 15. To send files to the printer, use: a. lpstat b. lprn Q 1P / d. ls CS2351 — UNIX Programming Spring 2011 ' Midterm Exam 16. In the Korn shell, which special character is used to see the content of a variable? ? / c.& d.@ 17. Which of the following vi commands will delete a single character? a. dd b; cw . / c. dw x 18. In a Korn shell script, what is the value of the variable $1? é) The first command line argument b. Integer value 1 / c. The name of the script d. The environment variable P81 19. Which of the following commands is used to get help on a command? CED man g l/ 20. Which of the following commands displays the difference between two files on a line—by- line basis? a. uniq - ./ d. quota . 21. Which of the following commands can be used to rename a file? a. rename b. m . c. cp '/ mv 22. Which of the following vi commands will delete a single line? dd few / c. d d. x 23. Which of the following commands will print the file myfile to the printer mle8pr2? a. print myfile mleSpr2 lp —d mle8pr2 myfile / c. lp mleSprZ myfile d. —lprinter mleSprZ ~file myfile C82351 — UNIX Programming Spring 2011 Midterm Exam 24. Which command is used to make a variable and its value visible to shell scripts?: a. make b. visible @ export / d. import 25. Which command is used for counting the number of lines, words, and characters in a file or directbry? ' wc b. count / C. out d. paste 26. Which command is used to search one file for a specified pattern? a. search b. sort / c. find grep 27. Which command will allow the user(owner) to have read, write and execute permissions, and give everyone else read and write permissions for a file called "filel", assuming that the file has no permissions set at all?: @ chmod u+rwx, go+rw filel ,b.’ chmod a=rw, u+x filel / ,e./ chmod u=rwx, go—x filel 1d? chmod a+rw, o+x filel 28. The d<cr> vi editor command deletes two lines. True b. False / 29. Which command is used to create a new directory? I a. rmdir b. newdir c. dir / @mkdir 30. The nd command works from the current directory and on down to all the subdirectories. True / 3 1. If a file has numeric permissions of 754, this is equal to what set of symbolic Permissions? i '7, 741/ drwxr——r—- 1 , . . (ED —rwxr-xr-- 1/ x-(Wtr r w- x f» - c -r-xrw-rw- If dr—xrw-rw- ‘Ltv (382351 -— UNIX Pro rammin S rin 2011 . Midterm Exam Consider below the fictitious file system: (for questions 32-35) (Assume that words inside the box represent directories, others represent plain files). hm. “HF ya...»- MVMFM .. , b 111 home a...“ MST V61]? .r" ‘-.. . X I‘m-5“». ,3“! Eat My; fi-xx'kxx hwl file‘l hwiZ filefl P921311 file} , w pgm; 32. If the current working directory is “lab”, what is the output of the command “ls ../”? a. jobl b. lab filel fileZ file3 d. filel £1162 £1163 lab @ 33. What is the absolute pathname of “amy”? a. amy b. home/army / @ /home/amy d . /amy 34. If the current working directory is “amy”, what is the relative pathname of “bob”? /a.’ /home/bob b. ./bob / )2! amy/. ./bob ../bob V 35. If the current working directory is “bob”, which one of the following commands will create a new subdirectory named labl ? a. newdir labl ® mkdir labl _ 1/ c. rrn prog/labl d. mkdir prog/lab* «7/ (352351 — UNIX Programming Spring 2011 ' Midterm Exam Part B: Fill—in—the-blank (5 pts. each) 36. The command to obtain 10 gin information about yourself and other persons and display the information one sereen at a time is :E,’ nae.’ I mg m, / .' 37. To set a file named “sampletxt” with the permission string as “-rwxrw—r-x”, we can type in ch mi: 5' m. In xi / 38. There are several shells that are available on UNIX machines. Name three of them: ernC j Kerri, C / 39. What is the output from the command: myscript 7 9 l3 , if the contents of myscript are given below: #! /bin/ksh / 5a {m - L—______ print “Begin” printu$033 .——? W $0 print $0 4 run scrLP+ print $1 5 print $2 Eng print $* ————-’7 7 q 6 print $# print “End” 40. What does the following command do, and what purpose does it serve? alias h=history 04": 4 35K! gm g 41. What does the following command do? sort —k2 employee r r , . 33 for}: {:5 it are? it; (“’9‘ it“; (if 5“: a“! ir’ltnififlafiiiflfi ‘3 "i I U I ...
View Full Document

Page1 / 7

Midterm Exam - Spring 2011 - 4%0 CSZ351 UNIX Programming...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online