Lab 1: Lab introduction

The goal of this lab session is to help you become familiar with the environment and operating system in the CS lab.

I. The Desktop

A. The name game

Already you've noticed that the computers here in the lab are using an operating system other than Microsoft Windows or MacOS, and with which many of you may be unfamiliar. You'll also hear a variety of names thrown around: Ubuntu, Unix, Linux, and GNOME. Which one of these are the lab's computers running?

The shortest answer is that the name of the operating system we're using is Ubuntu. However, Ubuntu is a variety of Linux, which in turn is often considered a variety of Unix, so you could get away also with saying that our lab uses Linux or that our lab uses Unix.

(Technically, Ubuntu is an operating system that uses the Linux kernel; the Linux kernel is a core operating system component which can be used to build a Unix-like operating system. UNIX (note the capitals) is a trademarked name for an operating system that dates from 1969; it originally was the property of the phone company, back when there was the phone company.)

GNOME is the name of the desktop environment (or windowing system) that we use. It's possible to run GNOME on operating systems other than Ubuntu, and it's possible to run environments other than GNOME on Ubuntu.

B. Exploring the desktop

Take a look under the Applications menu. We'll use only a handful of the available programs in this course, but you may want to try some of them on your own time. Look also under the Places and System menus. We will look more at some of these later.

Launch Firefox, and go to the URL http://cs.wheaton.edu/~cgray/csci23/. Then click on the link for "Linux tutoral 1" by today's date, and you should see an online copy of these instructions.

Read this entire paragraph before doing what it says. Notice at the bottom right corner of the screen you'll see what looks like a recycle bin (which it is), and just next to that two rectangles, the left one orange and the right one gray. Click on the right rectangle. You'll see that this window has disappeared. Click on the left rectangle to get it back.

The GNOME environment allows you to have several "virtual" workspaces active. This will come in handy if you have more windows open than is convenient to have on the screen at once. To move a window to a different workspace, right-click on the title bar of the window and select "Move to Workspace Right" etc. Later we will see how to configure your account to have more than two workspaces, if that suits you.

II. The File System and Terminal

A. Two ways to look at files.

Under the "Places" menu, select "Home Folder." This will bring up a window called the "File Browser" which lets you navigate the the file system; you'll notice that it looks more or less like the "Finder" in Mac OS and "Windows Explorer" in Windows. The folders (or directories, as we'll tend to call them) which you see there are automatically created for every new account. We won't be using any of these very often.

From the top menu bar of the screen, select Applications->Accessories->Terminal. The window this brings up is alternately called the terminal, xterm, shell, or command line. It provides a way to interact directly with the file system and to execute programs by typing in commands. It's an old-fashioned way to work, but once you get used to it you'll find it's faster for many of the things we do. In the next few minutes we'll be learning a handful of commands.

First, type ls into the terminal. You will see that it responds by printing the names of the same directories you see in the file browser. This command lists the contents of a directory. We'll use it as our first example of a Unix command.

Unix commands have three parts: the command itself, flags (optional), and arguments (optional). The arguments tell what to execute the command on, and the flags (which usually begin with "-" or "--") modify the behavior of the command. Now type

ls -l

