The focus of the first homework assignment is learning to navigate and operate the Unix filesystem. In addition to moving around a Unix system, you will need to know how to manipulate files and folders, search for files, read and modify permissions, and combine programs using pipes.

For this assignment, record your responses to the following exercises in the README.md file in the homework01 folder of your assignments Bitbucket repository and push your work by 11:59 PM Friday, January 22, 2016.

Exercise 01: Paths (2 Points)

Suppose you were at your AFS home directory on one of the student machines:

  1. How would you navigate to the csesoft AFS home directory using an absolute path?

  2. How would you navigate to the csesoft AFS home directory using a relative path?

  3. How would you navigate to the csesoft AFS home directory using a path that contains ~?

  4. How would you create a shortcut or link in your own $HOME directory called csesoft to the csesoft AFS home directory.

Computer Science and Engineering Software

The csesoft AFS home directory contains a collection of updated and additional software for students to use in coursework including:

It is located at the following path:

/afs/nd.edu/user14/csesoft

To utilize the software collection, you can add it to your $PATH environmental variable by using the following command:

setenv PATH /afs/nd.edu/user14/csesoft/new/bin:$PATH

To make this a permanent change, you should store the command above in your ~/.cshrc file.

Exercise 02: Copying, Moving, Removing (3 Points)

The /usr/share/pixmaps folder is found on many Linux machines. It usually contains images such as icons and wallpapers. On the student machines:

  1. How would you copy all the contents of the /usr/share/pixmaps folder to a new images folder in your AFS home directory?

  2. Perform the copy operation above and then inspect the symlinks in the new images folder. Are there any broken links? If so, how do you know and why are they broken?

  3. How would you rename the images folder to pixmaps? Time this operation using the time command.

  4. How would you move the pixmaps to /tmp/$USER-pixmaps (where $USER is your netid)? Time this operation using the time command. Is this operation slower? Why?

  5. How would you remove the /tmp/$USER-pixmaps folder? Time this operation using the time command. How does this compare to the previous move command?

Hints

  1. You may wish to utilize some of the following commands: cp, mv, rm.

Exercise 03: Files and Directories (5 Points)

In a past life, the instructor was a member of the Cooperative Computing Lab (CCL) and worked under the direction of Dr. Douglas Thain. One of the instructor's duties was to maintain the group's software, which is still located at the following path:

/afs/nd.edu/user37/ccl/software
  1. How would you list the contents of the software directory such that you get a long listing with file sizes in human readable format (ie. K, M, G, etc.)?

  2. How would you list the contents of the software directory such that you get a long listing of objects from newest to oldest (ie. the most recently modified file or directory is listed at the top)?

  3. The Cooperative Computing Lab develops a set of distributed and scientific computing applications collectively called the CCTools and provides the latest version of the software at the following path:

    /afs/nd.edu/user37/ccl/software/cctools/x86_64
    

    How many total files (excluding directories) are in the directory above? What command(s) did you use to determine the total?

  4. Does the directory above contain an executable named weaver? If so, that is the program written by the instructor for his dissertation. What command(s) did you use to determine if the folder contained weaver?

  5. Which of the three folders in the /afs/nd.edu/user37/ccl/software/cctools/x86_64 directory is the largest and how large is it (in terms of megabytes)? What command(s) did you use to determine the largest directory and its size?

  6. How many files are in the largest folder found above? What command(s) did you use to determine the number of files in the largest folder?

  7. What is the largest file in the /afs/nd.edu/user37/ccl/software/cctools/x86_64 directory? What command(s) did you use to determine the largest file?

  8. How many files in the /afs/nd.edu/user37/ccl/software/cctools/x86_64 directory have not been modified in more than 30 days? What command(s) did you use to determine this?

Hints

  1. You may wish to utilize some of the following commands: du, find, ls, sort, xargs, wc.

  2. You can combine multiple commands by passing the output of one command as the input of a subsequent command by using pipes such as:

    du | sort -n | head -n 5
    

    Which gives you the top five results after sorting the output of du.

Exercise 04: Unix Permissions (2 Points)

Suppose you had a file, data.txt, with the following permissions:

  rwxr-x--x
  1. Identify who can read from that file, write to that file, and execute that file.

  2. What command would you execute to change data.txt such that:

    a. Only you can read and write to the file.

    b. Only you and members of your group can read, write, and execute the file.

    c. Anyone can read the file.

    d. There are no permissions on the file.

  3. If there are no permissions on the file, who can delete the file?

Hints

  1. You can specify file permissions using octal. This is explained in this tutorial on Linux Permissions Basics.

Exercise 05: AFS Permissions (2 Points)

On the student machines, your home directory is stored on AFS, which is a distributed filesystem. While it has support for traditional Unix permissions, it has an additional layer of ACLs or Access Control Lists.

  1. Use the fs listacl command to view the ACLs on your home directory, your Private directory, and your Public directory. What are the differences in the ACLs for those three folders and what do those differences mean?

  2. What are the Unix permissions for the folder /afs/nd.edu/common? Use touch create a file /afs/nd.edu/common/$USER.txt (where $USER is your netid). What happened? Explain.

  3. How would you use the fs setacl command to give the instructor (but no one else but yourself) access to a folder in your home directory?

Exercise 06: Masks (1 Point)

Do each of the following:

  1. Type umask 000 and then use touch to create a file called world1.txt.

  2. Type umask 022 and then use touch to create a file called world2.txt.

  3. Type umask 044 and then use touch to create a file called world3.txt.

What are the permissions of each of the three files you created? Are they the same? Why or why not? Explain the effect umask has on file creation and how this can be useful.

Hints

  1. umask is explained in the Linux Permissions Basics tutorial.

Guru Point (1 Point)

For extra credit, install a Linux distribution either on a partition on your laptop or in a virtual machine. Once you have Linux installed, please show your setup to the instructor or a TA to verify.

There are a number of Linux distributions and which one you wish to install is up to you. That said, these are probably the most popular ones:

You can find a more exhaustive list on Distrowatch. For virtualization software, Virtualbox is a popular choice.

Feedback

If you have any questions, comments, or concerns regarding the course, please provide your feedback at the end of your README.md.

Submission

To submit your assignment, please commit your work to the homework01 folder in your assignments Bitbucket repository by 11:59 PM Friday, January 22, 2016.