Assignment 1: Software Engineering Toolkit 1.0 (Getting Started, A.K.A., Linux Basics)

Assigned: 1/11
Due: 1/18 at 11:59 p.m.

Note: Because this may be the first time using your UD Lab account please complete this early! If there are any problems with your account you may need me to troubleshoot them. You are welcome to work with others in the lab with you in case you can't figure out how to make something work, but this is an individual assignment and you should submit your own work.

Part I: Getting started in the CS Lab

  1. Try to log into the UD Lab in 103A EPS using your normal user name (omit the and your initial password usernamestudentid. Please follow Your account logon instruction on course website for more details.
  2. If step 1 fails, please get in touch with your professor immediately. You are now logged on to a Linux computer. In the top left you should be able to see your files (Computer or Home) and in the bottom right you should see . Use the menu to find the Linux terminal . You'll notice a search box for other applications, and some quick links.

  3. Please click the terminal icon to open the terminal. The terminal is a program that runs a shell, which is the primary development environment for the course. The terminal/shell give you access to many command-line applications, the file system, and other system resources.

  4. Type passwd (password command) to change your password to something easier to remember (and more secure) if necessary. You should be prompted for your old password and your new password. Save for later (technical difficulties).

  5. Type ls (list command) to see your files and directories. You should have a "Documents" folder. To change to the Documents folder type cd Documents (change directory to documents). While you're in your Documents folder, create a folder for this courses (mkdir csci325) and cd to your csci325 directory. Inside make a directory called program_half and change to it.
  6. In your terminal type emacs hello.cpp to invoke the Emacs text editor. Try hitting Enter on the terminal. Note that it is no longer functioning because Emacs is in the foreground. The Emacs editor (like many good text editors) functions primarily based on keyboard commands, not on the mouse--programmers are often much faster that way. In order to close Emacs type C-x C-c (Emacs speak for holding Ctrl and hitting x followed by holding Ctrl and hitting c). If your key combos were entered into Emacs (note not to have the Terminal highlighted) you should have closed the editor. Note that while you were "editing" hello.cpp, no file should appear when you list the terminal again.

  7. Open Emacs, this time with emacs hello.cpp&. Note that now you can enter terminal commands like ls. The ampersand put Emacs in the "background" so you can now enter other commands in the "foreground" of the terminal. Go back to Emacs and enable spell-checking by hitting M-x (hit escape once [don't hold it down] and hit x) then type flyspell-mode and hit the Enter key. You should see something like (C++/l Fly Abbrev) in the gray bar at the bottom if it worked (flyspell mode is enabled) or an error message otherwise.

    In Emacs set up a C++ "Hello World!" program. To save your file to the current directory type C-x C-s.

    A few notes about Emacs:
    1. As you type your hello world, note that Emacs automatically selects the correct indentation next line for you. Note that when you start a newline you can hit the tab character on the keyboard, and your program (functions, loops, conditionals, multi-line statements) will all be indented properly automatically. From here on out I am going to expect your indentation to be consistent with Emacs auto-indentation (in other words, I shouldn't see indentation errors in your programs).
    2. Feel free to modify your hello world program as you see fit to test the auto-indentation. For instance, you can type "cout << 6 + 4 / 3 [enter] << "Hello World!" [enter] << endl;" and each line's << operator should line up correctly.
    3. Regardless of where you are in the program, Emacs will try to preserve proper white-space use in your program--try hitting tab and see if it will budge ; )
    4. Emacs automatically reacts (when possible) to the extension of your source code file by selecting the programming language and conforming to standard conventions (see the "C++" that automatically appears at the bottom of the editor).
    5. When you hit M-x earlier you invoked the Emacs minibuffer (where you typed flyspell-mode. Many useful commands live there:
      • E.g., M-x flyspell-mode turns on spellcheck.
      • M-x replace-string finds and replaces a given string
      • M-x tetris or M-x doctor will probably waste far too much of your life.
    6. Fun fact: the M in M-x stands for meta. A key that lived on many early keyboards. (Feel free to impress people at parties with that one.)

  8. In this class you will compile your programs on the command line using the g++ compiler: g++ hello.cpp. If you list the directory contents you should see a new file "a.out". You can invoke your new C++ program by name ./a.out as long as you are in the correct directory (the ./ means "in the current directory" where ../ means in the parent directory). In this class we will be giving our programs better names. We pass additional arguments to command line programs to change the way that they behave. To give your program the name "hello" type:
    g++ hello.cpp -o hello

    The -o flag tells the compiler to expect an output file name next. Now you should see (and be able to execute) the hello binary.

  9. Type the following commands (with Enter after each) into the terminal:
    ls -l

    The pwd command stands for "print working directory" and the -l flag tells ls to do a "long" listing of the directory contents. The ./ in ./hello means "in this directory" to distinguish between the possible command "hello" (I told you that it would be useful).

  10. Take a screen-shot (menu->applications->accessories->screenshot) so that I can see the results of the previous commands in the terminal and the open Emacs window and save it to your account (please make sure both are visible).

Part II: Off-site access.

This section will walk you through the basics of accessing the department's computing resources while you are out of the lab or off-campus. One of the beautiful things about Unix development is that as long as you can access a terminal and the Internet, you can log into a Unix machine from anywhere in the world and work as if you were working on your local machine.

Note: When I say "off-site" access, you don't have to physically leave EPS (or even the lab) unless you really want to. Doing the following from another machine (your laptop, your desktop, one of the computers in G1) will get you prepared for what to expect.
  1. On your computer try to log into If you are on a Linux or OS X computer bring up a terminal (on OS X go to Applications>Utilities> You can log in remotely through ssh: ssh If you are on Windows you can download and use the program PuTTY. You should be able to log into cs1 by typing into the "host name" box.

    Note: We are aware of a networking bug that makes the domain name "" unavailable in certain parts of the campus. If this does not work you can use in its place. (You may want to save a note somewhere in your computer until we get this issue resolved.)

  2. Now that you're logged in remotely, use your new-found terminal powers to cd to where your code is. Open your "Hello World!" program in Emacs the same way you did before (without the ampersand). (Wow!) Both Emacs and the terminal should respond the same way to your keyboard regardless of whether you are sitting in the lab or a coffee shop.

    If you accidentally use the ampersand your program will seem inaccessible on a remote connection, however the fg [foreground] command will retrieve a job from the background and bring it back to the foreground. Feel free to try it. You can also suspend a running program like Emacs to the background with C-z. (The two will go back and forth on a remote connection.)

  3. Figure out how to take a screenshot on your operating system of choice with Emacs running on cs1 editing your code (hint: use a search engine).

Part III: Downloading files from outside the lab.

With your new-found Linux powers you should be able to do more than just work remotely without much in the way of additional effort. For the final part of this lab you should be able to log into CS1 remotely to upload and download your files. If you get into a pinch you may find yourself working off campus with a need to download your files for immediate submission. If you cannot accomplish this you may be in trouble. Again, please perform this step on your own machine (or at least in another lab).
  1. (For OS X/Linux users:) You should be able to use the sftp command (the same way you logged in with ssh). Many of the ssh commands will still work with sftp (ls, cd, pwd). There are two new commands of immediate value: get and put. The get command pulls a file off the machine you are logged into and downloads it to your local machine. The put command uploads a file (as long as you are in the correct directory when you invoke sftp) from your machine, to the server.

  2. (For Windows users:) There is a free program you may use called WinSCP. With WinSCP you can log into a remote server (cs1) and download your files to a Windows machine. The WinSCP web page hosts a version of WinSCP that can be installed on your local machine or dropped in as a pre-configured binary (you can drop this version in your documents on your standard UTM account). Once logged in you should recognize one window as the computer you are currently on and the other as your files on the CS domain.

  3. (All Operating Systems:) Use one of the above methods to download your hello world file to your local machine from cs1. Create a plain text file called README (with any small amount of text in it) and upload it to your account on cs1. Please take a screen-shot that shows that you have downloaded your hello.cpp file from cs1 and that you have successfully managed to upload your README file (either using get/put or by dragging files in WinSCP).

Part IV: Downloading files from outside the lab.

Open a text linux_commands.txt file and define what the following commands do (please number and label each). You may have to try some of them out first:

What to submit:

A single zip archive named (use your name) containing:
  1. Your screen-shot from I.10 showing that you are in the correct directory, that the correct files are there, and your Emacs window.
  2. Your screen-shot from II.3 with your computer running Emacs to open your hello.cpp (through a terminal ssh connection) on cs1.
  3. Your screen-shot from III.3 that shows you have successfully downloaded your hello.cpp file and uploaded your README file.
  4. Your definition file linux_commands.txt.