Computer Access and Use Information

Everyone who is registered in a computer science class automatically gets two computer accounts: one on the ACRC's Windows network, and one on "hills", which is a Linux server. By registering in this class, you also get a third account, on the Linux desktop machines in our classroom.

hills account info

Your hills account is on a Linux server, and gives you access to text file editing through the "pico" program, and C++ compiling through the "g++" program, plus other standard software. Hills may be accessed from any computer that has dial-up or Internet access, including the computers in the ACRC. To access hills, use any SSH or terminal emulation program, such as SSH Client or PuTTY.

Your hills login name is the same as your CCSFmail account user name. To find this user name, Login to Web4, go to the "Student Services & Financial Aid" tab, and scroll down to the "Student CCSFmail" link near the bottom of the page. Then click on "CCSFmail info". If you need help determining your login name, ask an ACRC staff member. If you've never logged onto hills before, your initial password for hills is your birthday, written like: jan0380 if you were born on January 3, 1980. You will be forced to change this password the first time you login, using this password as your "old password", and a new one of your choice for future use. If you've logged onto hills before, your password is the same as it was last time you logged in. Ask the ACRC staff for help if you don't remember your password.

To connect to hills, use a terminal emulation program such as SSH Client or PuTTY. From a Mac or Linux computer, you can open a terminal window and type:
ssh uname@hills.ccsf.edu
(Put your hills username in place of "uname" above.)

Linux Classroom Account Info

Your Linux desktop machine account is used when you sit down at a computer in our classroom (Batmale 413) or at one of the Linux desktop computers in the ACRC (on the right-side wall past the counter). Your initial login and password on this Linux account are the same as on hills, but remember they are different accounts. So if you change the password on one account, it doesn't change the other. Pretty much everything else you read below regarding Hills also applies to Linux. One big difference between our Linux desktop machines and the hills Linux server is that the desktop machines have a full graphical user interface (GUI), and can run programs such as Firefox, OpenOffice, etc. The hills system has only a text, command-line interface, as described below.

