When I write labs and projects, it looks like a lot of work. But that’s because I write them like tutorials. This lab has a lot of reading because you are probably new to all of this stuff so I have to explain everything. Read and follow along, and you should be done in no time.

For this course, we’re going to be using a few different technologies and servers to do the labs and projects. It’s going to work like this:

diagram: there are three computers: your computer, the AFS server, and thoth. your computer connects to the AFS server with FTP, and the AFS server stores your files. your computer connects to thoth with SSH, and thoth compiles and runs your programs. thoth and the AFS server are connected to each other.


AFS (the Andrew File System) is a worldwide networked system that lets you access files across a huge number of educational, research, and governmental institutions.

Every Pitt student is given some free space on Pitt’s AFS servers. How do you access it? With…


FTP (the File Transfer Protocol) is exactly what it sounds like: a way of transferring files back and forth over networks like the internet. SFTP is the secure (encrypted) version of FTP.

Using SFTP, you can access your AFS space to upload and download files. But that’s all it does. If you want to run commands, you need to use…

SSH and thoth

SSH (secure shell) is a program and protocol that lets you securely connect to a computer across the internet and interact with it.

You know your command-line or terminal interface? It’s that. Except, instead of your own computer, you’ll be running commands on another computer.

thoth is a computer in the CS building. It has all the software you’ll need to do work for this course: gcc, gdb, valgrind, and so on. It’s also configured in some special ways to make debugging easier.

Later projects will also use features only available on thoth. So please don’t try to compile your projects on your local machine.

1. Getting connected

First, if you haven’t already, follow the instructions on the FTP page. Next, you need to connect with SSH.

Nothing will show up when you type your password. That’s normal. Also, don’t worry about the “unauthorized access” message. You are supposed to be logging in. You’re authorized ;)

Windows users

You need to get an ssh client, PuTTY (use the 64-bit installer).

  1. Run PuTTY.
  2. Use thoth.cs.pitt.edu as the address and click “Open”.
  3. Say “Yes” to the certificate. (This only happens once.)
  4. Give your username (lowercase) and password, and you’re in!

Mac users

  1. Open up Terminal (⌘+Space, type “terminal”, hit enter).
  2. Run this:

     ssh yourusername@thoth.cs.pitt.edu
  3. Say “Yes” to the certificate. (This only happens once.)
  4. Give your password, and you’re in!

If you can’t log in, please ask the TA for help. If you are sure you’re putting in your username in lowercase, and the right password, please email me and CC Dr. Khattab (skhattab@cs.pitt.edu). He’s the thoth administrator.

2. Where are we?

When you log in, you are placed in your home directory.

  1. Try using pwd; it’ll show you the full path of your home directory.
    • Your home directory can be referred to as ~ in many commands as a typing shortcut.
  2. Try using ls. It will list the files and directories.
    • Your private directory is what you want to do your work in. No one else can see it.
  3. Do cd private and you’ll move into that directory.
    • pwd again, and you’ll see that your directory changed.
    • You can use cd .. to move up one directory.
    • You can use cd ~ to go to your home directory.

Common UNIX commands

Here’s a quick reference guide to refer back to.

3. Setting up your ~/.bash_profile

bash is what you’re using right now - the thing you type commands into. .bash_profile is the configuration file for bash.

  1. Do cd ~.
    • This goes back to your home directory.
  2. Do chmod u+rw .bash_profile
    • This makes it possible for you to edit it.
  3. Open your FTP client and sign in.
    • You will usually have both FTP and SSH open at the same time.
    • FTP for files, SSH for commands.
  4. You should see your home directory by default (public, private, all that stuff you just saw).
  5. Look for a file named .bash_profile in your remote folder.
    • If you don’t see it, it’s probably hidden by your FTP client.
    • WinSCP has the Ctrl+Alt+H shortcut to show hidden files.
  6. Right click .bash_profile file and choose “Edit” or some equivalent.
    • Have your FTP client open it in your code editor (VS Code, Sublime, Eclipse, etc)
    • Now you should be editing that .bash_profile file on your own computer!
  7. Scroll down to the bottom of the file. There, you’ll see:
     # Define your own private shell functions and other commands here
  8. Copy and paste this exactly:
     if [ "$HOSTNAME" = "thoth.cs.pitt.edu" ]; then
         source /opt/set_specific_profile.sh;
  9. If you want a nice-looking terminal prompt like I have, find the line that starts with export PS1, and replace it with this:
     export PS1="[\[\033[1;32m\]\h\[\033[0m\] \[\033[1;34m\]\w\[\033[0m\]]: ";
  10. Now save the file in your editor.
    • If you are using WinSCP or Cyberduck, it should automatically upload the file to AFS.
    • If you are using FileZilla, you will have to confirm that you want to upload.
  11. Back in SSH, do source .bash_profile
  12. Try doing man open. If you see this, yay! Hit q to exit.

