15110 SUMMER SESSION TWO - 2014

System Environment

The laboratory activities and programming assignments of 15-110 require the use of computer systems running a version of RedHat Enterprise Linux adapted for the CMU environment called "Andrew Linux" and using a graphical interface known as the GNOME Desktop. This document describes how to perform some of the basic operations within that environment.

Contents:

Applications/Utilities

There are several application/utility programs that we will use in this class. These include:

gedit
A simple editor for creating/editing plain text and Ruby source files. It is listed as "gedit Text Editor" in the Applications/Accessories menu or by entering the command "gedit &" on the command-line.
Gnome File Browser (Nautilus)
The default file manager on the machines we are using.
Terminal
Creates a window in which commands can be typed and executed at the "command line".
ssh
Used for secure remote access to unix.andrew.cmu.edu from your home machine. It can be used to provide a terminal window and transfer files. It can also be used in conjunction with a local X server to channel graphic windows from a remote system.
Interactive Ruby (irb)
Accepts ruby statements/expressions and evaluates them, display the result. It should be executed by entering the command irb in a terminal.

About Files and Directories

Most operating systems, including Linux, Mac OS X, and Windows, organize data into files and directories (a.k.a. folders). A file's contents is just a sequence of bits whose meaning depends on what format the file is in. Each directory contains a listing of the files that are inside the directory. Technically, the directory consists of a listing of the names of the files and how to get at the files contents, but you can just think of it as a container that holds named files and their contents.