(That's the letter ell, not the digit one.) You'll see the same directories listed again, but now they're formated differently and with a mess of other information. The -l flag indicates that you want to see the details of the items being listed, including whether the item is a directory or plain file, the permissions-level of the item, the owner of the item, and date and time when the item was last modified. Now try

ls -a

The -a flag indicates that you want to see all the files in the current location, even "hidden" files. As you can see by the result, hidden files are files that begin with a period. Mostly these contain information about your account, including customizations you have done. Certain applications maintain hidden files to keep a history. If you type

ls -la

that is, using both flags (the order doesn't matter), you can find out which hidden files are directories and which are plain files. The ones whose information line begins with "d" are the directories.

Take note of two hidden files in particular: "." and ".." . These are special directory entries and will appear in any location; they stand for the current directory and the parent directory, respectively. The single dot isn't very useful, but try typing

ls ..

will show you the directory that contains all user's home directories--- although you should not go poking into those directories themselves. This does show you the first example of an argument to a Unix command. In this case we gave the name of the directory ("..") whose contents we wanted to list. Likewise,

ls Desktop

Will list the contents of the Desktop directory, which is probably empty.

B. Managing directories

In this section we will learn how to modify and navigate the files in your account. If you ever get lost, you can find out where you are with the command pwd, which stands for "path to working directory." Try it now. You will see something like

/homes/msnerd

Which indicates you are in the home directory for the account msnerd, which is in the directory homes, which contains all the home directories. You can create a new directory with the command mkdir, and you can move into a directory with cd, "change directory." For starters, make a directory for this course--in case you do something else later on.

mkdir csci233
cd csci233

Now make a directory for today's work.

mkdir lab1
cd lab1

Notice that the file browser-- if you still have that window up-- reflects the making of the new directory as a new folder icon appears. In the terminal, you can always go back to the previous directory with cd .., that is, change directory to the parent directory. Also, typing cd alone without any arguments will always take you back to the account's home directory.

C. Managing files

In this section, you will learn to use the following commands:

cpcopy a file
catdisplay a file (or concatenate two or more files)
lessdisplay a file
mvmove (or rename) a file
rmremove (delete) a file

Copy the file aeneid from this class's directory. You will frequently do a copy like this at the beginning of a lab or project, since you will be provided starter code for most of your assignments.

cp /cslab/class/csci233/aeneid .

cp takes two arguments-- the first is the "source", the file you want to copy, and the second is the "target" or "destination", the place where you want the copy to go. In this case, "." means "here." Now ls will show that the file is now in the directory.

A note on etiquette: Every user has a home directory. It is rude to go poking about in other people's homes, even if nothing prevents you from doing so. You may browse public areas, such as /cslab, but you should visit areas under home directories only when you have been invited.

As you can see in the table above, we have two commands for looking at a file. Most of the time when you want to view a text file, you will also be editing it, for which you'll be using a text editing program. Accordingly, cat and less aren't commands you'll use all the time. They are, however, easy commands to practice with. Try

cat aeneid

You'll see that that the contents of the file are dumped to the terminal. For long files, this is generally not very helpful. We'll use cat for other purposes later. To view a file, you're better off using less. Try

less aeneid

This program lets you scroll through a file using the arrow keys. Hit 'q' to quit. (Why are these commands called "cat" and "less"? cat is short for "concatenate," because the command can also be used to chain several files together, when that's useful. less is a tongue-in-cheek name given because the less command is an improvement over an earlier command called more; the name more was given because instead of giving the file all at once, the command lets you indicate when you want more of the file.)

Next, you can make a copy of a file in the same directory but with a new name. Use cp as before, but give the name of the new file (instead of a new location) as the target, for example

cp aeneid aeneid2

The mv command is similar to the cp command. mv can be used either to move a file from a location to another location or to "move" the file within the same location but with a different name--- in which case what you're really doing is renaming the file. Do the following to make a directory, move one of the "aeneid" files into it, and rename the other one.

mkdir foo
mv aeneid foo
mv aeneid2 aeneid3

Use ls to observe the results. Finally, the rm command is used to remove or delete a file. Try the following.

rm aeneid3
rm foo

First, notice that the terminal never asks you if you're sure you want to delete something; moreover, rm deletes files for good--- it doesn't put them in the trash or recycle bin, so you can't resurrect it if you change your mind. You'll have to get used to thinking before pressing the enter key. Second, notice that removing the directory didn't work. The terminal will not delete a directory unless it is empty or if you use the -r flag.

rm -r foo

III. A first taste of Python

In Firefox, go the the class page, and follow the link for today's lab to "Python exercise 1". When you've done that, pick back up here.

IV. Configuring the Desktop

Spend a few more minutes exploring how to customize the appearance of the desktop. Rather than give you directions, I will let you figure this out on your own. Under System->Preferences, you will find items to let you change the appearance, mouse operation, screensaver, etc. If you need help, ask.

Some things in particular you should do:

To log out, go to System->Quit, and select log out.


Last modified: Thu Jan 14 11:03:38 CST 2010