Quick & Dirty Guide to Getting Started in CSE 303

This is a quick guide to help you get started using linux/unix for cse 303. This includes setting up your shell, trying some basic commands, and dipping a toe into Emacs. We suggest that you use one of the instructional Linux or Windows machines. If you use Linux, you'll get an "xterm" terminal when you log in which you can use to execute commands, so skip to the "Basic Unix Commands" section. If you'd rather use Windows, the following sections will help you set up a terminal and an "X server" to make the Windows machines act somewhat like the Linux machines.

Working on Windows: SSH and Reflection X

When working on Windows machines, we suggest you use SSH to log into a Linux session on Attu (attu.cs.washington.edu) and use Reflection X to give you a graphical interface.

Logging in from the basement labs

If you're going to be using the labs (such as AC 002), everything is all set up for you. Simply double-click the "SSH-X attu" icon on the desktop. A Reflection X dialog box may appear asking if you would like to run the 'Performace Tuner'. For now, just click 'No'. If you have never connected to attu.cs from the machine you are using, you will get a 'Host Identification' dialog box with some information about the security protocol (SSH) used to connect to this machine. Click the 'Yes' option. Type in your CSE account password when prompted and you're all set.

We need to do a little setup to make sure this terminal works the same way as a Linux xterm. First, go to the 'Edit' menu of the SSH window. Select the 'Settings' option. Select the 'Keyboard' subsection of the 'Profile Settings' on the left of the Settings dialog box. Ensure that both 'Use Alt as meta key' and 'Backspace sends delete' options are checked. Click 'OK' then save your changes by clicking the save icon or or selecting 'File->Save Settings'. If you do not save your settings, you will have to do this every time you log in. Saving the settings on one machine should affect all the Windows machines in the CSE labs.

Now look for the Reflection X icon in the notification area of the taskbar (usually in the lower right corner of the screen). The Reflection X icon looks like a little, teal pyramid with an "X" on it. Right click the icon and select 'Settings'. On the left side of the Reflection X Settings dialog box, scroll down to and select 'Keyboard'. Uncheck the 'Left' option in the 'Alt key reserved for Windows' section. Also ensure that 'Backspace key sends Delete' is checked un the 'Options' section. Click 'Apply' then 'OK'.

Accessing your Linux home directories from Windows

If you're in the basement labs, your O: drive should already be mapped to your Unix home directory. Look under for the O: drive under "My Computer" in the Start Menu. To accesss your files, go to O:\unix\homes\iws\userid, replacing "userid" with your own CSE account username. All the files you saved while working on Attu should be there.

If you're in the labs and your O: drive isn't mapped, open up a Windows Explorer window (by clicking the "My Computer" from the Start Menu) and in the Tools menu item, select "Map Network Drive" and enter O: for drive and \\ntdfs\cs for folder. Click Finish. If you're at a computer that does not use CSE's name servers, for example in Mary Gates Hall or at home, you will need to use the fully qualified name, \\ntdfs.cs.washington.edu\cs.

For more info on this, see the CSE support page that discusses Microsoft DFS, which is what we just used.

Working elsewhere

We recommend you work in the basement labs where we have checked that the right software is already installed and the directions we provide are correct. If you still want to work elsewhere you have a few options. You should test your homework on attu.
  1. Install the necessary software on your computer. Linux and everything we will use in this course is freely available.
  2. Install Reflection X on your computer, using the CSE department instructions. What a Reflection X session does is connect you to a CSE UNIX server. Everything you type or click is sent to the server, which sends back to your computer what to display. So you're using the department's software installation.
  3. For those savvy with terminals and ssh, it is possible to run emacs directly in terminals after connecting via ssh to the department, but it is not particularly pleasant.
  4. You can change your desire to avoid the department labs.

Basic Unix commands

To move around through the directory structure in your shell window, you'll need to know a few basic Unix commands. For instance:
attu4% mkdir mydir
attu4% ls
mail  mydir
attu4% cd mydir
attu4% pwd
/homes/iws/sbfan/mydir
attu4% exit
Each line that starts with 'attu4%' (the prompt) shows the use of a different command. Anything that comes after a line on which a command was entered and before another prompt is the output from the previous command. In the above: These are just the very minimum basics, or course.

Changing your shell

The shell is the program where you type in commands. There are different shell programs, which are all similar but have different rules and features. For sake of uniformity, we will use a shell called 'bash' but it's likely that your account is set-up such that when you log in the shell it uses is 'csh'. You can change this for the time being or once and for all. We strongly recommend the latter, but we'll explain the former first to help you understand what is going on.

Changing your shell for the time being: Type

attu4% bash
Now you may have a different looking prompt (such as -bash-3.1$). Otherwise at this point you will not notice any differences, but that's only because you don't know any differences between bash and csh. When you type
bash-3.00$ exit
you'll be back to the shell you were running when you typed bash. That is, you started running a different shell and when you exited, you just went back to the outer one.

Changing your shell once and for all: You could type bash every time you login, but that's a pain and you could get confused if you forget. So you can tell the operating system once and for all that for your account, the "first shell" should be bash. From any prompt, type:

chsh -s /bin/bash
You are running the 'change shell' program and specifying that your new shell can be found at /bin/bash. It's almost that simple: As a final note, if your shell already is bash, chsh will just say "Shell not changed".

Emacs

Now that you have your shell ready, let's open Emacs. Emacs is a very powerful text editor.

Type 'emacs &' to open emacs in a new window. You might be asking, "What's the deal with th &?" Well, the & tells the program to run "in the background", which means, for our purposes, that we can keep using the shell while also using the program, emacs in this case. If you don't type the & you won't be able do anything in your shell. window.

[GNU Emacs: a labeled diagram]

Emacs uses many key combinations involving the Control and Meta keys. On keyboards that don't have Meta, Alt is usually used as a substitute. If Alt doesn't work, ESC is equivalent to Meta. When we were setting up Reflection X, above, we made sure that the Alt key was able to be used as the Meta key. Regardless of which physical key we use (an actual dedicated Meta key, Alt, or ESC), we refer to the key as Meta. Key combinations are denoted C-x (Control-x (lowercase)) or M-x (Meta-x, Alt-x if you've followed this guide, or ESC-x).

A sequence of key presses is written like C-a C-b M-x, which would mean do the three actions (Control-a, Control-b, Meta-x) in sequence. Some commands might involve keypresses with no modifier keys (Control or Meta), for instance C-x b RET (switch to the previous buffer) would be type Control-x then the 'b' key then the 'enter' key.

The most important keys in Emacs Getting help in Emacs (the next most important keys) Some other useful keys:

Font-coloring in Emacs

Remember the Emacs modes we were talking about earlier? The modes for shell-scripting and C programming do a pretty good job of coloring your code, but you may need to say you want that: That's it. To check if it works, you need to restart Emacs. Save your file (C-x C-s) and quit Emacs (C-x C-c), and open it up again. Open up
~/.login
. Built-in bash constructs like if and set should be in different colors. DO NOT edit this file unless you know what you're doing.


Finally, there are other resrouces, including the CS Lab and Support pages.

Acknowledgment

These notes have evolved over the last few years, but are largely based on notes written by Keunwoo Lee in 2001. They started as a guide to CSE 341; information on SML has been removed. They now include instructions on changing your default shell to bash, which you should do for 303 unless you really do not want to. The notes were updated by Lincoln Ritter for autumn quarter 2006.