If you see No manual entry for open then you messed up somewhere. Make sure you saved your file and that it uploaded through your FTP client, then do the source step again. If you still can’t get it to work, ask for help!

4. Making a simple program

Organization is good. Don’t just do all your work in private. Make a directory for your 449 work!

  1. In SSH, go to your private directory with cd private.
  2. Do mkdir cs0449.
    • if you ls, you should now see cs0449 listed.
  3. cd into cs0449.
  4. Make a lab1 directory and cd into that.
  5. You can create empty files with the touch command. Do touch lab1.c to make your new program.

Now the file exists, but has nothing in it.

  1. In your FTP client, refresh the remote view.
    • If you make changes to folders/files in SSH, you will not see those changes in your FTP client until you refresh.
  2. Now go into private/cs0449/lab1 and then edit the lab1.c file in your local editor. Put the following in it:

     // Your Name (username)
     #include <stdio.h>
     int main() {
         printf("Hello World!\n");
         return 0;
  3. Save (and possibly upload) the file.
  4. In SSH, you can double-check that the file was uploaded by doing cat lab1.c.
    • cat prints out the file’s contents.
    • if nothing printed, then the file is still empty, and you need to try saving/uploading again.
  5. Now, compile it like so:
     gcc --std=c99 -Wall -Werror -o lab1 lab1.c

    If you did it right, it should print nothing. With UNIX, “no news is good news.” Successful commands will usually be quiet. But if you ls, you should now see a new file, lab1. This is your executable!

  6. Type ./lab1 to run your program. It should say “Hello, World!”

If you got this far, woo, now you know everything you need to know to write, compile, and test C programs! Now develop it a little further…

  1. Copy the get_line function from the 2_get_line_success.c example into your program.
    • Remember - put it before main so you don’t have to use a prototype.
    • You also need to add #include <string.h> to the top of the program for strlen().
  2. Now you’ll write a small function to uppercase a string.
    • C has a function toupper() in <ctype.h>, which converts a single character to uppercase.
    • Name your function uppercase().
    • Your function will take a char* argument that is the string to uppercase.
    • It will uppercase the string in-place.
      • (It changes the values in the array.)
    • Remember that strlen() is a O(n) function!
      • You do NOT want to call it once per loop. Otherwise, your loop will be O(n^2).
      • Put the string’s length into a variable, and use that in your loop condition.
  3. Now in main, use get_line() and uppercase() to make your program behave like this:

     Type something in: this is what the user typed in!
     Now in uppercase: THIS IS WHAT THE USER TYPED IN!

5. Archives and Submission

Your labs and projects will be submitted by copying (cp) files to a special directory.

Please follow these instructions for this and every lab/project you do. Bookmark this page!

  1. Make sure your name and username are in a comment at the top of your .c file.
  2. cd into your ~/private/cs0449 directory.
  3. Make a copy of the lab1 directory like so: cp -r lab1/ lab1_copy/
    • Making a copy reduces the chances of you losing all your work.
  4. Make a tar archive. tar lets you bundle several files together.

    This is the step everyone messes up and loses their work on. Please be careful.

    • Do this, using your username, not abc123.

      $ tar cvf abc123_lab1.tar lab1/
  5. Check that the tar archive has the right files.
    • tar tvf abc123_lab1.tar will list the contents of the archive. It should look like:
        $ tar tvf abc123_lab1.tar
        drwxr-xr-x abc123/UNKNOWN1    0 2018-01-19 01:06 lab1/
        -rw-r--r-- abc123/UNKNOWN1   78 2018-01-19 00:54 lab1/lab1.c
        -rwxr-xr-x abc123/UNKNOWN1 6424 2018-01-19 01:06 lab1/lab1
  6. gzip the tar file to compress it. It’s as easy as:
     $ gzip abc123_lab1.tar
    • Now it should have transformed into abc123_lab1.tar.gz.
  7. Finally, copy it to the submission directory.
     $ cp abc123_lab1.tar.gz ~jfb42/submit/449

If it worked correctly, it will say nothing. No news is good news!

But if you’re unsure, you can double-check that you submitted it properly like so:

$ ls ~jfb42/submit/449/abc123_lab1.tar.gz

and done correctly, it’ll show your filename:


If you messed up and need to submit again, then fix your mistake, repeat these steps, but rename your tar file to abc123_lab1_2.tar.gz before copying it to the submission directory.

If you mess up again, repeat, name it abc123_lab1_3.tar.gz, copy.

If you mess up again, repeat, name it abc123_lab1_4.tar.gz, copy.

If you mess up again, repeat, name it abc123_lab1_5.tar.gz, copy.

If you…. ok I think you get the idea.