CS/CE218 --- Unix and C Programming. 4 September 91 Revised: 10 Sept 91 HOMEWORK 1: DIRECTORIES AND FILES Due: 11 September 1991 1. (0 points) What is the date and time now? That is, when are you starting this homework? 2. (10 points) Write an essay, using emacs, of not more than one page (or about 50 lines) about your goals for this class. This essay will be graded on thought, clarity, and style; it may help to outline your points first. You may wish to discuss parts of the course objectives (from the course specification handout) that you disagree with, or things about how the course seems to be going that you don't like. When your essay is done, use emacs to mail a copy to ``leavens'' with subject ``goals essay,'' and hand in a printed copy as well (for your TA). You should also discuss this with Prof. Leavens (see the Red Tape handout). 3. (extra credit only) Use emacs outline mode to outline an essay about Richard Stallman's philosophy as described in his ``The GNU Manifesto''. Your outline should be for an essay that would either argue against Stallman's ideas (which might, after all, put you out of a job!) or for his ideas (which might, after all, make software free!). Underneath heading put your ideas for each argument. Use outline mode to check whether the argument is logically structured and complete. 4. (3 points) What are some of the advantages of using hierarchies, like Unix directories, to organize files? 5. (3 points) In a Unix manual page's command synopsis, what does ``[file]'' mean? What does ``[-xyz]'' mean? Comment on the consistency and succinctness of the meaning of such constructs in Unix manual pages. 6. (5 points) Briefly describe an abstract data type found in emacs, by describing its state and the operations that create, change, and observe it. 7. Use `ls' with some of its options to determine the subdirectory with the oldest date in the directory /home/staff. (By a subdirectory here is meant a *direct* subdirectory; one named /home/staff/*) a. (1 point) What is the relative path name (from /home/staff) of the subdirectory with the oldest date? b. (1 point) Does the date indicate when the directory was created or when it was last modified? What option of `ls' did you use? 8. (4 points) Create two subdirectories called 'dir1' and 'dir2' where dir1 is a subdirectory of your home directory, and dir2 is a subdirectory of dir1. As a result, the relative path of dir2 from your home directory should be 'dir1/dir2'. a. Which group owns the new directories? b. What (in words) are the group permissions of the new directories? c. (Extra credit only) Why does the group have those permissions? 9. Copy the file /etc/profile file into dir1/profile. a. (1 point) What is the full path name of the new file in dir1? b. (1 point) Who is the owner of the file in dir1? c. (1 point) What are your access permissions for that file? d. (1 point) What were your access permissions for /etc/profile? e. (5 points) Try copying some other files that originally have different permissions State a general rule about the ownership and permissions given to a copy of a file, based on the original file's permissions. 10. (7 points) Change the permission of dir1 to 100 (``chmod 100 dir1''). Keep the default permissions on dir1/dir2. For each of the following expirements, after giving your observation, give an explanation (with more detail than ``because of the permissions''). a. Can you list the contents of dir1 using ls from your home directory? What about dir1/dir2? b. Can you change directories (cd) into dir1 from your home directory? Can you change into dir1/dir2 from your home directory? c. Can you copy dir1/profile to dir1/dir2 (from your home directory)? d. Can you remove dir1/profile? Change the permissions on dir1 to 770. e. Are there any files in dir1/dir2 now? f. What, in your own words, does ``x'' permission mean on a directory? 11. (5 points) What is the minimum that you need to do to your home directory, and files to avoid giving other students the opportunity to copy your files without you knowing about it? 12. (5 points) Consider the full path name ``/usr/local/bin/..''. It is equal to the path ``/usr/local''. Consider several examples of full paths involving ``.'' and ``..''. Give a general rule (algorithm) for converting such paths into paths not involving directories ``.'' and ``..'' and describe why it is correct (i.e., why it works). You may state the algorithm in Pascal, C or pseudo-code (structured English). 13. (0 points) What is the date and time now? That is, when are you finishing this homework? How many hours did you work on it? Feedback questions: (no credit of any kind) 14. Rate the difficulty of this homework set. 5 4 3 2 1 (5 = too hard, 1 = too easy ) 15. Rate how you think the questions related to the topics in the text and the class lecture. 5 4 3 2 1 (5 = highly related, 1 = no relationship at all) 16. Rate the clarity of the questions. 5 4 3 2 1 (5 = very clear, 1 = unclear) 17. Rate how much you learned from taking this homework. 5 4 3 2 1 (5 = couldn't have lived without it, 1 = waste of time)