Section number:

Student ID:


Midterm examination

  1. Consider a Unix operating system in which there are two directories /usr/dir1 and /usr/dir2 and the file /usr/dir1/file1.

  1. Draw a figure representing the given directories in the directory tree.
  2. Draw a diagram representing the directory /usr/dir1 and the file /usr/dir1/file1. The diagram should include the inode of the file /usr/dir1/file1, the data blocks of the same file and the content of the directory /usr/dir1.
  3. Draw a diagram representing the situation after the execution of the command:

/usr/dir2 > ln /usr/dir1/file1 file2

Note that the command is launched when /usr/dir2 is the current directory.

  1. Consider the file myfile in the directory /dir1. Assume the directory dir1 is your current directory. Set the permissions for myfile so that you (the owner of the file) will be able to write, read and execute this file, your group will only be able to read and execute it and everybody else will not be able to do anything with this file.

Hint: If you use the symbolic syntax, you will need more than one command to set the permissions as required. Use (at least) one command for each level of permissions.

  1. Write Unix commands to:

  1. change the directory so that the root becomes the current directory
  2. make a directory called new_dir in the root directory
  3. copy the file myfile from the directory /dir1 into the directory new_dir
  4. change the name of the file you have just copied in directory new_dir so that the new name is yourfile
  5. delete the file myfile from the directory dir1

Observation: Pay attention to which directory is your current directory. If you work with a file which is not in the current directory, use the full pathname of the file or change the directory first.

  1. Extra credit:

Consider the situation of a file named file1 contained in a directory named /dir1. Draw two diagrams representing the situation before and after the execution of the commands:

cd /dir1

ln file1 file2

The diagram should include:

  1. the directory dir1 (with its internal structure and content)
  2. the inode(s) included with its(or their) internal structure
  3. the data belonging to the file(s)