Create a directory structure by carrying out the following tasks in the given order. For each task, give one or more Unix commands that perform the task. Each task should preferentially be performed using a single Unix command that is as concise as possible.

Some tasks may come with additional questions. You can write the answers to these questions as comments with the commands that you submit for each of the tasks.

  1. Create the following nine directories in the current directory:

    secret
    music
    pop_music
    classical_music
    hits
    movies
    thriller
    romantic
    personal

    This should be done preferentially using a single Unix command.

  2. Create the following three text files in the current directory:

    nevermind1_nirvana2.txt
    help3_beatles4.txt
    musicology5_prince6.txt

    Add some information about the artist/album (see links in the above file name) in each of these files.

    Question

    Who can read the content of these files?

  3. Move the directories thriller and romantic into directory movies.

  4. Move the directory movies into the directory personal.

  5. Move the three text files containing information about artists/albums (files with extension .txt) into the directory hits. This should be done preferentially using a single Unix command that uses as few characters as possible.

  6. Move the entire directories pop_music and classical_music into the directory music. This should be done preferentially using a single Unix command that uses as few characters as possible. You may assume that no other directories end with _music.

    Questions

    What file permissions are set for your home directory and the regular files and directories that you have created therein during the previous steps? What is the default setting of the file mode creation mask7?

    Working with file permissions

    Check the usage of the Unix commands chmod and umask.

  7. Make sure that no one else but yourself has any permissions on your home directory (your own permissions for your home directory may not be altered).

    Questions

    Think about two possible approaches to set the file permissions for this task. Which of the two approaches do you favor to carry out the task?

    Additional assignment

    If you are working with other users on the same machine, check with your neighbour that you do not have access to each other's home directories.

  8. Copy the directories music and hits to your home directory. Make the copies of these directories in your home directory and all contained files (including subdirectories) unreadable for all other users except yourself and your group members (all other permissions should remain unchanged).

  9. Create a new file secret.txt in the directory secret and add some text as content into the file. Make sure not a single user is able to search the contents of the directory secret.

    Additional assignment

    If you are working with other users on the same machine, check with your neighbour someone can read the contents of the file secret.txt. Explain what permissions are needed to get access to the file contents.

  10. Remove the entire directories secret and personal (i.e. including all contained files and subdirectories). This should be done preferentially using a single Unix command.