To use a Linux desktop computer to write, compile, and run a C++ program, here is what you do:

  1. Go to the menu:
    Applications->Accessories->gedit Text Editor
    and write your C++ program there.
  2. Save it to your home folder (default directory) with .cpp extension. (For this example, I'll assume you named your file "hello.cpp"
  3. Go to the menu:
    Applications->System Tools->Terminal
    and compile the program by typing:
    g++ hello.cpp
    (Make sure to use the correct name for your C++ program file instead of "hello.cpp" above.)
  4. To run the program, type:
    ./a.out

ACRC account info

Your ACRC account is used only to log into PC's in the Academic Computing Resource Center (ACRC) computer lab in Batmale 301, PC-Lab 2, plus some of the PC's toward the back-left of the main concourse. These computers are specifically for CS and CNIT students, and they have special software for our classes. Other computers don't require special logins. You can access Firefox, SSH Client, and compilers such as Eclipse from these computers, as well as other standard software.

There are also tutors available in the ACRC. They can help you with your homework. For extra help getting started with hills and the computers in the ACRC, go to a lab orientation in the first couple weeks of the semester. The login to your ACRC Windows account is the same as the initial login to your Hills account described above. Your initial password is your birthdate in the same format as it was for hills, and this password is reset at the beginning of each semester, so your old password is no longer valid if you've logged in to the ACRC network in previous semesters. If this is your first login to your Windows account, or if your password has expired (approximately every 45 days), there is a reminder to change your password, and you should do so.

Make sure to log off when you are finished with the computer. To log out of Windows, go to the Start menu at the bottom-left-side of the screen and select "Log Off"

Homework submission guidelines:

When turning in a programming assignment, the entire source code listing of your program must be included, along with sample test results that show the full range of your program's behavior. You can use any C++ compiler to do this. It can be done using copy and paste, or other tools. Instead of using Linux and g++, you can install your own C++ compiler, such as those listed on my links page.

If you do use hills (Linux) as described in this document, the best way to capture your output is to save it as a script. To do so, simply type "script myscript.txt" at the Linux prompt. You should see the following message in response: "Script started, file is myscript.txt". This means that everything displayed on the terminal window from now on will be saved in a text file called myscript.txt. When you are finished testing your program and you want to stop adding to the script file, type "exit", and you should see the following: "Script done, file is myscript.txt" The file "myscript.txt" can then be printed, or submitted for your homework, etc.

Warning: Make sure you always exit your script when you are done testing your file. If you don't exit the script, your script file will keep growing and growing. Also, never run pico when a script is running. The screen displayed by pico will fill your script file with junk.

To get help or ask questions, use the class's Insight discussion board to ask your classmates for help. (I will read and respond to discussion board postings too.) Please don't post more than a couple lines of C++ code to the Insight discussion forums, as other students may copy your work. If you need to show a large part of your code to ask your question, please e-mail your question to me directly. If you are e-mailing me your question, please include as much information as possible: send me your full program and the exact results it produces (error messages or other output).

Linux Basics

The ACRC has put some good Linux-related tips online

One common mistake with hills Linux is when people use the mouse. On hills, we are using Linux with a text-only interface, so your mouse does nothing to interact with hills. When you're using hills, forget about the mouse. Another common mistake is that people don't know Linux is case- sensitive. So file and program names must always be in the correct (upper or lower) case.

When you log in to hills using your own username, you will automatically be placed in your own directory on hills. So you can save any files you wish in that directory or any subdirectories you create. All the files you create will be there for you next time you login.

Here is a list of basic commands you should know, all of which you type at the main Linux (bash) prompt:

ls
list files in current directory. Use ll to list all files (including hidden ones)
rm myfile
remove (delete) the file specified (replace myfile with your file's name)
cp oldfile newfile
copy file: above will make a new copy of oldfile, calling it newfile
mv oldfile newfile
move file: above will change the name of oldfile to newfile
mkdir newdir
make directory: above will make a new directory called newdir
cd newdir
change directory: above will make newdir the new working (current) directory
cat myfile
concatenate (display): above will print the contents of myfile to the screen
more myfile
same as cat, except it shows only one page at a time. Hit space to see next page, or "q" to stop display.
script myscript.txt
create a script file called "myscript.txt" (use any name you wish, but please end it with .txt). Script file will contain all future screen output. Don't forget to type "exit" to stop scripting! More details are above under "Homework submission guidelines".
exit
exit, or logout, from hills. Or if you're in the midst of a saving your output to a script, this will stop the scripting.
Ctrl-C
To terminate a program - if you need to stop a program and get back to your Linux prompt (maybe your program is in an infinite loop or something) - type Ctrl-C (Control and 'c' together). If you just close your terminal emulator without stopping your program or logging out, the program will continue to run indefinitely, and you won't be able to delete that program file!
man xxx
manual page: Linux online help: above will tell you more about xxx. So to learn more about ls, type "man ls"
quota -v
Used to find out how close you are to your quota and maximum limit of storage space on hills.

There are two main programs you'll use on hills: pico for text file editing (including writing programs) and g++ to compile your C++ programs. Following are some basic directions on how to use these programs:

pico (text editor)

To run pico to create a new file, simply type "pico" at the Linux prompt. To use pico to edit an existing file (or create a new one) type "pico filename" where filename is replaced by whatever file you want to edit. To save your file in pico, type Ctrl-o (for write Out), and to exit, type Ctrl-x (it will prompt you to save if you've made changes). The is a limited menu of commands at the bottom of the pico screen, with the control key represented by ^. To insert a file that you've saved on hills into the document you're currently editing, type Ctrl-R.

g++ (C++ compiler)

Once you've used pico to write your C++ program, use g++ to compile it. The filename for your program must end in ".cpp" so that g++ knows it is a C++ program. So for instance to compile a program called prog1.cpp you would type the following command: "g++ prog1.cpp". If your program didn't compile correctly, you'll get errors or warnings telling you what's wrong. Otherwise, g++ should have created an executable file for you called "a.out". So to test your program, simply type "a.out" at the command line.

Logging Out

When you are done using any computer system, you should always log out. To log out of hills, type "exit" at the command prompt. To log out of the Windows network, go to the Start menu and select "Log Off".

Summary: Step-by-Step Instructions for Doing Homework

You may use any text editor and any C++ compiler to write and run your program; just make sure you turn in a text file containing your source code and sample output. Here are some step-by-step instructions for doing all this using CCSF resources that are available from anywhere:
  1. Sit at a computer that is connected to the Internet (dial-up connection is okay). If personal account login is necessary, see "ACRC account info" above.
  2. Run a terminal emulation program such as SSH Client or PuTTY.
  3. Connect and Login to hills.ccsf.edu
  4. Use a text editor to write your C++ program. For example, to create a program called "hello" type the following at your Linux prompt: pico hello.cpp and then in the pico window type the C++ code for your program, such as this one. When you are finished writing your program, save it and exit pico by typing Ctrl-X followed by Y to save.
  5. Compile your program using g++. Continuing with the "hello" example, type the following at your Linux prompt:
    g++ hello.cpp
    If you just get another Linux prompt, then your program compiled successfully. If you get any error messages, use pico to fix the problems in your C++ code and compile again.
  6. Run your program by typing: a.out
  7. Once your program works and you're ready to turn it in, it's time to save its source code and output in a file. Start this by typing script helloScript.txt at the Linux prompt.
  8. Now use "cat" to display your file on the screen (and in the script file): cat hello.cpp
  9. Run your program again: a.out
    Make sure to show a variety of test-cases to demonstrate your program's behavior (by running it as many times as necessary).
  10. Terminate the script by typing: exit
  11. You should turn in this script file (named "helloScript.txt"), so you'll need to transfer this file to your computer. You can do this using an FTP program, or by copying and pasting. FTP is more reliable, so those instructions follow:
  12. Run an FTP (File Transfer) program on your computer. You may have one available as part of SSH or other software, or you can download a free FTP program here. Use the FTP program to connect to hills.ccsf.edu, and type in your username and password.
  13. Since you're transferring a text file, you should set the transfer mode to ASCII text (this will be done automatically if the filename you're transferring ends with ".txt".
  14. On one side of the FTP program under "Remote Site" you should see your files on hills, including "helloScript.txt" (you may need to change directories). Use the other side, "Local System" to navigate to the directory you want to put your typescript file into, then drag the helloScript.txt file into the directory.
  15. Now use your web browser to access http://insight.ccsf.edu and log in to this course in Insight. Click on Assignments at top-left and select the assignment you want to turn in. At the bottom of the page for the assignment, click on the Browse button to select your file from your hard drive ("helloScript.txt" that you just transferred using FTP).
  16. Click on the Upload this file button to submit your homework. You should see a confirmation page saying, "File uploaded successfully"
  17. Don't forget to log out! In your terminal emulator window, log out of your hills account by typing exit. In your FTP program, to disconnect click the Exit button or close the program. And of course log out of Insight by clicking InsightHome on the top left, then clicking Logout at the top-right of the Insight home page.

More Information

For more information on many of these topics, see my Links page at http://fog.ccsf.edu/~cpersiko/links.html