UNIX final exam Spring Semester, 2002 ---------------------Name: ________________________________ Login ID: ______________________________ This is an "open" exam. This means you can use your textbook, any notes you have, the UNIX system, and the Web site to help you answer these questions. You have a 3 hour period to complete all of the questions on this exam. Mike will send mail at the beginning of the period and again at the end of the period so I know what files were submitted between those two times. ************************ You must copy this file to your directory space in your UNIX account. % cp ~jplane/final.exam ~ You can then use either vi or emacs to edit the file. Fill in all places where you see a blank "___". Sometimes you will put the answer in place of the blanks (like above for the name and login id) and sometimes you will insert the text of another file between the dashes. You can use copy and paste from the windows environment or the :r vi editor command to include a whole file in at the place indicated between the blank lines. When you are finished, submit this file for grading by mailing it to jplane on the students machine. The command will be similar to % mail jplane -s "final" < final.exam where final.exam is the name of the ASCII file in the current working directory. You will have 3 hours to complete this exam. It must be mailed at the end of the lab period. If you have any troubles, see Mike and he will resolve it and let me know what the problem was. ============================================ 1) Give the correct octal values for each of the following (remember decimal is base 10, octal is base 8, hexadecimal is base 16 and binary is base two): a) What is the octal equivalent to the decimal value 21? ______ b) What is the octal equivalent to the binary value 100110111? ______ c) What 3 octal digits would you use with the chmod command if you wanted to set the permissions so that the owner could read and write the file, the group could read and execute the file and the rest of the world could only execute the file? ____ 2) Create a transcript file (remember: the script command is used to record everything you type and every answer the computer gives you). That one script file should do each of the following things in the order specified. That file should then be included between the dashed lines that appear after the list of tasks. a) list the contents of the ~jplane directory so that the permissions on each of the children (files and directories) of ~jplane is also shown - in addition to information such as size and modification time and date. b) display the list of other users currently using the same computer system. (login ids and possibly other information for all other users) c) display the first 15 lines of the manual page which tells about the command which allows you to change your password. ----insert the file created by the script utility here ----3) Use the grep command to get the list of all lines which do not contain the numeral 1 (one) character from the file named grep.this (in the ~jplane directory). Put that list of lines between the set of dashes as indicated. ----insert lines that do not contain numbers here ----Use the grep command again to get the list of all lines which have a lowercase alphabetic character as the first character on the line and a numeric character as the last character on the line. ----insert the lines described above here ----4) Use the sed command to create a new file and include that file between the dashed lines below. Include the sed command file you used to effect that change between the second set of dashes. Use the file named sed.this which is in the ~jplane directory. Any line that contains the word "lines" in the original file, should have a new line added after it which contains your first name. Lines numbered 1 and 3 should have a new line added before that contains your login id. ----insert the file you created here --------insert the sed command file which caused those changes here ----- 5) Write a complete C-shell script file which has all of the following features. Include that script file between the dashed lines below. a) Have the top line tell the shell to interpret the file using the C-shell. b) Have the second line contain a comment which tells your name and login id. c) Have the next group of lines tell the number of arguments which the script was called with followed on that same line by the list of all of the arguments. d) Have the next group of lines ask the user of the script for his name and read it into a variable. e) Have the next group of lines determine if the name entered by the user was one of the arguments. Print the word "Yes" if it was or the word "No" if it was not. (Only print one or the other and only print it one time.) ----insert the C-shell script file here ----6) Give the command, as it would appear in the Cshell setup file so that you can type the command % month when you want to display just the name of the current month. Hint: the format of the command that tells the date and time is shown here, notice that the name of the month is in the fifth, sixth and seventh characters of the output format (you will need to use the colrm command in conjunction with the date command): FRI JUL 9 11:57:56 EDT 1998 Type the shell command in the blank given here: % _______ 7) Fill in the blanks by telling the command that would be used to do the task described. Use the Cto mean it is done in combination with the control key or the M- to mean it is done in sequence with the meta key. a) Move the cursor into the mini-buffer = _____ b) Move the cursor to the top of the work buffer = _____ c) Delete from the current point of the cursor to the end of the current line = _____ d) Save buffers and kill emacs = ____ _____ 8) Use emacs to copy the header information (the beginning of this project description to the line of stars) to the space between the dashed lines. ----insert this file's header here ----9) Create a file that will be interpreted using nroff text layout language with the ms macro package. Insert the complete nroff source file between the dashed lines given here. The nroff file must contain all of the things listed below. a) Have a comment at the top that tells your name and login id. b) Have a line near the top of the output which has your full name centered on the line. c) Have a line after your name which displays your login id in the output. This line should also be centered. d) Have a paragraph (at least 2 lines of output) which is indented like a standard paragraph and tells about your favorite topic you learned in this class. e) Have a paragraph (at least 2 lines of output) which is a "hanging paragraph". This paragraph should tell about your least favorite topic learned in this class. f) Have a paragraph (at least 2 lines of output) which is a "block paragraph". This paragraph should tell about something else you would have liked to learn more about in this class. g) Add section labels to the document you created above so that the "information" is labeled with a 1, your name is section 1.1, and your login id is 1.2. Then each of the paragraphs should be sections 2, 3, and 4. h) Go back and add emphasizing so that the second word in each of the three paragraphs is emphasized with underlining or italics. ----insert the complete nroff source file here ----10) Create a file that would be interpreted using the tbl command and the nroff command with the ms macro package. This source file should create a table when interpreted. Include the source file here between the dashed lines. The file displayed must have all of the following features: a) The table should have a border line all of the way around but not lines between the cells of the table. b) The table should have two columns. c) The first column should have a label centered at the top of that column which says this is a list of foods. d) The data in the first column should be left justified and it should name 4 of your favorite foods (one per line). e) The second column should have a label centered at the top of that column which says it is the price. f) The data in the second column should be right justified and it should tell the price of each of your favorite foods if served at a restaurant. ----insert the nroff source file here -----