Share Project Files
As an instructor, you may have code, data, or other project files that need to be shared publicly with your classroom. Additionally, students may have assignments, projects, or exams that need to be shared privately with the instructor. Follow this guide to create public, shared classroom workspaces as well as private, individual student directories.
Create a Shared Directory for the Classroom
This shared directory will serve as a project workspace for the classroom and is only accessible to users in the same allocation. Recall that all users on one project will share the allocations of that project and belong to the same UNIX "group". As members of the same UNIX group, users will typically share the same permissions (read, write, execute, etc.) on a set of files or directories. The UNIX group number (ex. G-876543
) will usually correspond to the project/allocation number and can be found in the Portal by selecting Projects & Allocations then Active Projects.
Shared directories and files should be on the work file system. A good place to do this is at the root of your work directory - called $STOCKYARD
. To access the filesystem, log in to the HPC cluster for your allocation. Please check the user guides for instructions on logging in to TACC machines. To create a shared directory, follow the commands below.
# Make your STOCKYARD directory accessible to users in your group.
$ chmod g+X $STOCKYARD
# Navigate to that directory and create a class directory to be shared.
$ cd $STOCKYARD; mkdir class-directory
# Your shared class directory will need to belong to the UNIX group that
# matches your project allocation. For example, if the group is `G-876543`:
$ chgrp -R G-876543 class-directory
# Set your group ID so that new files created in the shared class directory
# will inherit the group ownership.
$ chmod g+s class-directory
# Set permissions so that the project workspace is readable and accessible
# to group members.
$ chmod g+rX class-directory
# Lastly, take note of the path to your directory. Students will be able
# to access files in the shared directory through this path.
$ cd class-directory
$ pwd
/work/01234/username/class-directory/
Copy a File from the Shared Directory
To copy a file located in the shared class directory, log in to a system of your choice and enter the following commands:
# Copy the file into your work file system
$ cd $WORK
$ cp /work/01234/username/class-directory/file1 .
Create Student Directories for Turning in Assignments
Individual student directories with permissions specific to that student will protect students' homework from being seen by other users in the same allocation. We encourage you to create a subdirectory in the class-directory
we made earlier to contain all of the student folders. To create the individual student directories, we have provided a script below.
On a system of your choice:
$ cd $STOCKYARD; cd class-directory
$ mkdir class-assignments; cd class-assignments
Helper Script
In your preferred text editor, copy and paste the code below and save as a shell script named student_dirs.sh
.
#!/bin/bash
for USERNAME in $@
do
if id -u "$USERNAME" >/dev/null 2>&1; then
echo "Making a folder for $USERNAME..."
mkdir $USERNAME
setfacl -m u:$USERNAME:rwx $USERNAME
else
echo "$USERNAME does not exist"
fi
done
unset USERNAME
Execute the shell script, listing the usernames of students on the command line to generate individual student directories:
$ chmod g+rX student_dirs.sh
$ bash student_dirs.sh username1 username2 username3 username4 username5
Alternatively, you can wget the script from the command line by doing the following:
$ wget https://raw.githubusercontent.com/TACC/TeachingWithTACC/master/docs/scripts/student_dirs.sh
$ chmod g+rX student_dirs.sh
# List out the usernames of students in your class
$ bash student_dirs.sh username1 username2 username3 username4 username5
Return to the Overview