This semester, we will use the CS department's Linux workstations for all programming in CS232. If you do not have prior experience with Linux, we can arrange a separate tutorial to cover all the basics that you will need. This handout provides information to help you get started with Linux, X and emacs, and pointers to places where you can find more information.
There are currently several public CS department Linux workstations located in the "Linux Lab" (beyond the "mini-focus", toward the back of the Science Center). Currently, these machines have names such as: druantia, shark, cardinal, finch, jay, lark, robin, swallow, thrush, warbler and wren (but the particular machines may change over time). There are 7 workstations in the lab SCI E125 that can be booted either to Windows XP or Linux (instructions for booting these machines are attached to the top of each monitor). The names of these machines are gorilla, gibbon, tamarin, orangutan, chimp, baboon and lemur. Finally, there are several machines in 121B (behind the consultant's desk in the mini-focus) and a couple machines in 173, the CS student lounge. If you want to stay current on the status of the Linux workstations, you may want to follow the Vibrant Linux conference on FirstClass, inside the Computer Science conference folder.
In order to use a Linux workstation, you must have an account on puma, the CS department fileserver. If you have taken other computer science courses at Wellesley, you probably already have a puma account. If you have only taken CS111, your account needs to be upgraded. To obtain a new account or upgrade an existing one, you need to fill out a form at the following website:
http://cs.wellesley.edu/user-info/
(Note that the addresses http://cs.wellesley.edu/ and http://puma.wellesley.edu/ are equivalent.) Select the link labeled appropriate forms on this page (these forms can only be accessed from on-campus) and then select the option registering for some other course or other reason in the list that appears. A new page will appear titled Puma Account Request. If you already have an account, then check the item near the top of this page that is labeled I already have an account, just list me in the class. You will then need to fill out the information in the rest of the form. This is a also chance to reset your account password if you have forgotten it or want to change it. If you do not have a puma account, select I don't have an account, please create one for me and fill out the rest of the information. You will also need to enter a "magic word" as part of the form -- ask a CS instructor for this word.
If you have forgotten your password, go to the above web page, click on the appropriate forms link, and select the option You need your password reset.
Regardless of which Linux workstation you use, all files in your account are physically stored on the puma fileserver and not on the Linux workstation itself. For example, if you are user gdome, and you create a file named ~gdome/test.txt while working on the workstation named teddy, this file is actually stored on puma and not on teddy. You can later view, edit, or delete this file from any other CS department Linux machine.
The easiest way to do your work in CS230 is to log in directly to one of the Linux consoles in the Linux Lab or E125. A console that is not in use displays a Fedora Core blue screen that has a small white window to enter your username. To log in, type your puma username (the same as your "short" FirstClass username) and press the Enter key. A second window will appear where you should type your password, followed by Enter. If the log in is successful, a new screen will appear with several icons in the left side (one will be labelled with the name of your home directory), and several icons along a popup menu bar at the bottom of the screen (you will need to move the cursor to the bottom of the screen to see it appear). At the far left end of the menu bar is a red hat icon that opens a menu, similar to the Start button on Windows machines. In this document, this menu will be referred to as the "red hat menu".
At this point, you should open a window with a Linux shell. To do this, select the System Tools>Terminal option from the red hat menu. A window will appear containing a shell prompt that looks something like
[username@hostname current-directory]
where username is your username and hostname is the name of the machine into which you logged in. The current-directory is the directory that you are currently connected to, and is initially set to ~ when you first log in.
A few things can go wrong when you are logging in:
The prompt that you see after selecting System Tools>Terminal from the red hat menu is part of a command-line interface to a Linux system known as a shell. At the shell prompt, you type a Linux command to execute, followed by the Enter key. Linux then executes this command, and upon finishing the execution, presents you with another shell prompt. This mode of interaction may be unfamiliar if you have only had experience with a point-and-click, drag-and-drop window system. Although many tasks are not as convenient in a text-based shell as in a graphical interface, some tasks, such as finding all files that satisfy a non-trivial specification or automating a sequence of tasks, are actually more convenient in the text-based interface.
There are a plethora of shell commands for tasks such as navigating through and modifying the file system, searching for files that match certain criteria, finding documentation, and invoking programs like text editors and compilers. For a quick introduction to some very basic commands, see Section 4 (Shell Commands) of Scott Anderson's article Introduction to Unix and the X Window System, which can be found online at:
http://cs.wellesley.edu/user-info/handouts/unix-intro.pdf
and is linked from the CS230 documentation page. For a more detailed introduction, read Chapter 4 (The Unix Shell) of Larry Greenfield's The LINUX Users' Guide. There are a few red-bound copies of this guide next to the Linux workstations in the Linux Lab. The guide is also available online at:
http://cs.wellesley.edu/user-info/handouts/linuxUsersGuide.pdf
Once you have mastered the simple shell commands and are comfortable with X Windows, Emacs, and Java, as described below, you are encouraged to learn more powerful shell commands. A good starting point is The LINUX User's Guide, particularly the following chapters: Chapter 6 (Working with Unix); Chapter 7 (Powerful Little Programs); Chapter 9 (I Gotta be Me!); and Chapter 11 (Funny Commands). Also, the Linux man command can be used to find detailed documentation on any command. For example, executing man ls gives documentation on the file-listing command ls.
When you first log in to a Linux machine, the X windows system is launched automatically. If for some reason, you are not running X on your machine, you can launch X via the shell command startx. This will change the display from a strictly text-based interface to a graphical windows interface similar to that on Macs and Windows machines.
The particular window manager we are using this semester is called Gnome. Using Gnome is fairly intuitive. As described above, at the bottom left corner of the screen is a red hat icon that serves a purpose similar to the Start button in Windows. Click on this icon for a menu of options. Some particularly important options are Programming>Emacs (to launch Emacs) and Internet>Firefox Web Browser (to launch Mozilla, a web browser).
Emacs is an extensible, customizable, self-documenting text editor created by Richard Stallman. (Many people consider it to be one of the greatest programs of all time -- it is one of the flagship programs of Stallman's Free Software Foundation and GNU project.) You will be doing most of your work this semester -- writing, executing, and debugging Java programs -- using Emacs. In fact, it is possible to do almost all of your work in the course entirely within Emacs. It is important for you to become a proficient Emacs user because this will save you a lot of time during the semester.
There are three standard ways to launch Emacs:
All Emacs documentation, including a tutorial and reference information, is available online. If you are unfamiliar with Emacs, you should take the online Emacs tutorial. You can do this by typing the Control and h keys at the same time, followed by the t key. (In Emacs notation, this keystroke combination is usually written C-h t and pronounced "control-h t''.) This will load an interactive tutorial, whose directions you should follow. When you complete the tutorial, you will know how to do basic editing in Emacs.
The tutorial teaches you keystroke commands for basic Emacs functionality. If you prefer, most of this functionality can instead be accessed using a combination of the mouse, menu items, and arrow keys. However, we strongly recommend that you learn the keystroke commands, as they will save you time and make it easier for you to work remotely from PCs or Macs (see Section 12).
In addition to taking the tutorial, you should read Scott Anderson's article Introduction to The Emacs Editor,which can be found online at:
http://cs.wellesley.edu/user-info/handouts/emacs-intro.pdf
Another useful introduction to Emacs is Chapter 8 (Editing Files with Emacs) of Larry Greenfield's The Linux Users' Guide. You will find links to sites containing Emacs documentation on the CS230 documentation page. A particularly useful link is the Emacs reference card:
http://refcards.com/refcards/gnu-emacs/emacs-refcard-a4.pdf
You may want to print out a copy of this card and carry it with you for handy reference.
There are three standard ways to print files from a Linux machine (the third gives the nicest looking output):
All of these options will print your document on printer psci1l, which is one of the printers near the mini-focus consultants' desk. If you use lpr or a2ps, you can print to a different printer using the -P option, e.g.,
lpr -Ppsci1r Test.java
a2ps -1 -Ppsci1r Test.java
(note that there is no space between -P and psci1r).
If you experience printing problems, please report them to our Linux system administrators at CS-SysAdmin.
In addition to saving work in your puma home directory, you should make backup copies of your work on a Zip disk or on your own personal computer. For instructions on how to use a Zip disk with the Linux machines, read Section 8 (Using Removable Disks) of Scott Anderson's Introduction to Unix and the X Window System.
If you want to leave a Linux workstation for a short break, you can "lock'' your console by selecting the Lock Screen item from the red hat menu on the menu bar. This will lock the screen in such a way that your password is required to unlock it. You should only lock machines for short breaks (as a rule of thumb, no more than 15 minutes). Otherwise, you will be tying up an important resource that someone else may need to use.
After you are done using a Linux workstation, you need to log out. To do this, select the Log Out item from the red hat menu. You know that you have succeeded in logging out when you see the Linux login prompt appear. It is important not to accidentally leave yourself logged in to a Linux machine when you are done. If you do so, someone may accidentally or purposely read, modify, or delete your files. Also, you will be tying up an important resource and creating a potential security risk for the entire system.
You do not have to be physically seated in front of one of the Linux workstations in order to use it. You can access the department's Linux machines remotely from the public PC's or Macs. From the PC's, which currently run Windows XP, you can connect to Linux machines using the Putty program, which can be found inside the Program Files>PUTTY folder on the local disk. After launching the program, enter the name of one of the Linux workstations (listed at the beginning of this handout) in the Host Name field. From Macs, which currently run OS X, first launch the Terminal program in the Applications folder. In the terminal window, you can then invoke the ssh program. To connect to the machine named teddy, for example, enter the following command:
ssh -l username teddy
Note that you may receive a warning indicating that the authenticity of the host cannot be established, and a question about whether you want to continue connecting. If you respond with yes, the ssh program should then connect you to the Linux machine. You can also connect from one Linux machine to another via the above ssh command. In you are logged in remotely, you can log out by executing the command logout in the shell created by your remote access program.
There are two key advantages of connecting to a Linux machine remotely. First, you can access the Linux machines from any other machine on the Internet. This is important when you do not want to go to the Science Center to do your coursework. Second, you can still use the machines even when all consoles are actively being used, because multiple people can be logged into the same Linux machine at once. A disadvantage to accessing the Linux machines remotely is that these clients provide only a text-based interface, so you will not be able to use the graphical user interface familiar from the console. For this reason, it helps to be familiar with Emacs control- and meta- key commands!