Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Exercise 1 [Unix, 4 points] Consider the following tree structure for files and

ID: 3733414 • Letter: E

Question

Exercise 1 [Unix, 4 points] Consider the following tree structure for files and directories in Unix (directories are boxed, to distinguislh them from files): F1 F2 F4 F5 a3.c F6 F7 F8 al.htm a2.txt F9 Assume that your home directory is F6, and your current working directory is F8 Write a single Unix command that changes your current directory to F9. Use paths relative to your home directory in your command (not starting at the root or at the current directory): a) b) Your current directory is now F5. Write a single Unix command that copies the file al.htm into your current directory. Use paths relative to your current directory in your command (not starting at the root or at your home directory) c) Write a single Unix command that removes the directory F5 and all its contents. Use paths starting at the root in your command (not starting at your home or current directory):

Explanation / Answer

In relative path single dot (.) signifies current directory and double dot (..) signifies parent directory.

a) This command will take the user from current directory F8 to parent directory F4. From F4 the directories F7 and F9 are traversed

$ ../F7/F9

b) cp command is used for copy file from sourse to destination. The current working directory is F5, so with first double dot user reaches F2 directory, from second double dot user reaches root directory. From root directory F1/F3/F6 are traversed to select the file a1.htm to F5 directory which current working directory, hence single dot is used in second parameter of cp command.

$ cp ../../F1/F3/F6/a1.htm ./a1.htm

c) rm command is used to delete the directory. -r option is used for recursive deleting means deleting all files and subdirectories under this.

$ rm -rf /root/F2/F5/