Since the contents of each file is just a sequence of bits, the computer needs to apply rules to decode the contents of the file as, for example, a JPEG image, a Word document, a text file, etc. In many operating systems, file name extensions (the last part of the file's name, after the last period) are used to indicate the files format (that is, which set of rules should be applied to interpret the contents of the file). Windows and Windows programs tends to hide these extensions from the user, adding them and acting based on them automatically. In Linux, the filename extensions are treated mostly as a normal part of the name that the user can choose however they want. Most files, though, are given extensions that reflects their contents, and these extensions are used by programs and the user as advisory information on the likely contents of a given file.

A directory (= folders) can also contain other directories, which are often (but not always) referred to as subdirectories (nested folders). The directory in which a subdirectory is contained is referred to as that subdirectories "parent directory". The nesting of directories can is often thought of as forming a "tree" that branches out from a single "root" directory with smaller branches (subdirectories of the root directory) coming of it, even smaller branches (subdirectoreis of the subdirectories comming from the even smaller branches, and so on.

In Linux, the "/" (slash) character is used to separate a directory from its contents (In Windows, "\" (backslash) is used for this purpose.), and can be used to create "paths" that identify files stored on the computer. For example, the path /afs/andrew.cmu.edu/usr22/vonronne/public/15110/bin/lightbotchecker.py denotes the file lightbotchecker.py inside the bin directory that is inside the 15110 directory that is inside the public directory that is inside the "vonronne" directory that is inside the usr22 directory that is inside the andrew.cm.edu directory that is inside the afs directory inside the computer system's root directory.

(The systems at CMU are setup, using the Andrew File System (AFS), so that the afs directory inside root is shared, and will look the same, on any Linux machine running AFS. (The AFS subtree is also available on Windows machines, but it will have a drive letter instead of being found at /afs.)

In Linux, each user is normally given a "home directory" as a place for them to store files. The symbol "~" is used to refer to the current user's home directory. And for any user usr, ~usr refers to that user's home directory. So, for example, since the directory /afs/andrew.cmu.edu/usr22/vonronne/ is the user vonronne's home directory, it can be referred to as ~vonronne, and the file /afs/andrew.cmu.edu/usr22/vonronne/public/15110/bin/lightbotchecker.py can be referred to as ~vonronne/public/15110/bin/lightbotchecker.py. Furthermore, the user vonronne can also refer to the same file using the path ~/public/15110/bin/lightbotchecker.py.

See also Computing Services' Using Unix & the Andrew System.

On Andrew Linux machines, directories can be created, files can be moved, etc., using the GNOME File Browser or from a command line within a terminal.

GNOME File Browser

You can use the GNOME File Browser (a.k.a. Nautilus) to browse your home directory. You can get their either by clicking on the home folder icon on the background of your desktop or by selecting "Home folder" under the "Places" menu at the top of the screen. (If you get asked whether you want to use Nautilus or Thunar as your file manager, choose "Nautilus".)

Once opened, the GNOME file manager can be used to explore your home directory, create folders, delete folders, and files, and compress files. (See the "File" and "Edit" menus.)

Creating Zip Files in Gnome File Browser

For each programming assignment, as well as several of the lab activities, you will be asked to create and handin a zip file. A zip file is a way of bundling multiple files (perhaps organized into directories) into a single file so that it takes up less space and is easier to move around.

One way to create such a zip file is as follows:

  1. Open up your home folder in the GNOME File Browser. (You can get there from the "Places" menu. If you get asked whether you want to use Nautilus or Thunar as your file manager, choose "Nautilus".)
  2. Navigate to the directory containing the folder/file(s), you wish to zip.
  3. Select the folder/file(s) you wish to zip (shift-click to select more than one). Then select "Compress" from the File Browser's "Edit" menu. (If there is no "Compress," see below.) This will open a dialog box. (See image at right.)
  4. Ensure that the filename has some base name with an extension of ".zip" (it will probably default to an extension of ".tar.gz", so you will need to change this to ".zip"), then press "Create".

"What if there is no 'Compress' in the 'Edit' menu of the File Browser after a file is selected?" This can occur if your account has become configured to use Thunar instead of Nautilus as the default file browser. If you have this problem, running the following command in a terminal should fix the problem:

  cp -b ~vonronne/public/15110/xfce4-helpers.rc ~/.config/xfce4/helpers.rc

After executing this command, if you re-open the File Browser from the "Places" menu, you should get the Nautilus File Browser.

If, however, the cp command resulted in the error message, "cp: cannot create regular file", then your problem probably wasn't that you were running Thunar instead of Nautilus. Double check again that there really is no "Compress" in the "Edit" menu when you have files selected in the File Browser.

Navigating Directories and Managing Files from the Command-Line

Opening a Terminal

In addition to using the GNOME desktop environment, you can also interact with the systems in the Gates Hall Cluster using the "command line." If you're sitting at the machine, you get a "command line" using the "Terminal" program listed under the "Applications"/"System Tools" menu.

This will create a terminal window that contains a black space with a white prompt that says something like [vonronne@ghc15 ~]$ where the vonronne indicates the currently logged in user, the ghc15 the machine that user is sitting at, and the ~ indicates the "current directory", which many commands will operate on implicitly.

You can type commands after the prompt and upon hitting enter they will be executed. For example, if you enter the command ls, you will get a listing of the files in the current directory, which in this case would be vonronne's home directory.

A description of a few basic commands can be found as part of Using Unix & the Andrew System.

Example: Creating a 15110 directory in private

Here is an example command-line session of the user vonronne creating a directory for 15110 within the private directory in his home directory.

[vonronne@ghc15 ~]$ cd
[vonronne@ghc15 ~]$ ls
15110    Documents  OldFiles   Videos   public
Desktop  Downloads  Templates  private  www
[vonronne@ghc15 ~]$ cd private
[vonronne@ghc15 ~/private]$ ls
[vonronne@ghc15 ~/private]$ mkdir 15110
[vonronne@ghc15 ~/private]$ cd 15110
[vonronne@ghc15 15110]$ pwd
/afs/andrew.cmu.edu/usr22/vonronne/private/15110
[vonronne@ghc15 15110]$ cd
[vonronne@ghc15 ~]$ ls private
15110

Example: Creating a Directory for Lab 2

[vonronne@ghc15 ~]$ cd
[vonronne@ghc15 ~]$ ls private
15110
[vonronne@ghc15 ~]$ cd private/15110
[vonronne@ghc15 15110]$ mkdir lab2
[vonronne@ghc15 15110]$ cd lab2
[vonronne@ghc15 lab2]$ ls
[vonronne@ghc15 lab2]$ gedit lab2.txt

Creating Zip Files with the Command-line

In addition to creating zip files through the GNOME file browser, it is also possible to use the zip program in the terminal. To use it, you enter a command consisting of: For example, if I wish to create a zip file pa1.zip in ~/private/15110 that contains the files in ~/private/15110/pa1, I could use command zip -r pa1.zip pa1 in the ~/private/15110 directory. I might do this as part of the following sequence of commands:
[vonronne@unix13 ~]$ cd 
[vonronne@unix13 ~]$ cd private/15110
[vonronne@unix13 15110]$ ls
examples  lab1  pa1
[vonronne@unix13 15110]$ zip -r pa1.zip pa1
  adding: pa1/ (stored 0%)
  adding: pa1/lb1.txt (stored 0%)
  adding: pa1/lb2.txt (stored 0%)
  adding: pa1/lb3.txt (stored 0%)
  adding: pa1/lb4.txt (stored 0%)
  adding: pa1/lb5.txt (stored 0%)
[vonronne@unix13 15110]$ ls
examples  lab1  pa1  pa1.zip
[vonronne@unix13 15110]$ 

Additional Information

  1. Remote Access
  2. Hand In
  3. Piazza