GIS Lab Exercise #1

An Introduction to Unix and the GIS Laboratory

by
Thad Tilton
Department of Geography and Earth Resources
Utah State University
Logan, UT 84322-5240
ttilton@geog.usu.edu
 

This exercise will briefly introduce you to the Unix operating system, some of the software used in the GIS laboratory, and some of the rules and guidelines for using the system.

 

Unix Basics

Unix is a computer operating system, like DOS, Windows95, etc.  When you first log on to one of the Unix machines in the lab, you will see several windows and icons on your 'desktop'. The windows are referred to as 'Command Tool Windows', this is where you will enter commands.
The window in the upper left corner of your desktop is called the 'Console Window'. This window will display messages and warnings from the network, so it's a good idea not to type commands in this window.

Some of the icons you see may include the 'mailtool', 'calendar', or 'clock'. These icons can be maximized to windows by simply double clicking on them.
  
 
Additional progams may be brought up by placing your mouse cursor on the background of your desktop (the space that is probably blue) , holding down the right mouse button , and choosing from one of the menus.

 



 

Commands in Unix are also commonly refered to 'Utilities'. Although there are literally hundreds of utilities, there are only a handful of  that you will need to be familiar with to work in the GIS laboratory. Some of the most commonly used utilities are described below ...
(NOTE: Unix commands are always lowercase.)
 

                           that describe how to use the specified utility. Exampleman    c d     will describe the use of the cd utility.              When using   cd  , you can either give complete pathnames to the directory you wish to move to, or use some of the following options...
              c d  ../   moves you 'up' one directory.  For example, if you were in the directory   /auto/gis77/homework   and issued the command  cd  ../
                          you would now be in the directory    /auto/gis77
             c d ~    will move you to your 'home' directory.  So if you are user gis77 and are in the directory   /auto/gis67/homework/feb/data
                          and issued the command    cd ~   you would now be in the directory   /auto/gis77   (your home directory).
                          Likewise, you can follow the ~ with the name of another user to go to his/her home directory. A command of    cd  ~ttilton
                          for example, would put you in Thad Tilton's home directory
                         ( /auto/ttilton/ )
                With rm , you must specify a file or group of files to remove. You can either give a file name or use the wildcard '*'.
               Examples:
                       rm  myfile.txt     will remove only the file named myfile.txt (if it exists)
                       rm  *.txt             will remove all files that end with .txt
               Using the period '.' will put the fille in the specified directory and give the new file the same name. Using the period without a path will
             put  the file in you current directory.
             Examples:
                     cp   /auto/gisdata/textfiles/hisfile.txt    /auto/mydata/documents/myfile.txt
                                  copies the text file called hisfile.txt and renames it myfile.txt
                     cp  ~paxton/recipes/shoe.fly.pie     .         copies Paxton's recipe to your directory a keeps the same name

The window below shows an example of all the above utilities (except man):

Notice that the prompt (the text preceeding your commands) tells you which machine you are on ( land in the example above) and the name of the user who is currently logged on ( hafb above). The number after the user name is the number of commands you have executed in that command tool.

  

Assignment

      1)  Move to the following directory    /auto/utah/elev/dem/
           What letter do most of the files in this directory end with ?
           How many files in this directory end with .ps ?
           What command did you use to find out ?
 
     2) Make sure you are in the directory   /auto/hafb/elev/dem/
         Try to remove a file in this directory (don't be scared!).
         What happend ?

     3) Type in the command  cd ~
         What directory are you now in ?
      4) Type in the command  man ls
         Use the space bar or Return key to scroll through the text.
         What letters are used to indicate permissions for files ?
         Hit q to quit the man page and get back to your unix prompt.

 

To recieve credit for Exercise #1, mail answers to the above questions to  gisclass@geog.usu.edu
Make sure to include your name(s).

 
Using the ampersand  (&) at the command line

   By including an ampersand (&) at the end of your command line,  you can run programs in the 'background', meaning that your command tool  will
   give you another prompt and will still accept commands.
   Example:

  
     With an ampersand                                                            Without an ampersand

Note: not all commands need to be run in the background this way. The only time it is particularly useful for our purposes is when starting programs that
        launch a window(s). Netscape, ArcView,  WordPerfect, and Imagine are good examples of programs that should be started with an ampersand.
        Conversley, Arc, vi, and most Unix utilities (ls, cd, rm, etc) do not need ampersands.


Killing Unwanted Processes

Many times on the Unix system, you may find that a process (program) has been left running in the background on a machine either by you or another user. If the process was initiated by you, you have the ablility to remove it. Otherwise, you need to contact someone who has the power to remove any user's processes (System Administrator, Instructor, etc.).

1) The command psg can tell you if certain commands are still running, who owns the process, and the ID number used to eliminate it.
    To use the psg command, you need to include a text string that would appear in the program.
    Example:
         major{ttilton}23: psg netscape
         UID            PID        PPID    C       STIME        TTY       TIME     COMD
         ttilton       13440      12511      5      19:43:38      pts/7         5:18      /usr/local/netscape
2) If I am user ttilton, I can eliminate the process by issuing the following command (using the PID number above).
    Example:
       major{ttilton}24: zap 13440
     13440 killed with SIGTERM
    This process is now removed.
 


Quitting the System

To quit from your Unix login, pull down the RS/GIS Lab Menu by putting your mouse cursor in the screen background , holding down the right mouse button , and choosing exit ... (the last item on the menu). You will then be prompted to hit exit again to log out.

IMPORTANT:  Please make sure that you have not left any processes running on your machine when you log off (See 'Killing Unwanted Processes' above). It's OK to leave things like your clock, calendar,  mailtool, and command tools running. Processes like Arc, Netscape, Imagine, and Text Editors, however, must be properly exited before you log off the system.