Editing, Storing, and Retrieving Files in CS 115
This reading discusses the basics of working with files during CS 115 labs. Discussion in this reading is divided into three main sections:
High-level Overview
Working in the lab on CS 115 activities involves interactions with two separate computers:
- An Apple workstation physically located in the lab itself, and
- a remote server to store your program(s) between sessions.
The basic set up is illustrated in the diagram on the right.
A student/user works at a workstation in the lab. Typically, the Desktop and three other windows will be open.
- The Desktop provides a background for all other windows on the machine and serves to identify some commonly-used directories and files.
- Readings and instructions for the lab are available on the Web and viewable in a browser window.
- Programs or notes will be written and revised in a second window, running an editor, such as Aquamacs (preferred), TextEdit, XCode, or emacs.
- C programs will be compiled (translated to machine language) and run in a third window, called a Terminal window.
Since many students may use the same lab equipment, files developed on the lab machines are not saved from day to day. Rather, students will use a departmental server, called blue.cs.sonoma.edu for long-term storage of any lab work.

A Typical Flow of Work During a Lab
When You Log On
To use a lab computer in Darwin Hall, you will log in as a "student", using the password written on the whiteboard.
- When you log on, you will see whatever previous users might have left behind, except that
- User files are removed from each lab workstation nightly.
In summary, when you first log onto a lab computer, you might find some materials left over from previous users, but you are not likely to find your work from previous sessions on a lab machine.
Beginning Your Work
As you begin your session, you will need to make a fresh start on your workstation. This can be done in either of two ways:
- Create a new folder within the Desktop for your materials (to keep them separate from anything others might have left behind), or
- Copy a folder and your previous files from your long-term storage (on the department's server, blue.cs.sonoma.edu).
Making Progress on a Lab, Project, or Assignment
Much work in this course will involve creating, editing, compiling (see note ↠), and running programs. In practice, this work is best done using three separate windows, as shown in the above diagram.
- Use a browser to review readings and instructions for the lab.
- Use an editor (such as Aquamacs) to write and edit programs.
- Use a terminal window to compile and run the program.
Although the browser will be accessing materials on the Web, editing, compiling, and running programs require that the various windows all are set up to access the same file(s) in the same directory. (More about this shortly.)
As we shall see in the next few labs, compiling is a process of translating programs from a generally-readable format, such as C, to machine language—but more about that in a few days.
Finishing Your Work—Saving Your Files for the Next Time
When you have completed your work for the session, you will need to save your materials on the department's server. This involves two basic steps:
- Open a connection to the server:
- Type "command-k"
- Enter the connection string: afp://blue.cs.sonoma.edu
- Enter your departmental username and password
- Copy any relevant files from the directory on your Desktop to the relevant directory on the departmental server.
Mechanics
This section reviews the specific steps needed to accomplish the tasks described above.
Creating a New Folder on the Desktop
After you have logged into the workstation, the menu at the top-left of the screen should begin "Finder", "File".
- Click the "File" menu and then "New Folder".
- Once a new icon appears on the Desktop with the label "untitled folder", clicking on the label allows you to specify a name or title.
- Choose a title that relates to you (so this folder will not be confused with work from others). One possibility might include 115 and your name (e.g., "115-walker").
Opening an Editor
For this course, you must use a simple editor when writing programs.
- Fancy word-processing packages, such as Pages or Word, include much formatting information that confuses a computer when trying to run a program.
- Several editors are appropriate for CS 115. A recommended choice is Aquamacs (although TextEdit, XCode, and others are possible—but check with the instructor first if you wish to use something else).
At the bottom of the screen, you might find an icon for Aquamacs (or another editor of your choice).
- If so, just click on the icon to start the editor.
- If the appropriate editor icon is not present,
- Click on the "Finder" icon at the bottom left of the screen.
- When a new window appears, click on "Applications" on the left panel.
- Scan down the names given to find "Aquamacs.app" (or "TextEdt.app" or "Xcode.app), and click on the desired option.
- To create a new file with the editor, click on the "File" menu at the top-left of the screen and then click the "New File" option.
- To save the file,
- Use the "File" menu to select save.
- When a directory appears, click on "Desktop" and the directory/folder you wish to work with.
- Enter the desired name of the file, and click "Save".
The Aquamacs logo

Opening a Terminal Window
When working with programs (e.g., running them), you will need to work with a Terminal window; a Terminal window is an area where you will type commands, and the machine will respond based on what you requested. Opening and using a Terminal window can be done in either of two ways:
- If the Terminal Window logo is visible at the bottom of the screen, click on it.
- If the Terminal Window logo does not appear on the screen,
- Click on the "Finder" icon at the bottom left of the screen.
- When a new window appears, click on "Applications" on the left panel.
- Scan down the options to click on "Utilities" and then "Terminal.app".
When a Terminal window opens, it recognizes the folder/directory where you logged in—a home directory for "student". When working with your files, you will want it to recognize the folder/directory you created for your own session. This is usually done in two steps.
- After opening the Terminal window, move your cursor to that
window and type:
cd Desktop
The "cd" command is an abbreviation for "change directory", and you want to move from the login directory to the Desktop. - From the Desktop, you can move to the directory you created for
this session, using a comand such as
cd 115-your-name
If you have created and saved some files in your working directory, you can use the "ls" command to obtain a listing of all files saved in that directory:
ls
The Terminal Window logo

Setting Up Your Account for Storage on the Departmental Server
To store (and retrieve) files from the departmental file server, you first must connect to the server in three steps:
- Type "command-k"
- Enter the connection string: afp://blue.cs.sonoma.edu
- Enter your departmental username and password
Although you are free to organize your files in any way you wish, the following is recommended:
- Once connected to your account on the server, create a directory
for this course:
- Click on the server window, click on the "File" menu for the Finder (in the upper left of your screen).
- Click on the option for "New Folder"
- Label the newly created folder "CS 115" or equivalent
- Within the CS 115 folder, create four additional subfolders,
following the same basic process you have just used:
- Folder "labs" for collaborative work you will do with a partner during class sessions
- Folder "projects" for additional collaborative work
- Folder "supplemental-problems" for assignments you will be working on alone.
- Folder "current-work" for labs in progress.
With a "current-work" folder, you could start each session by connecting to the departmental server and copying your recent work to the lab workstation. This might be an easy way to pick up work where you left off from a previous session.
created January 11, 2022 revised January 12, 2022 |
![]() ![]() |
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |