Consider a Unix operating system in which there are two directories /usr/dir1 and /usr/dir2 and the file /usr/dir1/file1.
- Draw a figure representing the given directories in the directory tree.
- 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.
- 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.
- 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.
- Write Unix commands to:
- change the directory so that the root becomes the current directory
- make a directory called new_dir in the root directory
- copy the file myfile from the directory /dir1 into the directory new_dir
- change the name of the file you have just copied in directory new_dir so that the new name is yourfile
- 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.
- 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:
ln file1 file2
The diagram should include:
- the directory dir1 (with its internal structure and content)
- the inode(s) included with its(or their) internal structure
- the data belonging to the file(s)